Question: 4 . 1 4 LAB - Implement supertype and subtype entities ( Sakila ) Similar entities have many common attributes and relationships. Similar entities are

4.14 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 f 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 person_id with data type SMALLINT UNSIGNED.
The last_update and create date columns have data type TIMESTAMP.
The picture column has data type BLOB.
All other columns have data type VARCHAR (20)
Implement the belongs_to and works_at relationships as foreign keys;
belongs_to becomes an address_id foreign key in person with data lype SMALiLINT UNSIGNED.
works_at 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 person_id 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 1, 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 fk_payment_customer,
DROP CONSTRAINT EK_Payment staFE:
ALTER TABLE rental
DROP CONSTRAINT Ek_rental_customer,
DROP CONSTRAINT Ek_rental_stafe;
ALTER TABLE StOre
DROP CONSTRAINT EK gLONe stafE;
DROP TABLE customer, stafr;
 4.14 LAB - Implement supertype and subtype entities (Sakila) Similar entities

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!