LukasZahradnik / deep-db-learning

A modular message-passing scheme reflecting the relational model for end-to-end deep learning from databases
https://lukaszahradnik.github.io/deep-db-learning/
6 stars 2 forks source link

Foreign keys should be mapped using columns<->ref_columns instead of columns<->primary_key #22

Open neumannjan opened 1 year ago

neumannjan commented 1 year ago

https://github.com/LukasZahradnik/deep-db-learning/blob/393c6e2e6abeadf76550732fc3973be21706f9fc/db_transformer/data/dataset.py#L270-L279

As the title of this issue suggests, the proper way to map foreign keys should not be based on the primary key, since most SQL databases allow more general foreign key constraints that do not require the referenced set of columns to be the primary key.

Foreign key constraints in the DB (and consequently also those in our schema) ensure that len(columns) == len(ref_columns).

This should also eliminate the limitation of our code that requires a foreign key constraint to consist only of a single column.