1

So I have found out that I need to do a specialization Hierarchies model, however I can't quite figure out how to code it. I have found some information on how to do generalization.

My question is: is it the same way to code it but different way to express it?

Let's take this as an example:

Model
(source: javaguicodexample.com)

CREATE TABLE Employee(
            EmpNo                  INTEGER,
            EmpName                VARCHAR(30),
            EmpHireDate            DATE,
            CONSTRAINT PKEmployee PRIMARY KEY (EmpNo)
);
 
CREATE TABLE SalaryEmp(
            EmpNo         INTEGER,
            EmpSalary     DECIMAL(10,2),
            CONSTRAINT PKSalaryEmp PRIMARY KEY (EmpNo),
            CONSTRAINT FKSalaryEmp FOREIGN KEY (EmpNo) REFERENCES Employee ON DELETE CASCADE
);
 
CREATE TABLE HourlyEmp(
            EmpNo          INTEGER,
            EmpRate        DECIMAL(10,2),
            CONSTRAINT PKHourlyEmp PRIMARY KEY (EmpNo),
            CONSTRAINT FKHourlyEmp FOREIGN KEY (EmpNo) REFERENCES Employee ON DELETE CASCADE
);

is this how it should be coded? and the ERD should look like this one?

ERD

Community
  • 1
  • 1
PuchuKing33
  • 381
  • 3
  • 7
  • 19

1 Answers1

0

Questions about Specialization-Generalization get asked from time to time around here. You can get a general answer in the info tab. You can also look at the answers to previous questions, How to do Inheritance Modeling in Relational Databases? for example.

Community
  • 1
  • 1
Walter Mitty
  • 18,205
  • 2
  • 28
  • 58