To assign a database, I need to model the system for the school. Part of the requirements is to model information for staff, students and parents.
In the UML class diagram, I modeled this because the three classes are subtypes of the human type. This is due to the fact that all of them will require information, among other things, address data.
My question is: how can I simulate this in a database (mysql)?
Thoughts so far look like this:
- Create a monolithic person table that contains all the information for each type and will have many null values depending on what type is stored. (I doubt that this will be in good agreement with the lecturer if I do not argue this case very convincingly).
- A table of people with three foreign keys that refer to subtypes, but two of which will be null - in fact, I'm not even sure if this makes sense or is it possible?
According to this wikipage about django, you can implement the primary key in subtypes as follows:
"id" integer NOT NULL PRIMARY KEY REFERENCES "supertype" ("id")- Something else I didn’t think about ...
So, for those who previously modeled inheritance in the database; how did you do this? Which method do you recommend and why?
Links to articles / blog posts or previous questions are more than welcome.
Thank you for your time!
UPDATE
Well thanks for all the answers. I already had a separate address table, so that is not a problem.
Greetings
Adam