I have three tables in database:
trips(trip_id(pk), trip_name(unique), user_id(fk))
places(place_id(pk), place_name(unique))
trips_places_asc(trip_id(fk), place_id(fk))
Since many trips can have many places, I have one junction table as above.
If a user inserts places to the trip, the places will be added to places
table and the trip will be associated with the places in trips_places_asc
table.
So, if I write a query like:
INSERT INTO places (place_name)
VALUES ('XYZ')
INSERT INTO trips (trip_name)
VALUES ('MyTrip')
then how to store trip_id
and place_id
in Junction or Association table trips_places_asc
? Will I have to fire two queries?