3 ms·
I think single table with a column for the entity type/kind is TheWay™, adding indexes to columns that are commonly used for look-ups. This is an enterprise ap
by mattbrewsbytes 4y ago
I think single table with a column for the entity type/kind is TheWay™, adding indexes to columns that are commonly used for look-ups.
This is an enterprise application pattern called Single Table Inheritance: https://en.wikipedia.org/wiki/Single_Table_Inheritance https://en.wikipedia.org/wiki/Single_Table_Inheritance or from the source: https://www.martinfowler.com/eaaCatalog/singleTableInheritance.html https://www.martinfowler.com/eaaCatalog/singleTableInheritan...
There are trade-offs with all design decisions. In this case having columns that are un-used for some Models is a trade-off (and might be annoying when looking at a db table).
If AccessControl implies a permissions type of system, depending on how many permissions there are, they could all be boolean columns in this table. Or if there are sets of permissions and users could have combinations of them (aka 1:many), you could have a Users table, AccessControl table (maybe call it Roles?) with roles/permissions, then a UserRoles table that joins a User to many AccessControl/Roles.