Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

GTHell's avatar

Multiple pivot table or one pivot table with multiple columns?

What is better when designing a many-to-many relation? For instance, I have a table users has relationship with projects table and the column that has many to many are like, add_to_watchlist, and transaction. I wonder if I should store this three in one pivot table or separate them all?

0 likes
3 replies
shez1983's avatar
shez1983
Best Answer
Level 23

definitely separate.. you could consider a polymorphic type where you have an extra field but KISS.. just have a separate tables one for watchlist, one for transactions.

1 like
GTHell's avatar

@shez1983 I just made one table with all the field as true or false. How do you come up with naming those pivot table?

shez1983's avatar

naming depends on what relationship it is you are trying to link two tables.. ie subscribers as opposed to product_users.. so anyone can see whats happening.. because in certain cases you might have product_users again for another relationship

Please or to participate in this conversation.