100% found this document useful (5 votes)
2K views3 pages

Accessionnumber Title Author Department Purchasedate Price

The document describes creating and populating two tables (LibraryBooks and IssuedBooks) to computerize a library system for a Delhi University college. The LibraryBooks table tracks book information like title, author, and price. The IssuedBooks table tracks which books are borrowed by which patrons. The document demonstrates inserting records, deleting a record, updating a record, and querying the tables to list books by department, author, or other criteria.

Uploaded by

Ayushi Jangpangi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (5 votes)
2K views3 pages

Accessionnumber Title Author Department Purchasedate Price

The document describes creating and populating two tables (LibraryBooks and IssuedBooks) to computerize a library system for a Delhi University college. The LibraryBooks table tracks book information like title, author, and price. The IssuedBooks table tracks which books are borrowed by which patrons. The document demonstrates inserting records, deleting a record, updating a record, and querying the tables to list books by department, author, or other criteria.

Uploaded by

Ayushi Jangpangi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Question 1.

Create a database having two tables with the specified fields, to computerize a library system of a
Delhi University College.

LibraryBooks (Accession number, Title, Author, Department, PurchaseDate, Price)

IssuedBooks (Accession number, Borrower)

(a) Identify primary and foreign keys. Create the tables and insert at least 5 records in each table.

Answer 1.

(a) create table LibraryBooks ( AccessionNumber int , Title varchar (50) , Author varchar (20) ,
Department varchar (20) , PurchaseDate date , Price int ) ;

insert into LibraryBooks values ( 10004 , 'Fundamentals of Database System' , 'Navathe' , 'CS' , '01-
Jan-1998' , 675 ) ;

insert into LibraryBooks values ( 1002 , 'Discrete Mathematics' , 'O.Levin' , 'Maths' , '19-Dec-2000' ,
449 ) ;

insert into LibraryBooks values ( 1010 , 'Database System Concepts' , 'P.Rob' , 'CS' , '02-Mar-1996' ,
504 ) ;

insert into LibraryBooks values ( 2006 , 'Nuerology in Clinical Practice' , 'Navathe' , 'Medicine' , '01-
Jan-2004' , 209 ) ;

insert into LibraryBooks values ( 39910 , 'Software Engineering' , 'KK Aggarwal' , 'CS' , '28-Feb-2001' ,
198 ) ;

insert into LibraryBooks values ( 789 , 'Organisation Behaviour' , 'S Robins' , 'Management' , '09-Aug-
1990' , 800 ) ;

select * from LibraryBooks ;

ACCESSIONNUMBER TITLE AUTHOR DEPARTMENT PURCHASEDATE PRICE


Database
1010 System P.Rob CS 02-MAR-96 504
Concepts
Fundamentals
10004 of Database Navathe CS 01-JAN-98 675
System
Discrete
1002 O.Levin Maths 19-DEC-00 550
Mathematics
Nuerology in
2006 Clinical Navathe Medicine 01-JAN-04 209
Practice
Software KK
39910 CS 28-FEB-01 198
Engineering Aggarwal
Organisation
789 S Robins Management 09-AUG-90 800
Behaviour

create table IssuedBooks ( AccessionNumber int , Borrower varchar (30) ) ;

insert into IssuedBooks values ( 1002 , 'Puneet' ) ;


insert into IssuedBooks values ( 2006 , 'Bineet' ) ;

insert into IssuedBooks values ( 39910 , 'Arvind' ) ;

select * from IssuedBooks ;

ACCESSIONNUMBER BORROWER
2006 Bineet
1002 Puneet
39910 Arvind

(b) Delete the record of book titled “Database System Concepts”.

delete from LibraryBooks where title = 'Database System Concepts' ;

ACCESSIONNUMBER TITLE AUTHOR DEPARTMENT PURCHASEDATE PRICE


Fundamentals
10004 of Database Navathe CS 01-JAN-98 675
System
Discrete
1002 O.Levin Maths 19-DEC-00 550
Mathematics
Nuerology in
2006 Clinical Navathe Medicine 01-JAN-04 209
Practice
Software KK
39910 CS 28-FEB-01 198
Engineering Aggarwal
Organisation
789 S Robins Management 09-AUG-90 800
Behaviour

(c) Change the Department of the book titled “Discrete Maths” to “CS”.

update LibraryBooks set department = 'CS' where title = 'Discrete Mathematics' ;

ACCESSIONNUMBER TITLE AUTHOR DEPARTMENT PURCHASEDATE PRICE


Fundamentals
10004 of Database Navathe CS 01-JAN-98 675
System
Discrete
1002 O.Levin CS 19-DEC-00 550
Mathematics
Nuerology in
2006 Clinical Navathe Medicine 01-JAN-04 209
Practice
Software KK
39910 CS 28-FEB-01 198
Engineering Aggarwal
Organisation
789 S Robins Management 09-AUG-90 800
Behaviour

(d) List all books that belong to “CS” department.

select * from LibraryBooks where department = 'CS' ;

ACCESSIONNUMBER TITLE AUTHOR DEPARTMENT PURCHASEDATE PRICE


Fundamentals
10004 of Database Navathe CS 01-JAN-98 675
System
1002 Discrete O.Levin CS 19-DEC-00 550
Mathematics
Software KK
39910 CS 28-FEB-01 198
Engineering Aggarwal

(e) List all books that belong to “CS” department and are written by author “Navathe”.

select * from LibraryBooks where department = 'CS' and author = 'Navathe' ;

ACCESSIONNUMBER TITLE AUTHOR DEPARTMENT PURCHASEDATE PRICE


Fundamentals
10004 of Database Navathe CS 01-JAN-98 675
System

f) List all computer (Department=”CS”) that have been issued.

select * from LibraryBooks , IssuedBooks where department = 'CS' and


LibraryBooks.AccessionNumber = IssuedBooks.AccessionNumber ;

ACCESSIONN AUTH DEPART PURCHAS PRI ACCESSIONN BORRO


UMBER TITLE OR MENT EDATE CE UMBER WER
Discrete
O.Levi
1002 Mathem CS 19-DEC-00 550 1002 Puneet
n
atics
Softwar
KK
e
39910 Aggar CS 28-FEB-01 198 39910 Arvind
Enginee
wal
ring

g) List all books which have a price less than 500 or purchased between “01/01/1999” and
“01/01/2004”

select * from LibraryBooks where price < 500 or purchasedate between '01-Jan-1999' and '01-Jan-
2004' ;

ACCESSIONNUMBER TITLE AUTHOR DEPARTMENT PURCHASEDATE PRICE


Discrete
1002 O.Levin CS 19-DEC-00 550
Mathematics
Nuerology in
2006 Clinical Navathe Medicine 01-JAN-04 209
Practice
Software KK
39910 CS 28-FEB-01 198
Engineering Aggarwal

You might also like