Hello, this is the SQL code I have so far. It is based off of the ERD shown in the image attached. Basically, I want to add customer payment tracking, an employee table with work schedules and which videos they checked out to the customers all within the code. Current SQL code: -- Create Customer table CREATE TABLE Customer (   CUST_NUM INT PRIMARY KEY,   CUST_LNAME VARCHAR(50),   CUST_FNAME VARCHAR(50),   CUST_INITIAL VARCHAR(10),   CUST_E_MAIL VARCHAR(100) ); -- Insert some sample data into Customer table INSERT INTO Customer (CUST_NUM, CUST_LNAME, CUST_FNAME, CUST_INITIAL, CUST_E_MAIL) VALUES   (1, 'Smith', 'John', 'A', 'jsmith@example.com'),   (2, 'Johnson', 'Jane', 'M', 'jjohnson@example.com'),   (3, 'Garcia', 'Maria', 'L', 'mgarcia@example.com'),   (4, 'Lee', 'David', 'K', 'dlee@example.com'); -- Create Video table CREATE TABLE Video (   VIDEO_ID INT PRIMARY KEY,   VIDEO_CLASS VARCHAR(50),   VIDEO_TITLE VARCHAR(100),   VIDEO_CHG DECIMAL(5,2) ); -- Insert some sample data into Video table INSERT INTO Video (VIDEO_ID, VIDEO_CLASS, VIDEO_TITLE, VIDEO_CHG) VALUES   (1, 'Action', 'Die Hard', 2.99),   (2, 'Comedy', 'The Hangover', 1.99),   (3, 'Drama', 'The Shawshank Redemption', 3.99),   (4, 'Science Fiction', 'Blade Runner', 2.49); -- Create Rental table with rental date, due date, and return date columns CREATE TABLE Rental (   VIDEO_ID INT,   CUST_NUM INT,   RENTAL_OUT DATE,   RENTAL_DUE DATE,   RENTAL_RETURN DATE,   PRIMARY KEY (VIDEO_ID, CUST_NUM),   FOREIGN KEY (VIDEO_ID) REFERENCES Video(VIDEO_ID),   FOREIGN KEY (CUST_NUM) REFERENCES Customer(CUST_NUM) ); -- Insert some sample data into Rental table INSERT INTO Rental (VIDEO_ID, CUST_NUM, RENTAL_OUT, RENTAL_DUE, RENTAL_RETURN) VALUES   (1, 1, '2022-01-01', '2022-01-08', NULL),   (2, 2, '2022-02-01', '2022-02-08', NULL),   (3, 3, '2022-03-01', '2022-03-08', NULL),   (4, 4, '2022-04-01', '2022-04-08', '2022-04-05'); select * from Customer; select * from Rental; select * from Video;

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Hello, this is the SQL code I have so far. It is based off of the ERD shown in the image attached.

Basically, I want to add customer payment tracking, an employee table with work schedules and which videos they checked out to the customers all within the code.

Current SQL code:

-- Create Customer table
CREATE TABLE Customer (
  CUST_NUM INT PRIMARY KEY,
  CUST_LNAME VARCHAR(50),
  CUST_FNAME VARCHAR(50),
  CUST_INITIAL VARCHAR(10),
  CUST_E_MAIL VARCHAR(100)
);

-- Insert some sample data into Customer table
INSERT INTO Customer (CUST_NUM, CUST_LNAME, CUST_FNAME, CUST_INITIAL, CUST_E_MAIL)
VALUES
  (1, 'Smith', 'John', 'A', 'jsmith@example.com'),
  (2, 'Johnson', 'Jane', 'M', 'jjohnson@example.com'),
  (3, 'Garcia', 'Maria', 'L', 'mgarcia@example.com'),
  (4, 'Lee', 'David', 'K', 'dlee@example.com');

-- Create Video table
CREATE TABLE Video (
  VIDEO_ID INT PRIMARY KEY,
  VIDEO_CLASS VARCHAR(50),
  VIDEO_TITLE VARCHAR(100),
  VIDEO_CHG DECIMAL(5,2)
);

-- Insert some sample data into Video table
INSERT INTO Video (VIDEO_ID, VIDEO_CLASS, VIDEO_TITLE, VIDEO_CHG)
VALUES
  (1, 'Action', 'Die Hard', 2.99),
  (2, 'Comedy', 'The Hangover', 1.99),
  (3, 'Drama', 'The Shawshank Redemption', 3.99),
  (4, 'Science Fiction', 'Blade Runner', 2.49);

-- Create Rental table with rental date, due date, and return date columns
CREATE TABLE Rental (
  VIDEO_ID INT,
  CUST_NUM INT,
  RENTAL_OUT DATE,
  RENTAL_DUE DATE,
  RENTAL_RETURN DATE,
  PRIMARY KEY (VIDEO_ID, CUST_NUM),
  FOREIGN KEY (VIDEO_ID) REFERENCES Video(VIDEO_ID),
  FOREIGN KEY (CUST_NUM) REFERENCES Customer(CUST_NUM)
);

-- Insert some sample data into Rental table
INSERT INTO Rental (VIDEO_ID, CUST_NUM, RENTAL_OUT, RENTAL_DUE, RENTAL_RETURN)
VALUES
  (1, 1, '2022-01-01', '2022-01-08', NULL),
  (2, 2, '2022-02-01', '2022-02-08', NULL),
  (3, 3, '2022-03-01', '2022-03-08', NULL),
  (4, 4, '2022-04-01', '2022-04-08', '2022-04-05');

select * from Customer;
select * from Rental;
select * from Video;

K
Figure 9.9 Jollygood Movie Rental ERD
CUSTOMER
PK CUST NUM
CUST_LNAME
CUST_FNAME
CUST_INITIAL
CUST_E_MAIL
requests
RENTAL
PK,FK2 VIDEO ID
PK,FK1 CUST NUM
RENTAL_OUT
RENTAL_RETURN
is written in
H
PK
VIDEO
VIDEO ID
VIDEO CLASS
VIDEO_TITLE
VIDEO_CHG
Transcribed Image Text:K Figure 9.9 Jollygood Movie Rental ERD CUSTOMER PK CUST NUM CUST_LNAME CUST_FNAME CUST_INITIAL CUST_E_MAIL requests RENTAL PK,FK2 VIDEO ID PK,FK1 CUST NUM RENTAL_OUT RENTAL_RETURN is written in H PK VIDEO VIDEO ID VIDEO CLASS VIDEO_TITLE VIDEO_CHG
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Intermediate SQL concepts
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education