Best practice for ORM design (re: cascading delete from single entity)

If I have a very common shared table (ie. names) with a primary key (ie. name_id) included in many other tables as foreign keys, do I need my common table (names) to have a mapping reference to every other foreign key table for cascade deletes to work? For example: Name myName = session.Get(12345); session.Delete(myName); However, name_id is referenced in many other tables. If I want cascade delete, then my Name class needs to have references to every other table and every other table has a reference back to Name. Is this correct or are there any other approaches? It seems like a violation of separation of duties (?) for my Name class to be aware of other classes that refer to it.

Jun 3, 2025 - 10:10
 0

If I have a very common shared table (ie. names) with a primary key (ie. name_id) included in many other tables as foreign keys, do I need my common table (names) to have a mapping reference to every other foreign key table for cascade deletes to work?

For example:

Name myName = session.Get(12345);
session.Delete(myName);

However, name_id is referenced in many other tables. If I want cascade delete, then my Name class needs to have references to every other table and every other table has a reference back to Name.

Is this correct or are there any other approaches?

It seems like a violation of separation of duties (?) for my Name class to be aware of other classes that refer to it.