I have an architecture problem about how to store data related to a specific role in a relational database.
I have three roles, a Subscriber Contact
, Teacher
, and Student
. They are all stored in the Users
table, but have specific properties related to each. A student has a SchoolId
, Grade
, a subscriber contact has a DistrictId
, a teacher has ProgramId
, SchoolId
, Grade
.
Should I have three separate tables for subscriber contact, teacher, and student, or should I do some kind of key/value lookup? If key/value lookup how can I do this and how can I do it for a foreign key, like DistrictId
and SchoolId
?
You can simulate something like an inheritance. A superclass table consisting of all common attributes for roles subscriber
, teacher
and student
. Then three subclass tables for each of the roles consisting of the arrtibutes unique to each. There will be a one-to-one relationship between the superclass entity and each of the subclass entities.