Answer the question
In order to leave comments, you need to log in
Do I need a user ID field in both tables?
To capture the essence of the issue, the situation is as follows.
- there are users
- there are projects created by users
- there are tasks for projects mentioned above
----------------
- users
--- id
- projects
--- id
--- id_user
--- title
- tasks
--- id
--- id_project
--- message
--- id_user (?)
--------------------
Previously working with other people's codes (in the end I adopted it for myself) I noticed that wherever the user creates something there is an id_user field , and this is understandable, but if there is an intermediate table with this field (in my case, projects) then in tasks (what would be all in feng shui) this field does not need to be added already (or is it not feng shui anymore?)
When selecting stasks, we have id_project , we can find out our cherished id_user in the projects table from it . tasks.id_project is associated with projects.id projects.id_user is associated with users.id
It seems that everything is elementary, but why then create id_user in both tables, anyway, the data in these fields will be the same (in id_user), and if they are different, then these are already errors in the application.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question