Louis I. answered 06/19/20
Computer Science Instructor/Tutor: Real World and Academia Experienced
Presented in the opposite order, since problem 1 refers to a table
defined/constructed in problem 2
#2)
CREATE TABLE agent (
id VARCHAR(2) NOT NULL,
name VARCHAR(32) NOT NULL,
area TINYINT NULL,
rating TINYINT NULL CHECK (50 >= rating <= 150 ),
year_of_hire CHAR(4) NULL,
supervisor_id VARCHAR(2) NULL,
PRIMARY KEY(id),
FOREIGN KEY (supervisor_id) REFERENCES agent(id)
);
#1)
CREATE TABLE client (
id VARCHAR(4) NOT NULL,
name VARCHAR(32) NOT NULL,
agent_id VARCHAR(2) NULL,
spouse_name VARCHAR(32) NULL,
PRIMARY KEY(id),
FOREIGN KEY (agent_id) REFERENCES agent(id)
ON UPDATE CASCADE
ON DELETE SET NULL
);
NOTES: I applied my own naming conventions best practices,
but fields/data line up as described in the problem text.