Appearance
Relationships
Relationships connect rows in one table to rows in another. SchemaStack discovers relationships from your database schema and lets you add them as columns to your views.
Discovering Relationships
To add a relationship column:
- Open the Properties Panel (right sidebar)
- Click Add Relationship Column
- Browse the discovery tree — it shows all tables related to your current workspace, organized by foreign key paths
- Select the relationship you want to add
- Configure the edit mode and display settings (see below)
- The relationship column appears in your view
The discovery tree follows foreign keys in your database, so only valid relationships are shown.
Relationship Edit Modes
Each relationship column uses one of three edit modes that control how related records are created and managed:
| Mode | Behavior | Use Case |
|---|---|---|
| Reference | Link to an existing row in the related table | Order → Customer (customer already exists) |
| Owned | Create and manage the related row inline | Order → Shipping Address (belongs to order) |
| Association | Many-to-many link through a join table | Student ↔ Course (enrolled in multiple) |
INFO
OneToMany columns are always read-only from the parent view — they display aggregated data from child records. Edit child records in their own view.
Reference Mode
Reference mode links to existing rows. When editing a reference cell, you get a searchable dropdown of rows from the related table.
- The related row must already exist — you cannot create new rows from the reference field
- Clearing the reference removes the link but does not delete the related row
Owned Mode
Owned mode lets you create and edit the related row directly within the parent row's form. The related row's lifecycle is tied to the parent.
- Adding a parent row can simultaneously create the owned row
- Deleting the parent row may cascade to the owned row (depending on your database constraints)
- Edit the owned row's fields inline without leaving the parent form
Association Mode
Association mode handles many-to-many relationships through an intermediate join table.
- Select multiple related rows from a searchable list
- Add or remove associations without affecting the related rows themselves
- The join table is managed automatically
Many-to-Many Relationships
Many-to-many (M2M) relationships link records across two tables where each record on either side can relate to multiple records on the other side. Common examples: Users ↔ Roles, Posts ↔ Tags, Students ↔ Courses.
Creating a M2M Relationship
- Open the Properties Panel → Add Relationship Column
- Under Other Entities, expand the target entity (e.g., "Role")
- Select any column (e.g., the primary key)
- Check Multiple links (many-to-many)
- Set the Display Field (e.g., "name") — this controls what appears in the chips
- Click Add Column
SchemaStack creates a join table automatically (e.g., users_roles) with two foreign key columns and a composite primary key. No manual table creation needed.
How M2M Columns Display
M2M columns display as colored chips in the spreadsheet grid — each chip represents one linked record. For example, a user's "Roles" column might show: Admin Editor.
Editing M2M Associations
Click on a M2M cell to open the multi-select editor:
- Search — filter target records by the display field
- Checkboxes — toggle associations on/off instantly (each toggle saves immediately)
- Chips — selected items appear as removable chips at the top
- Pagination — "Load more" for large datasets
Changes are saved instantly per toggle — there is no "Apply" button.
Power User: Intermediate Entities
For M2M relationships that need extra columns (e.g., assigned_at, permissions on a User→Role link), create a junction entity explicitly:
- Create a new entity (e.g., "UserRole") with two foreign key columns (
user_id,role_id) plus your extra columns - Each FK is a regular ManyToOne relationship
- Use Reference mode for editing each side
This approach gives you full control over the junction entity while still allowing CRUD on the intermediate data.
OneToMany Relationships
OneToMany relationships show data from child records that reference the current row. For example, a Customer view can show all Orders for each customer.
How OneToMany Columns Display
OneToMany columns support two display modes:
- Count (default) — shows the number of related records (e.g.,
5) - Values — shows related records as colored chips (e.g.,
ORD-001ORD-002)
Adding a OneToMany Column
- Open the Properties Panel → Add Relationship Column
- In Existing Relationships, find the OneToMany relationship (labeled with
1:N) - Select a display column from the target entity
- The column appears showing aggregated values or count
Changing Display Mode
After adding a OneToMany column:
- Click the column header to open column properties
- Find the Display Mode dropdown
- Switch between Count and Values (chips)
Rollup Functions
For OneToMany columns in Count mode, you can change the aggregate function:
- Count — number of related records
- Sum — sum of a numeric field across related records
- Average — average of a numeric field
- Minimum — smallest value
- Maximum — largest value
Set the aggregate function in the column properties panel.
OneToMany columns are read-only from the parent view. Edit child records in their own view.
Relationship Discovery
The relationship picker helps you find and add relationship columns. It has two sections:
Existing Relationships
Shows relationships already defined in your database schema (foreign keys). Each relationship is labeled with its cardinality:
- No label — Many-to-One (most common)
1:1— One-to-One1:N— One-to-Many
Other Entities
Shows all other tables in your workspace. You can:
- Direct link — click a column to create a new foreign key relationship
- Through junction — expand a junction table's relationships to create a Many-to-Many link via an existing join table
Junction tables (tables whose primary key columns are all foreign keys) are detected automatically and labeled with M2M.
Search Filter
Use the search box at the top to filter entities by name — useful in workspaces with many tables.
Configuring Relationship Columns
After adding a relationship column, configure how it displays and behaves:
- Display Field — Which field from the related table is shown in the cell (e.g., a customer's name instead of their ID)
- Search Fields — Which fields are searched when filtering the dropdown (e.g., search by name and email)
- Inline Edit Fields — In owned mode, which fields of the related row are editable inline
These settings are configured per-column in the Properties Panel.
Referential Actions (Cascade Rules)
Referential actions control what happens to rows in the current table when the referenced (parent) row is deleted or updated. Configure these in the Properties Panel under Referential Actions for any foreign key column.
| Action | On Delete | On Update |
|---|---|---|
| No Action | Block delete if child rows exist (default) | Block update if child rows reference the old key |
| Cascade | Delete all child rows when the parent is deleted | Update the FK in all child rows to the new key |
| Set Null | Set the FK column to NULL in child rows | Set the FK column to NULL in child rows |
| Restrict | Same as No Action (fails immediately) | Same as No Action (fails immediately) |
| Set Default | Set the FK column to its default value | Set the FK column to its default value |
WARNING
Changing a referential action requires a database migration — the foreign key constraint is dropped and re-created. This is safe but may briefly lock the table on large datasets.
TIP
Set Null requires the FK column to be nullable. SchemaStack will warn you if the column is NOT NULL.
Further Reading
- Expanding Relationships (API) — How to query relationship data via the REST API