0

I'm relatively new into designing databases so this is my first project and I'm trying to understand better it's structure.

I need to create a SQLite database where there will be a simple USERS table with personal information such as name, sex, age, etc.

Then, each user will Add as many Dog names they want on a List.

I was considering to use more than 1 table, where every user will have it's own ID and it will be assigned with the other table, however I'm not sure how to do it without leaving the user with a limit of dogs.

How should I design it to support as many dogs as the user wants?

5
  • 3
    You do it by using a DOG table that references the USERS table. Read up about foreign keys - this is exactly the concept that allows you to represent unlimited relations between things. Nov 3, 2015 at 11:39
  • Thank you Kilian. I'll do some research on this topic. But it looks that I'm on the right path, isn't it?
    – Machado
    Nov 3, 2015 at 11:53
  • 1
    In addition to the above, what you are trying to create is called a "one to many" relationship.
    – GisMofx
    Nov 3, 2015 at 12:35
  • This is one of the more common relationships, so try to understand the relationship well. If you're not sure the relationship between two entites, ask yourself, "Does one X have many Y?" followed by "Does one Y have many X?" If the answer is Yes/No or No/Yes, you have one-to-many. If it is No/No, then it is one to one, and if you have Yes/Yes, you have many-to-many.
    – Neil
    Nov 3, 2015 at 13:07
  • Interesting. That's a one-to-many relationship.
    – Machado
    Nov 3, 2015 at 13:11

1 Answer 1

1

You can have a separate table for dogs where you have the general information for each dog and then an owner field.

If you you don't like that, you can also have a separate table for dogs and then a relationship table that relates the dogs to their respective owners.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.