1

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?

1

1 Answer 1

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.