0

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?

Robert Omete
  • 64
  • 1
  • 10
  • To get Id of Employee surely you can use the Id from base class Person? Or does you DB have two tables employee and person? – Rippo Sep 21 '13 at 09:10
  • My database has two tables employee and person but it does not allow a primary key on employee which is the sub table – Robert Omete Sep 21 '13 at 15:21
  • I only know Nhibernate but it appears you are looking for table per concrete class, see this blog post http://ayende.com/blog/3941/nhibernate-mapping-inheritance – Rippo Sep 22 '13 at 11:05
  • It seems that postgresql supports this but no other ORM except perhaps NHIBERNATE in this forum:https://forum.hibernate.org/viewtopic.php?f=1&t=936671 – Robert Omete Sep 23 '13 at 07:27

1 Answers1

0

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.

Jamie Ide
  • 48,427
  • 16
  • 81
  • 117