Reputation: 2005
I have a three tables:
table
-----------
|id |
-----------
|data_type|
-----------
|data_id |
-----------
table_data_a
----------
|id |
----------
|table_id|
----------
table_data_b
----------
|id |
----------
|table_id|
----------
data_type is a enum('data_a', 'data_b')
;
data_id is a relation to id fields of tables table_data_a or table_data_b
Upvotes: 0
Views: 81
Reputation: 436
In my opinion -
Ans1) There is no need to make relationship between these tables(association or inheritance) as data_id can act as id of both the table(table_data_a and table_data_b).Its better to take it as String or int as per your datatype in db , and make separate call to both tables for search.
Ans2) Mapping through Association refernce
Mapping through inheritance refernce
Upvotes: 1