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

Add foreign keys to SQLite dataset #9

Closed
dracos opened this issue Sep 5, 2024 · 1 comment
Closed

Add foreign keys to SQLite dataset #9

dracos opened this issue Sep 5, 2024 · 1 comment

Comments

@dracos
Copy link

dracos commented Sep 5, 2024

I'm not sure how the data/ifg-ministers-database.sqlite file is being generated, but it’d be great if it could include foreign keys linking the tables. Using sqlite-utils, I added them using the below (probably missed one), but perhaps this can be done as part of your flow that is creating the file:

sqlite-utils add-foreign-key ifg-ministers-database.sqlite appointment person_id person id
sqlite-utils add-foreign-key ifg-ministers-database.sqlite appointment post_id post id
sqlite-utils add-foreign-key ifg-ministers-database.sqlite appointment_characteristics appointment_id appointment id
sqlite-utils add-foreign-key ifg-ministers-database.sqlite organisation_link predecessor_organisation_id organisation id
sqlite-utils add-foreign-key ifg-ministers-database.sqlite organisation_link successor_organisation_id organisation id
sqlite-utils add-foreign-key ifg-ministers-database.sqlite post organisation_id organisation id
sqlite-utils add-foreign-key ifg-ministers-database.sqlite post_relationship post_id post id
sqlite-utils add-foreign-key ifg-ministers-database.sqlite representation person_id person id
sqlite-utils add-foreign-key ifg-ministers-database.sqlite representation constituency_id constituency id
sqlite-utils add-foreign-key ifg-ministers-database.sqlite representation_characteristics representation_id representation id

This will then eg prevent any data with non matching keys from making its way into the database.

@philipnye
Copy link
Member

@dracos Much appreciated. Now added (f8793c9) - and I've added this step in to the workflow used to generate the SQLite file

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

2 participants