Creating Connections

Learn how to add connection fields to your tables and establish relationships between different types of data.

What You'll Learn

This guide walks you through the process of creating connections between tables in your Knack application. You'll learn how to add connection fields, choose the right tables for your connections, and configure connection settings.

Adding a Connection Field

Creating a connection between tables involves adding a special field type - the Connection field - to one of your tables. Here's how to do it:

  1. Navigate to the Records or Fields section in Builder.
  2. Select your desired (child) table.
  3. Open the right panel, and select the table to add the connection to or;
    • In the records tab, insert a new field by selecting the field header from an existing field, and click to add a new field to the left or right. Select Connection as the field type.
    • In the fields tab, select Add Field, and select Connection as the field type
  4. Select the connection type.

Choosing the Correct Table

Where you place your connection field depends on the type of relationship you want to create. Follow these guidelines when deciding where to place your connection:

For One-to-Many Relationships:

  • Add the connection field to the child table. Each record in the child table allows to select one value from a list of values from the parent table.
  • Example: Navigate to an Employees table and add a connection field. Select the Company table to connect to. An Employee can belong to one Company, and a Company can have many Employees.

For Many-to-Many Relationships:

  • Add to the table used more frequently
  • Example: Navigate to a Students table and add a connection field to Courses. A student can select multiple courses, and when you go to the Courses table, each course can have multiple students selected. Students will be updated more frequently than courses, so add the connection field there.

Configuring Connection Settings

When creating a connection field, you'll need to configure several settings:

  1. Basic Settings:

    • Name: The field name that appears in your Builder
    • Description: Internal field description (appears as tooltips when viewing records)
    • Required: Whether the connection is mandatory
    • Default: Default selection option
  2. Format Options Based on Relationship Type:

    • For One-to-Many Relationships:
      • Searchable Dropdown: Single-select dropdown with search capability
      • Radio Buttons: List of options with single-choice radio buttons
    • For Many-to-Many Relationships:
      • Multi-Select Dropdown: Dropdown allowing multiple selections
      • Checkbox List: List with multiple-choice checkboxes

Examples

Creating an Employee-Company Connection

  1. Navigate to your Employees table
  2. Add a new Connection field
  3. Select the Companies table as the table to connect to
  4. Choose "One-to-Many" as the connection type (one company can have many employees)
  5. Name the field "Company"
  6. Set format to "Searchable Dropdown"
  7. Save the connection field

Creating a Students-Courses Connection

  1. Navigate to your Students table
  2. Add a new Connection field
  3. Select the Courses table as the table to connect to
  4. Choose "Many-to-Many" as the connection type (students take multiple courses)
  5. Name the field "Enrolled Courses"
  6. Set format to "Multi-Select Dropdown"
  7. Save the connection field

Tip: Create parent records first, so when adding child records, you'll have existing parent records to connect to.