- Home
- LLBLGen Pro
- Architecture
Entity inheritance
Joined: 01-Feb-2006
This is a new subject to me. I've read your documentation but I wanted to ask a couple of things.
1) The second diagram (Hierarchy creation for proper entity relationship modeling) has Board Member saying its Inheritance Info is Target per entity yet it doesn't appear to be part of the inheritance hierarchy - it just have a 1:1 relationship with CompanyCar. What am I missing?
2) I am keenly aware of your pitfall warning about Person-Employee and Person-Customer mutually exclusive sibling types so I wanted to check how far I can go.
If I have a Person table and Client derives from it (the type that uses separate tables not a discriminator columns - arrgh why did you choose such similar names!), that seems logical because Client is-a Person.
A client might be related to a Solicitor (a Person) say but rather than use inheritance from Person, I have a Role table with Solictor and a PersonRole table mapping. That way I can 'tag' any Person with any number of Roles without further use of inheritance.
Since that solicitor now just has a record in the Person Table (name/address etc.) and is related to other Clients via relationships, I should now be free to make him a Client also. Is this just a case of creating a Client instance with the already existing Person.ID?
3) I also have an Asset table where an Asset can be owned by one or two (typically husband and wife) but potentially multiple people so I can create an AssetOwnership association table which links Person and Asset (and maybe has an extra field for ownership percentage). But say my Person/Client hierarchy also has a twin: A Company/CompanyClient hierachy working in broadly the same way which can also own or partly own an Asset. I could create a CompanyAssetOwnership table twin but there may be a mix of Person and Company owners. If instead I created a new supertype called LegalBody which is an abstract parent of Person and Company then my AssetOwnership table could relate to this instead and allow me to mix and match Persons and Company for ownership. Is this possible and what type of entities would I see in the AssetOwnership.LegalBodies navigator collection?
Joined: 28-Nov-2005
simmotech wrote:
This is a new subject to me. I've read your documentation but I wanted to ask a couple of things.
1) The second diagram (Hierarchy creation for proper entity relationship modeling) has Board Member saying its Inheritance Info is Target per entity yet it doesn't appear to be part of the inheritance hierarchy - it just have a 1:1 relationship with CompanyCar. What am I missing?
That second diagram shows the inheritance of the cars (CompanyCar, FamilyCar, SportCar). BoardMember is just the entity that has a dependency on CompanyCar. It says TargetPerEntity because BoardMember is a subEntity of Manager, which has been cut from that diagram for simplicity (you can see it in the first diagram).
simmotech wrote:
2) I am keenly aware of your pitfall warning about Person-Employee and Person-Customer mutually exclusive sibling types so I wanted to check how far I can go.
If I have a Person table and Client derives from it (the type that uses separate tables not a discriminator columns - arrgh why did you choose such similar names!), that seems logical because Client is-a Person.
A client might be related to a Solicitor (a Person) say but rather than use inheritance from Person, I have a Role table with Solictor and a PersonRole table mapping. That way I can 'tag' any Person with any number of Roles without further use of inheritance.
Since that solicitor now just has a record in the Person Table (name/address etc.) and is related to other Clients via relationships, I should now be free to make him a Client also. Is this just a case of creating a Client instance with the already existing Person.ID?
That is exactly the point that paragraph in the docs is trying to make Your role-based implementation is the way to have has-a relationships instead of is-a ones.
simmotech wrote:
3) I also have an Asset table where an Asset can be owned by one or two (typically husband and wife) but potentially multiple people so I can create an AssetOwnership association table which links Person and Asset (and maybe has an extra field for ownership percentage). But say my Person/Client hierarchy also has a twin: A Company/CompanyClient hierachy working in broadly the same way which can also own or partly own an Asset. I could create a CompanyAssetOwnership table twin but there may be a mix of Person and Company owners. If instead I created a new supertype called LegalBody which is an abstract parent of Person and Company then my AssetOwnership table could relate to this instead and allow me to mix and match Persons and Company for ownership. Is this possible and what type of entities would I see in the AssetOwnership.LegalBodies navigator collection?
Yes it's possible. The type of entities in LegalBodies could be CompanyEntity and/or Personentity, both subtypes of LegalBodyEntity.