YouTube

By loading the video, you agree to YouTube's privacy policy.
Learn more

Load video

If you want to view or modify the relationships between the tables in your database, then you can click on the Relationships tab. It’s specifically designed to help you complete the following tasks:

Getting around

Before we dive into the specifics of these tasks, let’s first take a look at how the interface is organized. It may look a bit overwhelming at first, but rest assured, there’s a clear logic to it.

The Relationships tab shows a list of rows that tell how the tables in your database are related. Each table that you selected in the previous step has its own row. You can find them in the left-hand side of each row under the 'Table list' header. They’re sorted by table type. At the top you’ll find the subject tables, then the linked tables, and further below all the reference tables. Each of these table types is color-coded with blue, orange, and green, respectively. To the right of the arrows, you’ll see the tables that are referenced by them.

relationship manager overview

Let’s examine how the relationships of the Orders database are depicted. The top row shows the 'Customers' table. You can read from this row that this table references the CustomerType, District, Gender, and User tables.

relationship manager customer row

You can also clearly see that the tables that MOSTLY AI classified as linked tables reference the subject tables as well as other linked tables: Order` references the Customer and User subject tables, and OrderLineItem references the Order and Product linked tables.

relationship manager customer row

Further down, you’ll see the reference tables. It’s quite common that they don’t reference anything at all, as they`re usually the ones being referenced.

relationship manager customer row

The relationship manager allows you to modify these relationships. Hovering over a row reveals a + button and an edit button, with which you can add referenced tables and edit relationships respectively.

relationship manager customer row

Clicking on the '+' button opens a drawer with which you can add one or more tables that are referenced by the row’s leftmost table. You can use the search bar to specify the tables you want to add.

relationship manager customer row

Once you’ve clicked 'Proceed', another drawer appears with which you can configure the primary key and foreign keys of the row’s leftmost table. You can also directly open this drawer by clicking on the row’s edit button instead of the + button. This drawer contains two sections:

Primary key and referring tables

Here you can view or modify the table’s primary key and learn which tables refer to it.

relationship manager customer row


Foreign keys and referenced tables

Here you can view, modify or delete the table’s foreign keys and the tables they reference. You can also see the relationship type, navigate to the drawer of the referenced table, or remove the relationship altogether. If you’ve added referenced tables using the '+' button, you can find them in the list of foreign keys with an unspecified foreign key. Once you’ve specified them, you can click Save to continue.

relationship manager customer row

You can also add referenced tables directly to this list of foreign keys. Next to the search bar, you’ll find the same green + button that you’ll find when hovering over a row on the main screen. Clicking on it creates an empty row where you can specify a foreign key and the table it references.

relationship manager customer row

Handling databases without schema

The best way to relate the tables of a database without schema is to start with the tables whose relationships are the clearest to you and work down the list one by one:

  1. Enter the name of the table you want to start with in the search field. This will focus your workspace by filtering the rows.

    Upload subject table


  2. Click on the table name to open its relationships drawer.

    Upload subject table


  3. Select the primary key from the respective drop down menu.

    Upload subject table


  4. Next, we will specify all foreign keys:

    1. Click on the the big green button on the right of the bar. This will add an empty row to the list of foreign keys.

      Upload subject table


    2. Choose a foreign key column from the drop down menu and select the table it references.

      Upload subject table


    3. If the selected table doesn’t have a primary key specified, click on the go to button to open its relationship drawer, set the primary key, and return to this drawer.

      Upload subject table


    4. Repeat these steps until you completed all foreign keys of this table.

  5. Once everything’s filled out, click Save and repeat all steps until you’ve completed all relationships.

    Upload subject table


Fixing incomplete schemas

The relationship manager can also help you out if you need to synthesize a database that has an incomplete schema. If you don’t know which tables have no relationships configured, then you can select the Tables without relations option from the filter next to the search bar.

Upload subject table