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 key constraints in the backend datastores #390

Open
wood-push-melon opened this issue Jan 19, 2024 · 0 comments
Open

Foreign key constraints in the backend datastores #390

wood-push-melon opened this issue Jan 19, 2024 · 0 comments

Comments

@wood-push-melon
Copy link

Currently, there are no foreign key constraints added in the backend datastores' schemas. Probably we can consider adding some foreign keys in the users and includegroups tables. Take an example in the PostgreSQL backend:

ALTER TABLE users
    ADD CONSTRAINT fk_groups_users FOREIGN KEY (primarygroup) REFERENCES groups (gidnumber) ON UPDATE CASCADE;
ALTER TABLE includegroups
    ADD CONSTRAINT fk_parent_group FOREIGN KEY (parentgroupid) REFERENCES groups (gidnumber) ON UPDATE CASCADE;
ALTER TABLE includegroups
    ADD CONSTRAINT fk_child_group FOREIGN KEY (includegroupid) REFERENCES groups (gidnumber) ON UPDATE CASCADE;

This allows us to update necessary fields in users and includegroups tables whenever there is a change in group's gidNumber to not violate the data integrity.

And also we can evaluate if we need to add similar things for group deletion operations.

There might be additional actions required for some other databases: it seems users need to enable foreign key support in SQLite: https://www.sqlite.org/foreignkeys.html#fk_enable

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