Metadata.
add_relationship
Add a new relationship between the parent and child tables.
The relationship is created by adding a reference (ref) on the foreign_key field of the child table pointing at the parent primary key.
ref
foreign_key
child
parent
parent (str) – Name of the parent table.
child (str) – Name of the child table.
foreign_key (str) – Field in the child table through which the relationship is created. If None, use the parent primary key name.
None
validate (bool) – Whether to validate metadata after adding this relationship or not. Defaults to True.
True
ValueError – If any of the following happens: * The parent table does not exist. * The child table does not exist. * The parent table does not have a primary key. * The foreign_key field already exists in the child table. * The child table already has a parent. * The new relationship closes a relationship circle.