DBMS LAB-MANUAL-NEP-2024-25
Case Study-3
Database: Library
Create Following tables and insert tuples with suitable constraints
Table: Books
Book_Id Book_Name Author_Name Publishers Price Type Quantity
C0001 The Klone and I Lata Kappor EPP 355 Novel 5
F0001 The Tears William Hopkins First Publ 650 Fiction 20
T0001 My First C++ Brain & Brooke ERP 350 Text 10
T0002 C++ Brainwork‟s A.W.Rossaine TDH 350 Text 5
F0002 Thunderbolts Ana Roberts First Publ. 750 Fiction 50
Table: Issued
Book_Id Quantity_Issued
T0001 4
C0001 5
F0001 2
T0002 5
F0002 8
Create table Books(
Book_Id varchar2(5) primary key,
Book_Name char(20),
Author_Name char(25),
Publishers char(15),
Price number(3),
Type char(15),
Qty number(2)
);
Create table Issued(
Book_Id varchar2(5) references Books(Book_Id),
Qty_Issued number(2)
);
Insert into Books values(‘C0001’,’The Klone and I’,’Lata Kappor’,’EPP’,355,’Novel’,5);
DEPT OF BCA, SRFGCC, RCU, BELAGAVI 1
DBMS LAB-MANUAL-NEP-2024-25
Output:-
Write queries for the following
1. To show Book name, Author name and price of books of First Publ. publisher
select book_name, author_name, price
from books
where publishers=’First Publ’;
Output:-
2. Display Book id, Book name and publisher of books having quantity more than 8 and
price less than 500.
select book_id, book_name, publishers
from books
where qty>8 and price<500;
Output:-
DEPT OF BCA, SRFGCC, RCU, BELAGAVI 2
DBMS LAB-MANUAL-NEP-2024-25
3. Select Book id, book name, author name of books which is published by other than ERP
publishers and price between 300 to 700
select book_id, book_name, publishers
from books
where publishers not in ( select publishers
from books
where publishers=’ERP’);
Output:-
4. Generate a Bill with Book_id, Book_name, Publisher, Price, Quantity, 4% of VAT “Total”
select book_id, book_name, publishers, price, qty ,(price+(price*0.04))*qty as Total
from books;
Output:-
5. Display book details with book id‟s C0001, F0001, T0002, F0002 (Hint: use IN operator)
select book_name, publishers, price, type, qty
from books
where book_id in (‘C0001’,’F0001’,’T0002’,’F0002’);
Output:-
DEPT OF BCA, SRFGCC, RCU, BELAGAVI 3
DBMS LAB-MANUAL-NEP-2024-25
6. Display Book list other than, type Novel and Fiction
select book_name, publishers, type, price
from books
where type not in (‘Novel’,’Fiction’);
Output:-
7. Display book details with the author name starting with letter “A”
select book_id, book_name, type, price
from books
where author_name like 'A__%';
Output:-
8. Display book details with the book name starting with letter “T” and ending with “S”
select book_id, book_name, author_name, type, price
from books
where book_name like 'T%s%';
Output:-
9. Select Book_Id, Book_Name, Author Name, Quantity Issued where Books.Books_Id =
Issued.Book_Id
select b.book_id, b.book_name, b.author_name, i.qty_issued
from books b, issued i
where b.book_id=i.book_id;
DEPT OF BCA, SRFGCC, RCU, BELAGAVI 4
DBMS LAB-MANUAL-NEP-2024-25
Output:-
10. List the book_name, Author_name, Price in ascending order of Book_name and then in
descending order of price.
select book_name, author_name, price
from books
order by book_name asc, price desc;
Output:-
DEPT OF BCA, SRFGCC, RCU, BELAGAVI 5