❖ Polymorphic Relationship

Transaction Log table has a foreign key called Details. Sometimes, it refers to the Debit Accounts table and sometimes it refers to the Credit Accounts tables.Constraint API
Usage
Last updated

Transaction Log table has a foreign key called Details. Sometimes, it refers to the Debit Accounts table and sometimes it refers to the Credit Accounts tables.Last updated
from sdv.cag import PolymorphicRelationship
my_constraint = PolymorphicRelationship(
table_name='Transaction Log',
foreign_key_column_name='Details',
parent_table_names=['Debit Accounts', 'Credit Accounts'],
type_column_name='Type',
type_value_to_table={
'CREDIT': 'Credit Accounts',
'DEBIT': 'Debit Accounts'
}
)synthesizer = HSASynthesizer(metadata)
synthesizer.add_constraints([my_constraint])
synthesizer.fit(data)
synthetic_data = synthesizer.sample()