(Deprecated) Budibase Docs
  • đź‘‹Introduction
  • Quickstart tutorials
    • Build a CRUD app
      • Importing the Vehicles table from a CSV
      • Creating the Service log table from scratch
      • Listing recent Service Logs on the home screen
      • Creating a new Service Log with a modal
    • Build a CRUD app- SQL
      • Connecting to your SQL tables
      • Creating Screens from your SQL tables
      • Using relationships between SQL tables
      • Creating a List screen from scratch, using a SQL table
      • Creating a new log, with a modal
    • Build a CRUD app - REST
      • Adding a REST datasource
      • Creating a query that Lists Issues
      • Using your request to display items in your app
      • Add a “Create Item” request
      • Create a new todo Item, inline
      • Mark todo items as “Done”
      • Finishing Touches
  • Building apps
    • Data
      • Users table
      • Data sources
        • Internal/CSV
        • PostgreSQL and MySQL
        • REST
          • REST Queries
          • REST Bindings Example
          • REST Query Import
          • REST Authentication
          • REST Variables
        • Other sources
      • Data Types
        • Text
        • Number
        • True/False (Boolean)
        • Date/time
        • Options
        • Attachments
          • Example
        • Relationships
          • Example
        • Formula
        • JSON
      • Views
        • Filters
        • Calculations
        • Groups
      • Transformers
    • Design
      • Screens
      • Layouts
      • Components
        • Section
        • Container
        • Data Provider
        • Repeater
        • Table
        • Chart
        • Card
        • Text
        • Button
        • Link
        • Icon
        • Image
        • Embed
      • Forms
        • Form Component
        • Field Groups
        • Fields
      • Bindings
      • Actions
      • App State
      • Conditions
      • App theming (coming soon)
      • Handling Data
        • Search/Filter Data
    • Automate
      • Automation steps
        • Triggers
        • Logic
        • Actions
      • Activating and testing
      • Contextual bindings
    • Admin and management
      • User Management
      • Authentication and SSO
        • OpenID Connect
        • SSO with Auth0
        • SSO with Azure AD
        • SSO with Okta
        • SSO with OneLogin
        • SSO with Google
        • SSO with Keycloak
      • Email
      • Portal
      • User Settings
  • Guides
    • Display user-related data
    • Add search
    • Add filtering
    • Create public & private screens
    • Writing a custom SQL query
    • Create a child record from the parent
    • Items assigned to me
    • Master-detail
  • Self-hosting
    • Get started
      • Budibase CLI Setup
    • Hosting methods
      • Overview
      • DigitalOcean
      • Kubernetes (K8S)
      • Docker compose
    • Hosting settings
      • Advanced options
        • Reverse proxy
    • Accessing CouchDB
    • Accessing MinIO
  • References
    • Budibase architecture
    • Deployment information
    • Troubleshooting
    • Contributing to Budibase
      • Writing Your Own External Data Connectors
Powered by GitBook
On this page
Export as PDF
  1. Quickstart tutorials
  2. Build a CRUD app- SQL

Using relationships between SQL tables

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:

  1. Select your SQL datasource

  2. Click on “Create Relationship”

  3. Set relationship type to “One”

  4. The from (“One”) table is “Vehicles”

  5. The to (“Many”) table is “Service Logs”

  6. The “From Table Column” is how your relationship will be named in your Vehicles table. We will call this “Service Logs”.

  7. 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

  1. Click “Update Display Columns”

  2. For “Vehicles”, choose “Registration”

  3. For “Service Log”, choose “Description”

PreviousCreating Screens from your SQL tablesNextCreating a List screen from scratch, using a SQL table

Last updated 3 years ago