Question: Please help with this SQL Code Refer to the address, store, staff, and customer tables of the Sakila database. In this lab, these tables initially

Please help with this SQL Code
Refer to the address, store, staff, and customer tables of the Sakila database. In this lab, these tables initially have the same
columns as in Sakila, however some constraints are different.
The customer and staff tables have many common columns. Move these columns to a new supertype table person, as shown in
the following diagram:
addr
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 the diagram in three steps:
Step 1. Create a person supertype table:
Create a primary key person_id with data type SMALIINT uNSIGNED.
Add the common columns of customer and staff (refer to the diagram). Specify the same data types and constraints as in
customer and staff.
Implement the belongs_to relationship as a foreign key constraint on address_id. Specify the same foreign key rules as in
customer and staff.
Step 2. Drop common columns from customer and staff:
Drop columns that moved to person in step 1.
Do not drop last_update, as every Sakila table has this column.
Drop the foreign key constraint on address_id before dropping this column.
Step 3. Implement IsA relationships in customer and staff:
Drop the existing primary key columns.
Add new primary keys person_id with data type SMALLINT UNSIGNED.
Implement the IsA relationships as foreign key constraints on person_id. Specify CA.SCADE foreign key rules.
HINT: Use ALTER TABLE to add and drop foreign key constraints:
ALTER TABLE customer
ADD FOREIGN KEY (person_id) REFERENCES person (person_id) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE customer
DROP FOREIGN KEY customer_ibfk_1;
-- customer_ibfk_1 is a symbol representing the first foreign key declared in customer
Please help with this SQL Code Refer to the

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 Programming Questions!