#Database design feedback / data integrity

9 messages · Page 1 of 1 (latest)

unborn seal
#

Hi there, I feel like i have way to many foreign keys everywhere, this of course makes querying easier, but I am scared of data integrity issues etc. - especially looking at the appointment table.
I see now i am not allowed to post pictures, so here is the link to the database (click diagram in the top). https://dbdocs.io/18067263/django-help-db

Many thanks!

A free, simple, developer-friendly tool to help you create web-based documentation for your database

#

Database design feedback / data integrity

shy wolf
#

Hi, there are many ways to design a database. (when I think back to my training and the topic of normalisation...🤣 ) The question is always whether it makes technical/professional sense to list certain data in different tables. Like a postcode, for example. And yes, believe it or not, there are companies that even write the postcode in a separate table so that the same postcode does not appear several times in the actual ‘main data’, but only an id/reference to it.

If you ask me... your database design looks solid. The only thing I would still customise would be the ‘roles’, e.g. ‘is_superuser’ etc. These are always included in the standard Django User ORM object. If you are not planning to add further authorisations/roles there, you can leave it as it is. Otherwise, I would create a ‘permissions’ or ‘roles’ table with a name, description, etc. and then assign these roles to the users.

unborn seal
#

I completely forgot to mention, i currently do not have any data integrity checks in my models.

gleaming stump
#

at first glance, that looks a lot like the schema at my last job

#

Practioner has a fk to Company, but also has a fk to User which itself has a fk to Company. This seems like a bad idea.

#

If a single Client could be associated with more than one Company, you'll have to duplicate their name, email, &c

unborn seal
# gleaming stump at first glance, that looks a lot like the schema at my last job

Thank you for the feedback! I think I will take the company field out of practitioner, since like you said i can still get it via the user.

In my current setup I wasn't planning to have a Client associated with more than one company, but maybe it is good to integrate this. I would solve this by adding a CompanyClient many to many.

Again, thanks for the feedback.