Question

I am designing a database using both ORM tools from Telerik ORM and Devexpress ORM data model wizard. I have two classes an employee and person class. The employee class inherits from person class which is the base class. Both ORMs insist the person class must have an identity column/key which is fair enough. But I want the employee class to also have an identity column as well but to inherit atttributes from the person class which both ORMs do not allow. This also includes nHibernate. Anyone with an idea how to go about this?

Était-ce utile?

La solution

Inheritance is an "is a" relationship; employee is a person, so an employee's id is a person's id. If you're using table per concrete class mapping as Rippo suggested, then the Employee table should have a primary key of PersonId that is also a foreign key to the Person table.

I would also think about modeling this relationship using roles instead of inheritance.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top