Reputation: 527
That's my first post here. Thanks in advance everyone that collaborates with me.
I'm working on a new MER, this is a piece of the it: https://i.sstatic.net/jt5Mz.png.
In the linked MER, i'm using Table per Hierarchy on entities: Person, Company and Individual. Driver entity is on based on Table per Type.
My big problem is that a Driver can be Individual or Company.
Both Individual or Company inherites from Person that holds common fields from both entities.
There is a way to make the Driver entity flexible to be an Individual or a Company, using the Table per Type on Driver entity?
Thanks you all!!!
Upvotes: 1
Views: 334
Reputation: 39297
I think you need to change it so that Driver HAS A Person instead of Driver IS A Person. i.e. you have a separate Driver class and it has a field on it called Person and that 'Person' is either an individual or a company.
OR you should move the DriverNumber field to the Person class so that a Person (Individual or Company) can be a 'Driver' if they happen to have a driver number.
Upvotes: 1
Reputation: 7612
Why not change the design to say that a 'Driver' is 'associated' (0..1) rather than inherited from a Person. Basically making 'driver' an optional entity of person then both individual or company will inherit this.
Upvotes: 0