Skip to main content

Linking Tables

When you first create an app, you’ll notice that table1 has been created for you by default. This will be your main table and your starting point to start linking additional tables.

1. Create a function function1 to fetch data


select workspace_id, workspace_name, workspace_type from workspaces

Note: you can do this with Python functions too, not just SQL

2. Bind function1 to your main table table1

3. Add a new table table2

Add a table

4. Create function2

This function will link table2 to table1. Sample function:


select user_id, user_email, user_name, user_location, workspace_id from users
where workspace_id = {{ state.tables.table1.workspace_id }}

Note: Table dependency is automatically inferred for SQL functions. For Python functions, you need to specify table dependencies manually.

5. Select table2

Select table2

6. Bind function2 to table2

Bind function2

7. Click on Save

Save function2

8. Tables are linked

Linked tables automatically refetch data based on row selection from the table they are linkedin to. In this case, table2 will refetch its underlying function whenever a row in table1 in selected. table2 is considered a table "linked" to table1.

Note: Table dependency is automatically inferred for SQL functions. For Python functions, you need to specify table dependencies manually. You can do so via the dropdown in the Python function where you can set function2 to watch for changes in table1 to trigger a refetch.