There are several independent tables, table1
, table2
, table3
etc., each of which has a primary key. In addition, there is also a kinda shared table shared_table
with 3 columns - text_value
, fake_foreign_key
and table_name
, it is a called shared_table
in that each of the independent tables (table1
, table2
, table3
) needs to join to the shared_table
by using the column fake_foreign_key
and the table_name
to get some data from the same column named text_value
.
Based on the design above, it is way difficult to join an independent table with the shared_table
directly with SQL, but of course with the help of some programming language it is possible.
In relational database design, based on the ER modeling, there should be relationship between two relational tables. So I am surprised about the design above, as there is actually no direct primary key and foreign key relationship between the shared_table
and other tables. Moreover, the mapping of the table has to be computed programmatically, and thus it will be difficult to use the ORM (object-relational mapping) framework.
The mere benefit for this design is the amount of tables is much smaller than in the case if we create separate text value tables for each of the reference table, i.e. table1
, table2
, table3
, as all the text values are in the same table shared_table
Question: is this design an anti-pattern? shall we really need such design?