suppose i am modeling a database and i have an entity Equipement, it can be a Workstation or a Peripheral, when translating to SQL, what is the best way ? Equipement table with the common attributes and the two others ? or just the two child tables?
Share
You can use either a universal table, vertical partitioning or horizontal partitioning. A universal table has ALL attributes and an additional type attribute. This attribute represents which type your entity has. Attributes which you do not have for a special type are NULL. In your example you could have a table:
With following Rows:
If you use vertical partitioning you map all your classes to tables and reference them with you base entity:
If you use horizontal partioning you reference again to your base entity but you take all
attributes from each base entity as well:
I personally use universal tables for entities which does not have many different attributes. If it comes that you have too many different attributes I would avoid this type, because you will have a lot of NULL fields.
Hope that could help you!