Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
neumannjan opened this issue Jul 22, 2023 · 0 comments

Comments

@neumannjan
Copy link
Collaborator

neumannjan commented Jul 22, 2023

table_primary_keys = primary_keys[col.ref_table]
for i_index, row in enumerate(table_data):
if row[index] is None or row[index] not in table_primary_keys:
continue
edge_index.append([i_index, table_primary_keys[row[index]]])
hetero_data[table_name, col.columns[0], col.ref_table].edge_index = (
torch.tensor(edge_index, dtype=torch.long).t().contiguous()
)

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant