Reputation: 914
For example, I have Users
and Projects
tables.
Multiple users can be members of a project. How do I insert multiple users into the members
column of the Projects
table?
Do I separate by comma like: "John, Alex, Hanna"?
I'm a beginner in MySQL, sorry if this is a dumb question. Thanks!
Upvotes: 0
Views: 47
Reputation: 1680
You defiantly need another table. It should look like this
Name: UserProjects
Field: UserId
Field ProjectID
Those 2 fields should be primary keys (dual primary id). If you want to go down the route of 'soft deletes' then add a status column which you'll set to 0 if you delete it. Also look up insert on update for mysql.
Trust me this is the way to go. Using a delimiter field or something will only give you problems later down the line.
Upvotes: 3