inheritance - modeling a very simple isA relationship : 2 tables with even/odd ids or 3 tables? -


we have 2 types of hospital staff in our project

  • doctor
  • nurse

and never gonna change (i.e. no other staff type). there quite overlap between 2 entity types (e.g. login information same) there large difference . far can have:

  • one doctors table ids (2,4,6 etc) , nurses table odd ids (1,3,5 etc)
  • 3 tables, 1 capture common parent entity (staffs) , 1 table each child entity (doctors , nurses)

i can't convince 1 of colleagues first design better in our project because of simplicity (specially fewer joins common operations) , better performance. why first design better ?

there 3 possible ways solve this:

put in 1 table. far easiest work (select * personel type = 'doctor'). big downside columns belong type unused opposite type (and visa versa).

put in 2 specific tables. both doctor , nurse have columns need themself. in way quite viable aswell can decide 1 select from. however, using odd , id's makes no sense (where thinking: select * tab_doctor, tab_nurse id = uneven?). if use id's , adds id uneven table problem, prevent have write trigger check on id (makes worse performance).

the last possibility using 3 tables child entity's said. 1 use lot of communication between tables. , it's simplicity have stated not on level of other 2 options.

each implementation has upsides , downsides depending on quite few factors (not ones mentioned, think of size of tables, etc.).


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -