mercredi 20 juin 2018

Is it normal to share one table's data with many other tables without directly using foreign key

enter image description here

In relational database design, based on the ER modeling, there should be relationship between two relational tables. However, currently I have met a special design case shown in the picture above:

There is a shared table called shared_table(on the bottom of the picture), where the values in column text_value can be used by many other tables such as those presented on the upper side of the picture, say table1, table2, table3. The relationship is on base of the field table_name, on base of the value from which the text_value can be mapped to the tables on the upper side of the picture.

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 object-relational mapping framework.

Question: is this design an anti-pattern? shall we really need such design?

Aucun commentaire:

Enregistrer un commentaire