Just wondering if there is any problem in this design or has it ever broke any rules in database normalization.
The major table has a column that mapped to two(or even more) different tables, so data in reference
column may mix with primary key from multiple tables.
is it a better design to create different association tables (major -> A and major -> B)?
Table Major
item id | reference
-----------------------
id 1 | a1 pk from tb A
id 2 | b1 pk from tb B
id 3 | a2 pk from tb A
id 4 | b2 pk from tb B
id 5 | a3 pk from tb A
id 6 | a4 pk from tb A
id 7 | b3 pk from tb B
id 8 | b4 pk from tb B
......
Table A
sub item id |
-----------------------
id a1 | .....
id a2 | .....
id a3 | .....
id a4 | .....
......
Table B
sub item id |
-----------------------
id b1 | .....
id b2 | .....
id b3 | .....
id b4 | .....
......
As long as you keep the number of tables you are referencing to a minimum it isn't too bad of an idea, in the Table Major you would want to add an extra field that would identify which table it belonged to.
It depends on how central this Table Major would be to your project. If its at the center of your universe, I would say maybe (leaning more towards no), if not then you would probably be fine.
ORMs do what you are suggesting, but I would look at other options before implementing it.