# Predefined Constraints

Predefined constraint classes are available for frequently occurring business rules. The business rules can be isolated to a single table or can be applied across multiple tables.

For more information about using predefined constraints, please see the [**Constraint-Augmented Generation tutorial**](https://colab.research.google.com/drive/1WCMQujfVKL5giULZXOPPIBoMfzR9Zj68?usp=sharing).

## Single Table

These constraints can be applied within an individual table of your dataset

<table><thead><tr><th width="213.66666666666666">Constraint</th><th>Description</th><th>Example</th></tr></thead><tbody><tr><td><a href="predefined-constraints/fixedcombinations">FixedCombinations</a></td><td>No shuffling is allowed other than what's already observed in the data</td><td>The <code>city</code> and <code>country</code> values cannot be shuffled to create new permutations.</td></tr><tr><td><a href="predefined-constraints/fixedincrements">FixedIncrements</a></td><td>All the numerical values are increments of a whole number</td><td>All values in <code>salary</code> must be divisible by 1000</td></tr><tr><td><a href="predefined-constraints/inequality">Inequality</a></td><td>The value in one column must always be greater than the other</td><td>The <code>checkout_date</code> must always be after the <code>checkin_date</code></td></tr><tr><td><a href="predefined-constraints/onehotencoding">OneHotEncoding</a></td><td>The original data columns represent a one hot encoding scheme</td><td>Exactly 1 of the following columns has a <code>1</code> in each row: <code>not_subscribed</code>, <code>basic_subscriber</code>, <code>premium</code></td></tr><tr><td><a href="predefined-constraints/range">Range</a></td><td>The value in one column is bounded by the values in other columns</td><td>The <code>parent_age</code> must be in between <code>child_age</code> and <code>grandparent_age</code></td></tr><tr><td>❖ <a href="predefined-constraints/chainedinequality">ChainedInequality</a></td><td>A chain of 2 or more columns in an inequality</td><td><code>purchase_date</code> &#x3C; <code>start_date</code> &#x3C; <code>end_date</code> &#x3C; <code>expiration_date</code> &#x3C; <code>termination_date</code></td></tr><tr><td>❖ <a href="predefined-constraints/fixednullcombinations">FixedNullCombinations</a></td><td>No shuffling is around for the missing values, other than what's already observed in the data</td><td>The <code>city</code> and <code>country</code> columns must both either be null together or not at all.</td></tr><tr><td>❖ <a href="predefined-constraints/mixedscales">MixedScales</a></td><td>The value of one categorical column determines the scale of another numerical column.</td><td>If the value of <code>test_type</code> is <code>'blood_pressure'</code> then the value of <code>test_result</code> must be within a reasonable for this test only.</td></tr><tr><td>❖ <a href="predefined-constraints/selfreferentialhierarchy">SelfReferentialHierarchy</a></td><td>A column in the table refers to a different column in the same table.</td><td>The <code>Manager ID</code> column refers to the <code>Employee ID</code> column in the same table.</td></tr></tbody></table>

## Multi Table

These constraints can be applied between multiple different tables of your dataset.

<table><thead><tr><th width="215.859375">Constraint</th><th width="268.72265625">Description</th><th>Example</th></tr></thead><tbody><tr><td>❖ <a href="predefined-constraints/carryovercolumns">CarryOverColumns</a></td><td>The same columns are present in a parent table and a child table, and the values of those columns have to match up according to the connection.</td><td>The account <code>Type</code> in one table must match the corresponding account <code>Type</code> in another table.</td></tr><tr><td>❖ <a href="predefined-constraints/denormalizedtable">DenormalizedTable</a></td><td>A table that was created by denormalizing a parent and child table.</td><td>The <code>Transactions-Users</code> table was created by denormalizing the <code>Transactions</code> and <code>Users</code> table. (The user info is repeated for each transaction they've made.)</td></tr><tr><td>❖ <a href="predefined-constraints/foreigntoforeignkey">ForeignToForeignKey</a></td><td>There are foreign keys in multiple tables but no primary key to attach them to.</td><td>The <code>Warehouse ID</code> column in multiple tables is referring to the same concept.</td></tr><tr><td>❖ <a href="predefined-constraints/foreigntoprimarykeysubset">ForeignToPrimaryKeySubset</a></td><td>There is a 1-to-many connection between tables, but only certain values are allowed to have connections.</td><td>Only accounts with <code>Type=Premium</code> are allowed to have children in another table.</td></tr><tr><td>❖ <a href="predefined-constraints/polymorphic-relationship">PolymorphicRelationship</a></td><td>The values inside a foreign key column can refer to different tables, depending on the context.</td><td>A transaction log's <code>Details</code> might sometimes reference a row in the <code>Credit Accounts</code> table and other times in the <code>Debit Accounts</code> table.</td></tr><tr><td>❖ <a href="predefined-constraints/primarytoprimarykeysubset">PrimaryToPrimaryKeySubset</a></td><td>There is a 1-to-1 connection between the primary keys of two or more tables but only certain values are allowed to have connections.</td><td>Only users with <code>Is Minor=True</code> are allowed to have an entry in another table.</td></tr><tr><td>❖ <a href="predefined-constraints/referencetable">ReferenceTable</a></td><td>A table acts as an unchangeable reference. You do not want to synthesize an new information in it.</td><td>The <code>City</code> table should act as a reference; you do not want to synthesize new cities.</td></tr></tbody></table>

{% hint style="info" %}
❖ **SDV Enterprise Bundle**. This feature is available as part of the **CAG Bundle**, an optional add-on to SDV Enterprise. For more information, please visit the [CAG Bundle](https://docs.sdv.dev/sdv/explore/sdv-bundles/cag) page.
{% endhint %}

{% hint style="warning" %}
**Can't find a constraint?** We've deprecated some constraints where the equivalent functionality could be achieved using other SDV features. We recommend using existing SDV features to handle the logic instead of adding a constraint. For more information, see [Deprecated Constraints](https://docs.sdv.dev/sdv/concepts/constraint-augmented-generation-cag/predefined-constraints/deprecated-constraints).&#x20;
{% endhint %}
