'MySQL Specialization/Generalization questions

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



Solution 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Community