Professional Documents
Culture Documents
18CSL58-DBMS LAB Excercise-1 Library Database
18CSL58-DBMS LAB Excercise-1 Library Database
18CSL58-DBMS LAB Excercise-1 Library Database
Title Phone
Pub_Year
Book_id Name Address
Published
BOOK Publisher
by
No_of_Copies
Authored
by
BOOK_AUTHORS LIBRARY_PROGRAMME
Address
Programme_id
Auther_Name
me Programme_Name
e
PUBLISHER
Name Address Phone
BOOK
Book_id Title Publisher_Name Pub_Year
BOOK_AUTHORS
Book_id Author_Name
LIBRARY_PROGRAMME
Programme_id Programme_Name Address
BOOK_COPIES
Book_id Programme_id No_of_Copies
BOOK_LENDING
Book_id Programme_id Card_No Date_Out Due_Date
1 CSE Block A
3 ECE Block B
4 ME Block D
5 CIV Block D
2 ISE Block F
103 3 20
101 2 60
101 3 20
104 1 50
100 1 5
100 2 40
101 1 10
102 1 60
102 2 100
102 3 50
( ***Note: Use SQL Command Prompt DOS Shell Window to avoid date Error***)
6.
insert into book_lending values(100,1,200,'15-Oct-2019', '30-Oct-2019');
insert into book_lending values(101,1,200,'5-Sep-2020', '20-Sep-2020');
Retrieve details of all books in the library – id, title, name of publisher, authors,
Query 1. number of copies in each Programme, etc.
select bk.book_id, title, publisher_name, author_name, no_of_copies, programme_name
from book bk, book_authors ba, library_programme lp, book_copies bc
where bk.book_id=ba.book_id and bk.book_id=bc.book_id and bc. Programme_id=lp.
Programme_id
order by programme_name, bk.book_id;
BOOK_ID TITLE PUBLISHER_NAME AUTHOR_NAME NO_OF_COPIES PROGRAMME_NAME
Shamkant B.
104 Fundamentals of Database Systems Pearson 50 CSE
Navathe
Get the particulars of borrowers who have borrowed more than 3 books, but
Query 2. from Jan 2017 to Jun 2017.
BORROWER NOOFBOOKSBORROWED
300 4
Partition the BOOK table based on year of publication. Demonstrate its working
Query 4. with a simple query.
create view book_part as select book_id,pub_year from book;
104 2017
100 2005
101 2014
102 2015
Create a view of all books and its number of copies that are currently available
Query 5. in the Library.
create view book_view (book_id,Title, No_of_copies) as Select book.book_id, Title,
sum(No_of_Copies) from book, book_copies where book.book_id=book_copies.book_id
group by book.book_id,title order by book.book_id;
select * from book_view;