Single table inheritance is an inheritance hierarchy of classes as a single table that has columns for all the fields.
RelationshipRelational databases don’t support inheritance.
STI tables require a class_name
field and a class_id
field.
Advantages
- Single table simplicity.
- No
joins
. - Any refactoring that pushes fields up or down the hierarchy doesn’t change the database.
Issues:
- Contains irrelevant fields for specific classes.
- Creates wasted space.
- STI table may become too large with multiple index and frequently locking; which impacts performance.
- You have a single namespace for fields so the same name coant can’t be used for difference datatype in ifferent classes.