If guest has many bookings and a booking has many guests then you have a Many-Many relationship for which you would use a booking_guest pivot table.
https://laravel.com/docs/5.5/eloquent-relationships#many-to-many
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have an accommodation booking site and in my database I have a guests table and a bookings table, and I need to relate a booking to the specific guests for that booking. There could potentially be any number of guests.
The obvious solution on the face of it would be a one (booking) to many (guests) relationship as per here: https://laravel.com/docs/5.4/eloquent-relationships#one-to-many but this then sets a foreign key on a guest tying it to that specific booking. But of course guests will make many bookings over time so each guest record can not be permanently hard wired to a specific booking.
My idea therefore was simply to store guest IDs in a string on the booking separated by pipes '|' and do a 'manual' lookup when I want to find guests associated with a booking. But is there a better way of modelling this (in either SQL or Laravel or Eloquent)? I'm using MariaDB/MySQL as the database, if that makes any difference.
Thanks
If guest has many bookings and a booking has many guests then you have a Many-Many relationship for which you would use a booking_guest pivot table.
https://laravel.com/docs/5.5/eloquent-relationships#many-to-many
Please or to participate in this conversation.