Question: 4 . 1 4 LAB - Implement supertype and subtype entities ( Sakila ) Similar entities have many common attributes and relationships. Similar entities are
LAB Implement supertype and subtype entities Sakila
Similar entities have many common attributes and relationships. Similar entities are often converted imo aublypes of a Bupertype entity, as illustrated in this lab
In the Sakila database, the customer and staff tables have several common columne. Convert these tables into subtypses of person. Specifically, write CREATE TABL.E statements for porson, oust omer, and st a that imploment thio ER diagram:
Follow Sakila conventions for table and column names:
All lower case
Underscore separator between root and suffix
Foreign keys have the same name as referenced primary key Implement atributes as columns:
The primary key of all three tables is personid with data type SMALLINT UNSIGNED.
The lastupdate and create date columns have data type TIMESTAMP.
The picture column has data type BLOB.
All other columns have data type VARCHAR
Implement the belongsto and worksat relationships as foreign keys;
belongsto becomes an addressid foreign key in person with data lype SMALiLINT UNSIGNED.
worksat becomes a store id foreign key in sta f with data type TINY INT UNSIGNED.
Specify RESTRICT actions for both foreign keys.
Required relationships become NOT NULL foreign keys.
Subtype entities have an Is A relationship to the supertype. Implement these relationships as foreign keys:
The personid columns of custamer and staff become foreign keys referring to person.
Specify CASCADE actions for both foreign keys.
NOTE: If you execute your solution with the Sakila database, you must first drop cust comer, sta and all constraints that refer to these iables. Use the following statements with Sakila only, not in the zyLab environment:
ALTER TABLE payment
DROP CONSTRAINT fkpaymentcustomer,
DROP CONSTRAINT EKPayment staFE:
ALTER TABLE rental
DROP CONSTRAINT Ekrentalcustomer,
DROP CONSTRAINT Ekrentalstafe;
ALTER TABLE StOre
DROP CONSTRAINT EK gLONe stafE;
DROP TABLE customer, stafr;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
