Question
PLEASE Check AND SEE IF THIS CODE BELOW IS CORRECT BECAUSE IT SEEMS NOT TO RUN ON MY END CREATE TABLE Books ( ISBN INT
PLEASE Check AND SEE IF THIS CODE BELOW IS CORRECT BECAUSE IT SEEMS NOT TO RUN ON MY END
CREATE TABLE Books (
ISBN INT NOT NULL ,
book_name VARCHAR( 100 ) NOT NULL ,
book_status CHAR( 1 ) NOT NULL ,
book_type INT NOT NULL,
book_edition INT NOT NULL ,
book_publisher INT NOT NULL ,
PRIMARY KEY ( ISBN )
);
CREATE TABLE Book_Type (
book_type_id INT NOT NULL ,
book_type_name VARCHAR( 50 ) NOT NULL
PRIMARY KEY ( book_type_id )
);
CREATE TABLE Author (
author_id INT NOT NULL,
author_fname VARCHAR ( 50) NOT NULL ,
author_fname VARCHAR ( 50) NOT NULL ,
author_email VARCHAR ( 100) NOT NULL
);
CREATE TABLE Publisher (
publisher_id INT NOT NULL,
publisher_name VARCHAR (100) NOT NULL,
PRIMARY KEY ( publisher_id )
);
CREATE TABLE Book_Author (
book_id INT NOT NULL ,
author_id INT NOT NULL
);
CREATE TABLE Member (
member_id INT NOT NULL ,
member_fname VARCHAR( 50 ) NOT NULL ,
member_lname VARCHAR( 50 ) NOT NULL,
member_phone VARCHAR( 25 ) NOT NULL ,
member_email VARCHAR( 100 ) NOT NULL ,
member_email VARCHAR( 100 ) NOT NULL ,
member_type INT NOT NULL ,
member_address INT NOT NULL ,
PRIMARY KEY (member_id )
);
CREATE TABLE Member_Type (
member_type_id INT NOT NULL ,
member_type_name VARCHAR( 50 ) NOT NULL ,
member_type_allowed_day INT NOT NULL ,
member_type_fine INT NOT NULL ,
PRIMARY KEY (member_type_id)
);
CREATE TABLE Address (
address_id INT NOT NULL ,
address_desc TEXT NOT NULL ,
postcode INT NOT NULL ,
PRIMARY KEY (address_id )
);
CREATE TABLE Postcode (
postcode_id INT NOT NULL,
postcode_description VARCHAR( 10 ) NOT NULL ,
PRIMARY KEY (postcode_id )
);
CREATE TABLE Librarian (
librarian_id INT NOT NULL ,
librarian_fname VARCHAR( 50 ) NOT NULL ,
librarian_lname VARCHAR( 50 ) NOT NULL ,
librarian_address INT NOT NULL ,
librarian_phone VARCHAR( 25 ) ,
librarian_email VARCHAR( 100 ) ,
PRIMARY KEY ( `librarian_id` )
);
CREATE TABLE Borrow (
borrow_id INT NOT NULL ,
member_id INT NOT NULL ,
ISBN INT NOT NULL ,
librarian_id INT NOT NULL ,
borrow_date DATE NOT NULL ,
return_date DATE ,
expected_return_date DATE NOT NULL ,
PRIMARY KEY (borrow_id )
);
CREATE TABLE Fine (
fine_id INT NOT NULL ,
borrow_id INT NOT NULL ,
librarian_id INT NOT NULL ,
fine_amount FLOAT NOT NULL
fine_paid CHAR( 1 ) NULL ,
PRIMARY KEY ( `fine_id` ),
INDEX (borrow_id)
);
ALTER TABLE Books ADD FOREIGN KEY (book_type) REFERENCES Book_Type (book_type_id) ;
ALTER TABLE Books ADD FOREIGN KEY ( `book_publisher` ) REFERENCES Publisher( publisher_id ) ;
ALTER TABLE Book_Author ADD FOREIGN KEY ( ISBN ) REFERENCES books( ISBN ) ;
ALTER TABLE Book _ Author ADD FOREIGN KEY ( author_id ) REFERENCES Author( author_id ) ;
ALTER TABLE Member ADD FOREIGN KEY ( member_address ) REFERENCES Address( address_id ) ;
ALTER TABLE Member ADD FOREIGN KEY ( member_type) REFERENCES Member_Type( member_type_id ) ;
ALTER TABLE Librarian ADD FOREIGN KEY ( librarian_address ) REFERENCES Address( address_id ) ;
ALTER TABLE Borrow ADD FOREIGN KEY ( member_id ) REFERENCES Member( member_id ) ;
ALTER TABLE Borrow ADD FOREIGN KEY ( ISBN ) REFERENCES books(ISBN) ;
ALTER TABLE Borrow ADD FOREIGN KEY ( librarian_id) REFERENCES Librarian( librarian_id );
ALTER TABLE fine ADD FOREIGN KEY ( borrow_id) REFERENCES Borrow( borrow_id );
ALTER TABLE fine ADD FOREIGN KEY ( librarian_id ) REFERENCES Librarian( librarian_id );
ALTER TABLE address ADD FOREIGN KEY ( postcode ) REFERENCES Postcode( postcode_id);
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