I have a database structure in which i have 4 tables lets assume to be
Table1, Table2, Table3 and Table4
the relation between table1,2,3 is as follows:
(Table1).hasMany(Table2)
(Table2).hasMany(Table3)
now there is another table Table4 which has a key references which is a foreignkey for either table1,table2,table3 ie the table would look like something like this
Table4
+-----------------------------------+------------+--------+
| references | Col2 | Col3 |
+-----------------------------------+------------+--------+
| foreign key Table1 | value1 | random |
| foreign key Table1 | value2 | random |
| foreign key Table2 | value2 | random |
| foreign key Table3 | value3 | random |
+-----------------------------------+------------+--------+
how do I define the relationship between the tables. In the doc there is no such usecase mentioned. Is there a particular way to go about it? Or show I store the data without defining the foreign key relationship?