Budibase allows you to declare relationships between your table. We are going to set up our one-to-many relationship between Vehicles and Deals.
Note that Budibase does not modify your tables. We are simply telling Budibase about your existing database structure.
To create a relationship:
Select your SQL datasource
Click on “Create Relationship”
Set relationship type to “One”
The from (“One”) table is “Vehicles”
The to (“Many”) table is “Service Logs”
The “From Table Column” is how your relationship will be named in your Vehicles table. We will call this “Service Logs”.
The “To Table Column” is how your relationship will be name in your Service logs table. We will call this “Vehicle”
The relationship is now created, however, we need to tell Budibase how to describe the Vehicle from the Service Log table, and vice versa. To do this, we need to set the “Display Column”. This is equivalent to a column alias:
SELECT ServiceLogs.*, Registration as Vehicle
FROM ServiceLogs
INNER JOIN Vehicle on ServiceLog.VehicleId = Vehicle.id
I.e. use the Vehicle “Registration” column when displaying it in the Service Table.
So, we will set up our display columns
Click “Update Display Columns”
For “Vehicles”, choose “Registration”
For “Service Log”, choose “Description”