Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

DBMS Practical 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Name: Muhammad Idrees Ali

Roll NO: 19128


Class: BMS 1C

DBMS PRACTICAL-1

Relational Data:
Q1: SQL statement to create the table LibraryBook?
Ans: Create table LibraryBook (Accession_Number int, Title varchar(100), Author
varchar(50), Department varchar(50), Purchase_Date date, Price int);

Q2: SQL statement to create the table IssuedBooks?


Ans: Create table IssuedBooks (Accession_Number int, Borrower varchar(50));

Q3: SQL statements to insert all records in the table LibraryBooks provided as data?
Ans: insert into LibraryBook values (10004, 'FUNDAMENTAL OF DATABASE
SYSTEM', 'KS NAVATHE', 'CS', '01-JAN-1998', 675);
insert into LibraryBook values (1102, 'DISCRETE MATHEMATICS', 'O LEVIN',
'MATHS', '19-DEC-2000', 449);
insert into LibraryBook values (1010, 'DATABASE SYSTEM CONCEPTS', 'PROB',
'CS', '02-FEB-1996', 504);
insert into LibraryBook values (2006, 'NEUROLOGY CLINICAL PRACTICAL', 'AK
NAVATHE', 'MEDICINE', '01-JAN-2004', 209);
insert into LibraryBook values (39910, 'SOFTWARE ENGINEERING', 'KK
AGGARWAL', 'CS', '28-FEB-2001', 198);
insert into LibraryBook values (789, 'ORGANIZATIONAL BEHAVIOR', 'S
ROBBINS', 'MANAGEMENT', '09-AUG-1990', 880);

Q4: SQL statements to insert all records in the table IssuedBooks provided as data?
Ans: insert into IssuedBooks values (1002, 'PUNEET');
insert into IssuedBooks values (39910, 'ARVIND');
insert into IssuedBooks values (2006, 'BINEET');

Q5: Identify primary and foreign keys?


Ans: In the table Librarybooks, Accession Number will be primary key and, in the table,
IssuedBooks, Accession Number will be primary key and foreign key.
Q6: Delete the record of book titled “Database System Concepts”?
Ans: delete from LibraryBook where TITLE='DATABASE SYSTEM CONCEPTS';

Q7: Change the Department of the book titled “Discrete Maths” to “CS”?
Ans: update LibraryBooK set DEPARTMENT='CS' where TITLE='DISCRETE
MATHEMATICS';

Q8: List all books that belong to “CS” department?


Ans: select * from LibraryBook where DEPARTMENT='CS';

Q9: List all books that belong to “CS” department and are written by author “Navathe”?
Ans: select * from LibraryBook where DEPARTMENT='CS' and AUTHOR like
'%NAVATHE%';

Q10: List all computer (Department=”CS”) that have been issued?


Ans: select * from LibraryBook, IssuedBooks WHERE Department = 'CS'and
LibraryBook. Accession_number = IssuedBooks. Accession_number;

Q11: List all books which have a price less than 500 or purchased between
“01/01/1999” and “01/01/2004”?
Ans: select * from Library_Book where PRICE < 500 or PURCHASE_DATE between
'01-JAN-1999' and '01-JAN-2004';

You might also like