0

I have classes that follow a composite pattern relationship for which I need to create the relational data model for Oracle database. The (java) classes are as below -

class AbstractEmployee {
    int employeeId;
}

class Employee extends AbstractEmployee {
    Date joiningDate;
}

class Supervisor extends AbstractEmployee {
    List<AbstractEmployee> directs;
    int officeLocationId;
}

Clearly, there are attributes which are shared across all classes and there are other attributes which are specific to each class. What would be the best way to create sql tables for the above scenario?

I can see that there are different ways to handle hierarchy namely - TPC, TPH and TPT as provided on this post - inheritance in databases. However, composite patterns pose additional complexity in being intrinsically recursive structures, and as a result, the select/insert query performance can be drastically impacted by the schema.

If possible, please discuss the pros/cons of your solution in terms of scalability and performance.

Community
  • 1
  • 1
  • Only supervisors have locations? – APC May 17 '17 at 14:52
  • Ignore that, its just an example. But I hope you got the question. – Sudhanshu Mittal May 17 '17 at 14:54
  • Actually it's important. Are Supervisors also Employees? Not Abstract Employees but actual instantiated Employees. – APC May 17 '17 at 14:56
  • No, Supervisors are not necessarily instantiated employees. I added the location attribute to illustrate that both sub-classes can have their own specific attributes. Perhaps the example is poorly constructed. The point is that Supervisors forms a composite group of employees and other supervisors. – Sudhanshu Mittal May 17 '17 at 15:03

0 Answers0