❖ Polymorphic Relationship
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()constraints = synthesizer.detect_constraints(
data,
constraint_classes=['PolymorphicRelationship']
)