Referential Integrity
Checks that the values of a field in one table exist in a field of another table.
The Referential Integrity monitor checks that the values of a field in one table exist in another table, which can come from a different data source.
When to Use
- Foreign keys: Every value of a foreign key must exist in the reference table.
- Mandatory relationships: Every row of a parent table must have at least one matching row in a child table. Select the child table as the left table and use the right join check.
- One-to-one relationships: Every parent row has a child row, and every child row belongs to an existing parent row (outer join check).
When the accepted values are a short, fixed list rather than another table, use Value List Validation.
How It Works
Sifflet joins the two tables on the selected fields and counts the rows without a match, depending on the comparison mode:
| Comparison mode | Counts | Example |
|---|---|---|
| Left join check (default) | Rows of the left table whose value does not exist in the right table | Every foreign key value exists in the reference table. |
| Right join check | Rows of the right table whose value does not exist in the left table | Every parent row has a child row (with the child table as the left table). |
| Outer join check | Rows of either table whose value does not exist in the other table | Parent and child rows match each other. |
The default static threshold fails when the count is greater than 0, that is, as soon as one row has no match.

Example
You want every order to belong to an existing customer. Create a Referential Integrity monitor with the following settings:
- Datasets:
orders(left table), thencustomers(right table). - Left join key column and Right join key column:
customer_idin both tables. - Comparison mode: Left join check (default).
- Monitoring mode: Incremental scan, with
created_atofordersas the time window column and a daily time-based data aggregation.
On June 7, the nightly synchronization of customers fails, so the customers who signed up that day are missing from customers. Their 340 orders of June 7 have no matching customer. The data point of June 7 is 340, greater than 0, so the monitor fails.
Configure the Monitor
Referential Integrity Settings
| Setting | Description | Default |
|---|---|---|
| Datasets | The left table first, then the right table. Select the table that receives new rows first, and the reference table second. | None |
| Left join key column and Right join key column | The field of each table to compare. | None |
| Comparison mode | Left join check, Right join check, or Outer join check (see How It Works). | Left join check |
Common Settings
- Threshold: Static (default), relative, or dynamic, on the count of unmatched rows (there is no percentage value mode). See Thresholds.
- Scan mode: Incremental or full dataset. Time settings only apply to the left table, and are only available with the Left join check comparison mode. In incremental scan mode, the monitor only checks the new rows of the left table against the whole right table, which reduces the cost of each run. Without time settings, the monitor scans both tables entirely at each run. See Scan Modes.
- Where clause: Each table has its own where clause.
- Group by: Only available on the left table, with the Left join check comparison mode.
- Joins: Not available: the monitor already compares the two tables.
Monitor as Code
The monitor kind is ReferentialIntegrity. The first dataset is the left table, and the second dataset is the right table. The following YAML creates the monitor of the example on Snowflake:
datasets:
- uri: snowflake://<account>/<DATABASE>.SALES.ORDERS
- uri: snowflake://<account>/<DATABASE>.SALES.CUSTOMERS
parameters:
kind: ReferentialIntegrity
left:
field: customer_id
timeWindow:
field: created_at
firstRun: P365D
frequency: P1D
right:
field: customer_id| Parameter | Required | Description |
|---|---|---|
matchType | No | LeftOnRight (default, Left join check), RightOnLeft (Right join check), or Full (Outer join check). |
left.field | Yes | The field of the left table. |
left.whereStatement | No | SQL condition (without WHERE) to filter the left table, for example my_field <> 'cancelled'. |
left.timeWindow | No | Time settings for incremental checks on the left table. Only with matchType: LeftOnRight. |
left.groupBy | No | Group by on the left table. Only with matchType: LeftOnRight. |
left.partition | No | Partition settings of the left table. |
right.field | Yes | The field of the right table. |
right.whereStatement | No | SQL condition (without WHERE) to filter the right table. |
Related Templates
- Value List Validation: Checks values against a fixed list instead of another table.
Updated about 15 hours ago

