> For the complete documentation index, see [llms.txt](https://docs.sdv.dev/sdv/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sdv.dev/sdv/modeling/constraint-augmented-generation-cag/predefined-constraints.md).

# 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="/pages/8xSPxlTBpgfaW4BAGKIO">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="/pages/Cl6yztj9rTfBqLLX97Ej">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="/pages/navHDSt2NNL2QmcGqn8Q">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="/pages/k1SXCc357LsDT5bkKzdz">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="/pages/1ZMlkAzTnc0k8umpuBGB">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="/pages/6HLgkdHYwQj4xdc5yBen">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="/pages/EayBLBtu4woaTVQBFI7x">ColumnFormula</a></td><td>One column can be formulaically determined by other columns in the same table.</td><td>In the same table, there is a simple formula that the <code>total_rate</code> column value = <code>room_rate</code> + <code>amenities+fee</code></td></tr><tr><td>❖ <a href="/pages/drRAugLYU7abjXbmdlNA">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="/pages/XekElqxywjy9FWe2rshA">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="/pages/3OGYvO1XbgcBacDISvOI">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="/pages/32hA4ZYrI2qBgjA6AwmD">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="/pages/lMR24XK9fGGw9sf6rb2b">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="/pages/F8soCRQDMQvR0B8GBK94">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="/pages/i61srEg6fRCTzWOk7cLp">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="/pages/HafxR3z7CvH6Q9lx34bk">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="/pages/NtSPDwEWfGMlf0tJzXM7">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="/pages/oTRU0XR4rpDeKZnWYtMO">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](/sdv/explore/sdv-bundles/cag.md) page.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.sdv.dev/sdv/modeling/constraint-augmented-generation-cag/predefined-constraints.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
