Question: (MySQL Syntax) Write a single UPDATE statement to change the due date for all books borrowed on same day as the borrowing patron's sign-up. These due dates should be changed to exactly 30 days after patron sign-up. Here are the tables: CREATE TABLE book( isbn VARCHAR(100) PRIMARY KEY, title VARCHAR(100) NOT NULL, author VARCHAR(100) NOT NULL, pub_date DATE ); CREATE TABLE patron( id INT PRIMARY KEY, first_name VARCHAR(100) NOT NULL, last_name VARCHAR(100) NOT NULL, sign_up DATE NOT NULL ); CREATE TABLE borrow( patron INT NOT NULL, book VARCHAR(100) NOT NULL, check_out_date DATE NOT NULL, due_date DATE NOT NULL, PRIMARY KEY(patron, book, check_out_date), FOREIGN KEY (patron) REFERENCES patron(id), FOREIGN KEY (book) REFERENCES book(isbn) ); CREATE TABLE late_notice( patron INT NOT NULL, book VARCHAR(100) NOT NULL, check_out_date DATE NOT NULL, notice_date DATE, FOREIGN KEY (patron, book, check_out_date) REFERENCES borrow(patron, book, check_out_date) );
Question: (MySQL Syntax)
Write a single UPDATE statement to change the due date for all books borrowed on same day as the borrowing patron's sign-up. These due dates should be changed to exactly 30 days after patron sign-up.
Here are the tables:
CREATE TABLE book(
isbn VARCHAR(100) PRIMARY KEY,
title VARCHAR(100) NOT NULL,
author VARCHAR(100) NOT NULL,
pub_date DATE
);
CREATE TABLE patron(
id INT PRIMARY KEY,
first_name VARCHAR(100) NOT NULL,
last_name VARCHAR(100) NOT NULL,
sign_up DATE NOT NULL
);
CREATE TABLE borrow(
patron INT NOT NULL,
book VARCHAR(100) NOT NULL,
check_out_date DATE NOT NULL,
due_date DATE NOT NULL,
PRIMARY KEY(patron, book, check_out_date),
FOREIGN KEY (patron) REFERENCES patron(id),
FOREIGN KEY (book) REFERENCES book(isbn)
);
CREATE TABLE late_notice(
patron INT NOT NULL,
book VARCHAR(100) NOT NULL,
check_out_date DATE NOT NULL,
notice_date DATE,
FOREIGN KEY (patron, book, check_out_date) REFERENCES borrow(patron, book, check_out_date)
);
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
This update statement is failing a test case. Any ideas on how to fix this?