Structuring the database and linking data

Please could a kind individual help me understand how I link data types in my Bubble App because I just can’t get my head around it. I’m new to Bubble and I’ve watched loads of videos and read the manuals and other forum posts about this but I’m still confused so please be patient with me…I’m used to MS Access where you have tables and set up the relationship between primary and foreign keys etc. But in Bubble it seems to be different.

Let’s say I’m responsible for the cars at work and need to create a Bubble app to track who’s using each car and when it’s due to go out and come back. What would be the best way to create my data structure to create a minimum viable app so that people can book cars for when they need them?

I already have a Data Type for “User” and I add to it fields like first name, last name, email, job title and office address. This stores info about the employees who can use the cars and who’ll log in to the app to make bookings.

I then create a second Data Type for “Cars” and create fields like Registration Number, Make, Model, Colour, Mileage, Last Serviced. This logs all the cars and lets me keep an eye on when they’re due routine maintenance.

In order to track bookings of available cars that tracks who (ie which “User”) has what Car and when they will have/had it…

Do I create a third Data Type called “Bookings” and put in fields like “UserEmail” with field type “User” (to link across to the email field which uniquely identifies each user in the “User” Data Type field), then a field for “Car Reg No” with field type “Cars” (so that it links to the Cars data via the unique “Registration Number” field) and then create Date/Time fields for Date Out, Time Out, Date Returned, Time Returned. That will store all my bookings in the “Bookings” Data Type

OR

Would I just create Fields in the “Cars” Data Type for “User” (To link to the user data in the User Data Type) and then create Date Out, Time Out, Date Returned, Time Returned fields?

If anyone could explain this to me like I’m 5, I’d really appreciate it.

Thank you so much in advance.

1 Like

There’s various ways to go about it - mainly it comes down to exactly what kind of data you need to store, and how much of it you’re likely to have…

But in your case, I’d assume that you want to store specific data about a booking such as time/date booked, length of booking, date retuned etc.

So in that case, as you mentioned, create a separate datatype for booking.

Have a field for User (of type User) and a field for Car (of type Car) so you can link the booking to a specific car and user.

Then have whatever other data fields you want (such a date booked, date returned etc).

That’s all you need to do, although you may also decide to attach the bookings to either the User, the Car, or both.

In which case add a field for Bookings (of type Booking) to the User, Car, or both, as a List.

If the number of bookings per User or per Car are relatively small then adding them as a list can make it easier and quicker to find bookings relative to Users or Cars, so is probably the best way to go.

Thank you so much for taking the time to explain that to me. I think I get it now and it’s kind of cool that I was pretty much there with it. You’ve really helped me. Thank you!

1 Like