Answer the question
In order to leave comments, you need to log in
What is the best way to format foreign keys in a database?
Hello, tell me how to implement such a system correctly:
There is a user table in which there are users with a unique ID, users must have a table of things.
There is a table of things that looks like: item id, item name, description.
Should I create a unique table for each user and refer to it? But how?
Or is it better to indicate its owner in the table of things for each item, referring to the ID in the user table?
Help me figure it out, it doesn't work at all.
Answer the question
In order to leave comments, you need to log in
You have a table of users.
You have a table with all items.
You want the user to have items.
To do this, we enter a separate table, where it will be:
user id, item id, quantity (for example).
I advise you to read some book on the theory of relational databases.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question