Library Database Program 1-2
Library Database Program 1-2
Aim: Demonstrating creation of tables, applying the view concepts on the tables.
2. Get the particulars of borrowers who have borrowed more than 3 books, but from Jan 2017
to Jun 2017.
3. Delete a book in BOOK table. Update the contents of other tables to reflect this data
manipulation operation.
4. Partition the BOOK table based on year of publication. Demonstrate its working with a
simple query.
5. Create a view of all books and its number of copies that are currently available in the
Library.
DESC PUBLISHER;
--Create Table BOOK with Primary Key as BOOK_ID and Foreign Key PUB_NAME referring the
PUBLISHER table
DESC BOOK;
--Create Table BOOK_AUTHORS with Primary Key as BOOK_ID and AUTHOR_NAME and
Foreign Key BOOK_ID referring the BOOK table
DESC BOOK_AUTHORS;
DESC LIBRARY_PROGRAMME;
--Create Table as BOOK_COPIES with Primary Key as BOOK_ID and PROGRAMME_ID and
Foreign Key BOOK_ID and PROGRAMME_ID referring the BOOK and LIBRARY_PROGRAMME
tables respectively
DESC BOOK_COPIES;
DESC CARD;
DESC BOOKLENDING;
Insert Values
--------------------------
--------------------------
----------------------------
--------------------------
--------------------------
--------------------------
SQL QUERIES
1. Retrieve details of all books in the library – id, title, name of publisher, authors,number of
copies in each Programme, etc.
---------------------------------------------
2. Get the particulars of borrowers who have borrowed more than 3 books, but from Jan 2017
to Jun 2017.
SELECT CARD_NO
FROM BOOK_LENDING
WHERE DATE_OUT BETWEEN '2017-01-01' AND '2017-06-01'
GROUP BY CARD_NO
HAVING COUNT(*)>3;
---------------------------------------------
3. Delete a book in BOOK table. Update the contents of other tables to reflect this data
manipulation operation.
---------------------------------------------
4. Partition the BOOK table based on year of publication. Demonstrate its working with a
simple query.
---------------------------------------------
5. Create a view of all books and its number of copies that are currently available in the
Library.