0

I have a facultyand studenttable to store each information, respectively. I made a contacttable to store the contacts of either faculty or student. I would like to use the contact table as a generic one, means it can be used by either faculty or student.

My table diagram is something like this.

I compressed faculty and student into a USER table and have an account type in that table to know whether it is a faculty or student type of user. Then the USER table will have a one is to many relationship with the contact table.

Student

Faculty

Contacts

Student & Faculty = User table
User table -----<- Contact table

2
  • In practice what you're proposing is good. A good practice is to also have an AccountType table that will contain the friendly description of the account type and an integer. Then use that integer in the User table in the account type field. Any indexing on that field, in the user table, will be more efficient. You only need to join to the AccountType table when you care to display the friendly name. Also modifications to AccountType values will be much more efficient.
    – SDillon
    Commented Apr 28, 2015 at 12:56
  • Is there an another way around? Commented Apr 28, 2015 at 13:09

1 Answer 1

1

True story: I was a student at my school, then I taught there. Then one of the teachers took my class. You need to account for silliness like this.

And a faculty member or student isn't necessarily a user either.

Use table inheritance.

Faculty : Individual : Party

Student : Individual : Party

Where : means inherits.

Party hasOne User

A contact is a relationship between two parties:

Party hasMany ContactRelationships belongsTo Party

See Ready-to-Use Database models example for reference models.

1
  • This is my first time to hear that. Thank you for that, sir! :) Commented Apr 28, 2015 at 17:59

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.