0

Which of the following database patterns would be a better model

For example:

Teacher(id, name, surname, login,password, subject, degree....)

Student(id, name, surname, login, password, group, faculty....)

VS

User(id, login, password, name, surname)

Student(id, group, faculty...)

Teacher(id, object, degree...)

And join it by inner join?

Which way would be preferred?

AspiringMat
  • 2,161
  • 2
  • 21
  • 33
  • Since some students may also teach, I'd go with alternative 2. – jarlh Sep 30 '19 at 07:19
  • This is a faq. Before considering posting please always google your error message or many clear, concise & precise phrasings of your question/problem/goal, with & without your particular strings/names & site:stackoverflow.com & tags, & read many answers. If you post a question, use one phrasing as title. See [ask] & the voting arrow mouseover texts. We cannot reason, communicate or search unless we make the effort to (re-re-re-)write clearly – philipxy Sep 30 '19 at 09:25
  • There's no such thing as "better"/"best" in engineering unless you define it. Also unfortunately all reasonable practical definitions require a ridiculous amount of experience with a ridiculous number of factors that interact with chaotic sensitivity to details. Make straightforward designs. When you demonstrate via measurement that a design and all alternatives you can think of have problems (whatever that means at the time), then ask a very specific question. Which should also define "better"/"best". [Strategy for “Which is better” questions](https://meta.stackexchange.com/q/204461/266284) – philipxy Sep 30 '19 at 09:25

1 Answers1

0

It totally depends. In the first model, students and teachers are separate entities, entirely. So, relationships are to one of them but not to the other.

In the second model, students and teachers are subsets of users (presumably, the ids are the same in the three tables). This allows you to have other tables that reference users -- say an address table or a transaction table.

It is not clear if your data model needs relationships to users. So, there is no way to say that one is "better" than the other.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786