I am working on a social platform like web site. I’m not sure what should be the table structure of this situation;
I will have trips that users will create. And users can add users to the trips that they traveled with.
So;
>One Trip >Many users
Should I create the with just two columns;
>tripID >userID
and adding new row for every new user for the same trip ?
Or do you have any other opinion ?
Thanks for any advice.
You have several different relationships here:
This means a one-to-many for trips to user for creating trips (a user can create many trips, a trip has one creator).
You also have a many-to-many, as a user can go on many trips, and trips can have many users, so you need a join table for that.
I would name the join table trip_users, as that is the two joined entities in alphabetical order, which is a standard in some places:
trips
users
trip_users