this is whats been done so far
USE jordan;
CREATE TABLE book(
`isbn` CHAR(17) NOT NULL,
`title` VARCHAR(30) NOT NULL,
`author` VARCHAR(30) NOT NULL DEFAULT 'N/A',
PRIMARY KEY (`isbn`));
CREATE TABLE IF NOT EXISTS copy(
`code` INT NOT NULL,
`isbn` CHAR(17) NOT NULL,
`duration` TINYINT NOT NULL,
PRIMARY KEY (`code`),
CONSTRAINT `isbn`
FOREIGN KEY (`isbn`)
REFERENCES `book` (`isbn`)
ON DELETE CASCADE
ON UPDATE CASCADE);
CREATE TABLE student(
`no` INT NOT NULL,
`name` VARCHAR(30) NOT NULL,
`school` CHAR(3) NOT NULL,
`embargo` BIT NOT NULL,
PRIMARY KEY (`no`));
CREATE TABLE loan(
`code` INT NOT NULL,
`no` INT NOT NULL,
`taken` DATE NOT NULL,
`due` DATE NOT NULL,
`return` DATE NULL,
PRIMARY KEY (`no`, `taken`, `code`),
CONSTRAINT `code`
FOREIGN KEY (`code`)
REFERENCES `copy` (`code`)
ON DELETE RESTRICT
ON UPDATE CASCADE);
SELECT
`jordan`.`student`.`no` AS `no`,
`jordan`.`student`.`name` AS `name`,
`jordan`.`student`.`school` AS `school`,
`jordan`.`student`.`embargo` AS `embargo`
FROM
`jordan`.`student`
WHERE
(`jordan`.`student`.`school` = 'CMP')