Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Similar entities have many common attributes and relationships. Similar entities are often converted into subtypes of a supertype entity, as illustrated in this lab. In
Similar entities have many common attributes and relationships. Similar entities are often converted into subtypes of a supertype entity, as illustrated in this lab.
In the Sakila database, the customer and staff tables have several common columns. Convert these tables into subtypes of person. Specifically, write CREATE TABLE statements for person, customer, and staff that implement this ER diagram:
The diagram has five entities and two relationships. The entities are person, staff, customer, address, and store. Person is a super type entity, with subtypes staff and customer. Staff appears above customer, within person. Address and store appear outside person. Person has attributes personid R U firstname, lastname, email, active, and lastupdate. Staff has attributes personid R U picture, username, and password. Customer has attributes personid R U and createdate. Address and store have no attributes. Relationship addressbelongstoperson has cardinality onemany maximum and onezero minimum. Relationship staffworksatstore has cardinality manyone maximum and zeroone minimum.
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 attributes as columns:
The primary key of all three tables is personid with data type SMALLINT UNSIGNED.
The lastupdate and createdate 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 type SMALLINT UNSIGNED.
worksat becomes a storeid foreign key in staff with data type TINYINT UNSIGNED.
Specify RESTRICT actions for both foreign keys.
Required relationships become NOT NULL foreign keys.
Subtype entities have an IsA relationship to the supertype. Implement these relationships as foreign keys:
The personid columns of customer 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 customer, staff, and all constraints that refer to these tables. Use the following statements with Sakila only, not in the zyLab environment:
ALTER TABLE payment
DROP CONSTRAINT fkpaymentcustomer,
DROP CONSTRAINT fkpaymentstaff;
ALTER TABLE rental
DROP CONSTRAINT fkrentalcustomer,
DROP CONSTRAINT fkrentalstaff;
ALTER TABLE store
DROP CONSTRAINT fkstorestaff;
DROP TABLE customer, staff;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started