❖ CompositeKeys
Last updated
Last updated
Use the CompositeKeys constraint when multiple columns together form a primary key. Optionally, you may also have multi-column foreign key that connects to the primary key.
Create a CompositeKeys
constraint that lists all the composite keys of your database (primary and foreign keys).
Parameters:
(required) primary_keys
: A list of dictionaries that define the composite primary keys of all tables that have composite primary keys. Each dictionary should have the following keys:
'table_name'
: A string with the name of the table
'primary_key'
: A list of strings representing all the columns in the table that form the composite, primary key. At least 1 of these columns should be an sdtype id or PII column.
relationships
: A list of dictionaries that define the relationships from composite foreign keys to the composite primary keys defined above. Each dictionary should have the following keys:
'parent_table_name'
: A string with the name of the parent table with the composite primary key (this should be listed in the primary_keys
section above).
'parent_primary_key'
: A list of columns that comprise the composite primary key of the table (this should be the same as the primary_keys
section above)
'child_table_name'
: A string with the name of the child table that refers to the parent
'child_foreign_key'
: A list of columns that comprise the composite foreign key that refers to the parent. The length of this list should be the same as the primary key that it refers to.
Make sure that all the table and columns in you provide are in your Metadata. If you provide any foreign key connections, make sure they align with the columns in the primary key.
Apply the constraint to any SDV synthesizer. Then fit and sample as usual.
For more information about using predefined constraints, please see the Constraint-Augmented Generation tutorial.
This functionality is in Beta. At this time, select SDV Enterprise users are able to use this feature and provide feedback.