Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6854889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:41:23+00:00 2026-05-27T01:41:23+00:00

I am trying to figure out how to structure this database. I have used

  • 0

I am trying to figure out how to structure this database. I have used Apple’s core data before just fine, I’m just working on a different project now that requires MySQL. I am very new to MySQL so please go easy on me. 🙂

For this example, let’s say I have three tables, User, Device, and Location. Drawing it out, a Location can have many Devices, but the Device can only have one Location; Each User has its primary key, UserID, of which I need to use to fetch the correct information.

So how do I create a relationship like this here? I’ve heard of creating an index and a foreign key and I’m not sure how they work exactly.

In the end, what I need to do is be able to access the User‘s specific table and view all of the Locations associated with that User. I will also need to be able to add a Device at a certain Location for a certain User.

Again, please forgive me as I’m trying to wrap my head around MySQL. I am using HeidiSQL to do my database editing.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:41:23+00:00Added an answer on May 27, 2026 at 1:41 am

    User – Device is a many-to-many relationship, so you’ll want to introduce an intermediary table to resolve that relationship. That table simply consists of two foreign keys, one referencing the User table and one referencing Device. Device – Location can be handled with a simple foreign key in the Device table pointing to a Location table.

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to figure out the best data structure to use for this
I have a view that will look like this: I'm trying to figure out
I'm trying to figure out what to do here. I have customer data in
Okay I've been trying to figure this out for a while now. I have
This query works fine but I'm having trouble trying to figure out why it
I am trying to figure out what type of structure or container I should
Trying to figure out the best way to do this: Should I do something
Trying to figure out this pseudo code. The following is assumed.... I can only
I am trying to figure out this error since 5 hours without any success.
Ok, when trying to insert into the database I'm getting this error You have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.