Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Case

Programming assignment solution

Rating
-
Sold
-
Pages
6
Grade
A+
Uploaded on
23-10-2021
Written in
2019/2020

Programming assignment solution in database

Institution
Course

Content preview

CS2203 Database WA 7

Develop a SQL query that will select all of the books that are currently checked out and are past
due to be returned, which have a value greater than $10.00. Your query must return the name,
address, postal code, and phone number of the borrower, the name and phone number of the
librarian responsible for the transaction, the date the book was due to be returned, and the name,
cost, and ISBN number of the book. You query should sort the list by the return date in
descending order.

You must submit both your SQL query and the output of executing your query against your
database.



Create Database Schema



create table book ( title varchar(60) not null, author varchar(40), cost decimal(10,2), isbn_number
integer not null );



alter table book add unique (isbn_number);



alter table book add primary key (isbn_number);



create table bookcopy ( Isbn_number integer, publicationdate date, sequence integer);



alter table bookcopy add primary key (isbn_number, sequence);



alter table bookcopy add CONSTRAINT bookcopy_uniq UNIQUE (ISBN_number, sequence);



alter table bookcopy add CONSTRAINT book_fkey FOREIGN KEY (isbn_number) REFERENCES book
(isbn_number) ON DELETE CASCADE;




create table borrower ( librarycard integer, name char(40), address char(40), postalcode char(20),
phonenumber char(20), membershipdate date);

, alter table borrower add primary key (librarycard);



create table librarian ( librarianid integer, name char(40), phonenumber char(20), supervisor integer);



alter table librarian add primary key (librarianid);




create table booklended ( librarycard integer not null, checkoutdate date not null, returndate date,
ISBN_number integer not null,

sequence integer not null, librarianid integer not null

);



alter table booklended add PRIMARY KEY (ISBN_number, sequence, librarycard, checkoutdate);



alter table booklended add CONSTRAINT booklended_uniq UNIQUE (ISBN_number, sequence,
librarycard, checkoutdate);



alter table booklended add CONSTRAINT borrower_fkey FOREIGN KEY (librarycard) REFERENCES
borrower (librarycard) ON DELETE CASCADE;



alter table booklended add CONSTRAINT librarian_fkey FOREIGN KEY (librarianid) REFERENCES librarian
(librarianid) ON DELETE CASCADE;



alter table booklended add CONSTRAINT bookcopy_fkey FOREIGN KEY (isbn_number, sequence)
REFERENCES bookcopy (isbn_number, sequence);




Populate Book Table

Written for

Institution
Course

Document information

Uploaded on
October 23, 2021
Number of pages
6
Written in
2019/2020
Type
CASE
Professor(s)
Na
Grade
A+

Subjects

$10.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
Given17

Get to know the seller

Seller avatar
Given17 University of the People
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
4 year
Number of followers
0
Documents
5
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions