0% found this document useful (0 votes)
131 views11 pages

DBMS Lab Program 1

The document outlines the syllabus, objectives, and assignments for a Database Management Systems lab course. It includes 5 mini projects on various databases like a library database, order database, movie database, college database, and company database. Students will design the databases, write SQL queries to perform operations like retrieving, inserting, updating, and deleting data. They will also develop a mini application project on a real-world domain using front-end tools integrated with a back-end database. The practical exam will evaluate students' ability to perform SQL programming tasks and demonstrate their mini project. Overall, the course aims to develop students' foundational knowledge and skills in database concepts, technologies, and applications.

Uploaded by

amazing video
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
131 views11 pages

DBMS Lab Program 1

The document outlines the syllabus, objectives, and assignments for a Database Management Systems lab course. It includes 5 mini projects on various databases like a library database, order database, movie database, college database, and company database. Students will design the databases, write SQL queries to perform operations like retrieving, inserting, updating, and deleting data. They will also develop a mini application project on a real-world domain using front-end tools integrated with a back-end database. The practical exam will evaluate students' ability to perform SQL programming tasks and demonstrate their mini project. Overall, the course aims to develop students' foundational knowledge and skills in database concepts, technologies, and applications.

Uploaded by

amazing video
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 11

SHREE DEVI INSTITUTE OF TECHNOLOGY

(Affiliated to VTU, Belgaum & Approved by AICTE, New Delhi)


Airport Road Kenjar, Mangaluru-574142

DBMS LABORATORY WITH MINI PROJECT


Lab Manual-18CSL58

Department of Computer Science & Engineering


V Semester
2020-2021

i
CONTENTS

VTU Syllabus For DBMS LAB WITH MINI PROJECT(18CSL58)……………

SL. NO. DESCRIPTION

1. LIBRARY DATABASE

2. ORDER DATABASE
3. MOVIE DATABASE

4. COLLEGE DATABASE
5. COMPANY DATABASE

ii
DBMS LABORATORY WITH MINI PROJECT
[As per Choice Based Credit System (CBCS) scheme]
(Effective from the academic year 2015 -2016)
SEMESTER – V
Subject Code 15CSL58 IA Marks 20
Number of Lecture Hours/Week 01I + 02P Exam Marks 80
Total Number of Lecture Hours 40 Exam Hours 03
CREDITS – 02
Course objectives: This course will enable students to
 Foundation knowledge in database concepts, technology and practice togroom
students into well-informed database applicationdevelopers.
 Strong practice in SQL programming through a variety of databaseproblems.
 Develop database applications using front-end tools and back-endDBMS.
Description (If any):
PART-A: SQL Programming (Max. Exam Mks. 50)
 Design, develop, and implement the specified queries for the followingproblems
using Oracle, MySQL, MS SQL Server, or any other DBMS under
LINUX/Windowsenvironment.
 Create Schema and insert at least 5 records for each table. Addappropriate
databaseconstraints.
PART-B: Mini Project (Max. Exam Mks. 30)
 Use Java, C#, PHP, Python, or any other similar front-end tool. All
applications must be demonstrated on desktop/laptop as a stand-alone or web
based application (Mobile apps on Android/IOS are notpermitted.)

PART A: SQL PROGRAMMING

1 Consider the following schema for a Library Database:


BOOK(Book_id, Title, Publisher_Name, Pub_Year)
BOOK_AUTHORS(Book_id, Author_Name)
PUBLISHER(Name, Address, Phone)
BOOK_COPIES(Book_id, Branch_id, No-of_Copies)
BOOK_LENDING(Book_id, Branch_id, Card_No, Date_Out, Due_Date)
LIBRARY_BRANCH(Branch_id, Branch_Name, Address)
Write SQL queries to
1. Retrieve details of all books in the library – id, title, name ofpublisher,
authors, number of copies in each branch,etc.
2. Get the particulars of borrowers who have borrowed more than 3 books, but
from Jan 2017 to Jun2017.
3. Delete a book in BOOK table. Update the contents of other tables toreflect
this data manipulationoperation.
4. Partition the BOOK table based on year of publication. Demonstrateits
working with a simplequery.
5. Create a view of all books and its number of copies that are currently
available in the Library.

ii
i
2 Consider the following schema for Order Database:
SALESMAN(Salesman_id, Name, City, Commission)
CUSTOMER(Customer_id, Cust_Name, City, Grade, Salesman_id)
ORDERS(Ord_No, Purchase_Amt, Ord_Date, Customer_id, Salesman_id)
Write SQL queries to
1. Count the customers with grades above Bangalore’saverage.
2. Find the name and numbers of all salesman who had more than onecustomer.
3. List all the salesman and indicate those who have and don’t have customers in
their cities (Use UNIONoperation.)
4. Create a view that finds the salesman who has the customer with thehighest
order of a day.
5. Demonstrate the DELETE operation by removing salesman with id 1000. All
his orders must also bedeleted.
3 Consider the schema for Movie Database: ACTOR(Act_id, Act_Name,
Act_Gender) DIRECTOR(Dir_id, Dir_Name, Dir_Phone)
MOVIES(Mov_id, Mov_Title, Mov_Year, Mov_Lang, Dir_id)
MOVIE_CAST(Act_id, Mov_id, Role)
RATING(Mov_id, Rev_Stars) Write SQL queries to
1. List the titles of all movies directed by‘Hitchcock’.
2. Find the movie names where one or more actors acted in two or moremovies.
3. List all actors who acted in a movie before 2000 and also in a movieafter
2015 (use JOINoperation).
4. Find the title of movies and number of stars for each movie that has at least
one rating and find the highest number of stars that movie received. Sortthe
result by movietitle.
5. Update rating of all movies directed by ‘Steven Spielberg’ to5.
4 Consider the schema for College Database: STUDENT(USN, SName,
Address, Phone, Gender) SEMSEC(SSID, Sem, Sec)
CLASS(USN, SSID)
SUBJECT(Subcode, Title, Sem, Credits)
IAMARKS(USN, Subcode, SSID, Test1, Test2, Test3, FinalIA) Write
SQL queries to
1. List all the student details studying in fourth semester ‘C’section.
2. Compute the total number of male and female students in each semester andin
eachsection.
3. Create a view of Test1 marks of student USN ‘1BI15CS101’ in all subjects.
4. Calculate the FinalIA (average of best two test marks) and updatethe
corresponding table for allstudents.
5. Categorize students based on the followingcriterion:
If FinalIA = 17 to 20 then CAT =‘Outstanding’
If FinalIA = 12 to 16 then CAT = ‘Average’ If FinalIA< 12 then CAT =
‘Weak’
Give these details only for 8th semester A, B, and C section students.

i
v
5 Consider the schema for Company Database:
EMPLOYEE(SSN, Name, Address, Sex, Salary, SuperSSN, DNo)
DEPARTMENT(DNo, DName, MgrSSN, MgrStartDate)
DLOCATION(DNo,DLoc)
PROJECT(PNo, PName, PLocation, DNo) WORKS_ON(SSN, PNo,
Hours)
Write SQL queries to
1. Make a list of all project numbers for projects that involve anemployee
whose last name is ‘Scott’, either as a worker or as a manager of the
department that controls theproject.
2. Show the resulting salaries if every employee working on the ‘IoT’ project is
given a 10 percent raise.
3. Find the sum of the salaries of all employees of the ‘Accounts’ department,as
well as the maximum salary, the minimum salary, and the average salary in
thisdepartment
4. Retrieve the name of each employee who works on all the projects
controlledby department number 5 (use NOT EXISTSoperator).
5. For each department that has more than five employees, retrieve the
department number and the number of its employees who are makingmore
thanRs. 6,00,000.

PART B: MINI PROJECT

 For any problem selected, write the ER Diagram, apply ER-mappingrules,


normalize the relations, and follow the application developmentprocess.
 Make sure that the application should have five or more tables, at least one
trigger and one stored procedure, using suitable frontendtool.
 Indicative areas include; health care, education, industry, transport, supplychain,
etc.
Course outcomes: The students should be able to:
 Create, Update and query on thedatabase.
 Demonstrate the working of different concepts ofDBMS
 Implement, analyze and evaluate the project developed for anapplication.
Conduction of Practical Examination:
1. All laboratory experiments from part A are to be included forpractical
examination.
2. Mini project has to be evaluated for 30Marks.
3. Report should be prepared in a standard format prescribed for projectwork.
4. Students are allowed to pick one experiment from the lot.
5. Strictly follow the instructions as printed on the cover page of answerscript.
6. Marksdistribution:
a) Part A: Procedure + Conduction + Viva:10 + 35 +5 =50Marks
b) Part B: Demonstration + Report + Viva voce = 15+10+05 = 30Marks
7. Change of experiment is allowed only once and marks allotted to theprocedure
part to be madezero.

v
Write SQL queries to:
1. Retrieve details of all books in the library – id, title, name of publisher, authors,
number of copies in each branch,etc.
2. Get the particulars of borrowers who have borrowed more than 3 books, but from Jan
2017to Jun 2017
3. Delete a book in BOOK table. Update the contents of other tables to reflect
thisdata manipulationoperation.
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
theLibrary.

Entity-Relationship Diagram:

v
i
Schema Diagram:

v
ii
Table Creation:

create table PUBLISHER_dbms(Name varchar(15),


Address varchar(15),
Phone varchar(10),
Primary key (Name));

create table BOOK_dbms(Book_id varchar(4),


Title varchar(10),
Publisher_name varchar(15),
Pub_year int,
primary key (Book_id),
Foreign key(Publisher_name) references PUBLISHER_dbms (Name) on delete
cascade);

create table BOOK_AUTHORS_dbms(Book_id varchar(4),


Author_name varchar(10),
primary key (Book_id),
Foreign key(Book_id) references BOOK_dbms (Book_id) on delete cascade);

create table LIBRARY_PROGRAMME_dbms(programme_id varchar(4),


programme_name varchar(15),
Address varchar(15),
primary key (programme_id));

create table BOOK_LENDING_dbms(Book_id varchar(4),


programme_id varchar(4),
Card_no int,
Date_out datetime,
Due_date datetime,
primary key (Book_id, programme_id, Card_no),
Foreign key(Book_id) references BOOK_dbms (Book_id) on delete cascade,
Foreign key(programme_id) references LIBRARY_PROGRAMME_dbms (programme_id) on
delete cascade);

create table BOOK_COPIES_dbms(Book_id varchar(4),


programme_id varchar(4),
No_of_copies int,
primary key (Book_id, programme_id),
Foreign key(Book_id) references BOOK_dbms (Book_id) on delete cascade,
Foreign key(programme_id) references LIBRARY_PROGRAMME_dbms (programme_id) on
delete cascade);

v
ii
i
To view created tables:

SELECT * FROM PUBLISHER_dbms;

SELECT * FROM BOOK_dbms;

SELECT * FROM BOOK_AUTHORS_dbms;

SELECT * FROM LIBRARY_PROGRAMME_dbms;

SELECT * FROM BOOK_LENDING_dbms;

SELECT * FROM BOOK_COPIES_dbms;

Inserting values:

insert into PUBLISHER_dbms values ('TMH', 'Mangalore','9876543897');


insert into PUBLISHER_dbms values ('Prism', 'chennai','8756444324');
insert into PUBLISHER_dbms values ('Himalaya', 'Kolkata','9876556785');
insert into PUBLISHER_dbms values ('Pearson','Delhi','9878987675');
insert into PUBLISHER_dbms values ('Elsevier','Bangalore','7659876785');

insert into BOOK_dbms values ('b1','DBMS', 'TMH',2015);


insert into BOOK_dbms values ('b2','DMS', 'Prism',2016);
insert into BOOK_dbms values ('b3','CN', 'Himalaya',2015);
insert into BOOK_dbms values ('b4','AI', 'Pearson',2013);
insert into BOOK_dbms values ('b5','OS', 'Elsevier',2017);

insert into BOOK_AUTHORS_dbms values ('b1','navathe');


insert into BOOK_AUTHORS_dbms values ('b2','dsc');
insert into BOOK_AUTHORS_dbms values ('b3','david');
insert into BOOK_AUTHORS_dbms values ('b4','stuart');
insert into BOOK_AUTHORS_dbms values ('b5','galvin');

insert into LIBRARY_PROGRAMME_dbms values ('bh1','Book Corner', 'Bangalore');


insert into LIBRARY_PROGRAMME_dbms values ('bh2','Book Point', 'Mangalore');
insert into LIBRARY_PROGRAMME_dbms values ('bh3','Book Cafe', 'Mumbai');

insert into BOOK_COPIES_dbms values ('b1','bh1',10);


insert into BOOK_COPIES_dbms values ('b1','bh2',15);
insert into BOOK_COPIES_dbms values ('b2','bh2',30);
insert into BOOK_COPIES_dbms values ('b2','bh3',28);
insert into BOOK_COPIES_dbms values ('b3','bh1',35);
insert into BOOK_COPIES_dbms values ('b3','bh2',22);
insert into BOOK_COPIES_dbms values ('b4','bh1',8);

i
x
insert into BOOK_COPIES_dbms values ('b5','bh3',17);

(Note: For Mysqluse Date Format: ’YYYY-MM-DD’. Eg: ’2017-01-02’.)

insert into BOOK_LENDING_dbms values ('b1','bh1',1,'02-jan-17','10-jan-17');


insert into BOOK_LENDING_dbms values ('b2','bh2',2,'11-jan-17','11-mar-17');
insert into BOOK_LENDING_dbms values ('b3','bh1',1,'21-feb-17','21-apr-17');
insert into BOOK_LENDING_dbms values ('b5','bh3',1,'15-mar-17','15-jul-17');
insert into BOOK_LENDING_dbms values ('b3','bh2',4,'12-apr-17','12-may-17');
insert into BOOK_LENDING_dbms values ('b4','bh1',1,'21-feb-17','21-apr-17');

Queries:

1. Retrieve details of all books in the library – id, title, name of publisher,
authors, number of copies in each branch, etc.

select b.book_id, b.title, b.publisher_name, a.author_name, c.no_of_copies,


lp.programme_name

from BOOK_dbms b, BOOK_AUTHORS_dbms a, BOOK_COPIES_dbms c, LIBRARY_PROGRAMME_dbms lp

where b.book_id=a.book_id and b.book_id=c.book_id and c.programme_id=lp.programme_id;

2. Get the particulars of borrowers who have borrowed more than 3 books, but
from Jan 2017 to Jun2017.

select Card_no

from BOOK_LENDING_dbms

where Date_out between '01-jan-2017' and '01-jun-2017'

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.

Delete from BOOK_dbms where Book_id='b4';

(Note: records corresponds to Book_id =’b4’ is also deleted from BOOK_AUTHORS,


LIBRARY_BRANCH, BOOK_COPIES and BOOK_LENDING tables because of the use
of ‘on delete CASCADE’ constraint on foreign keys).

x
4. Partition the BOOK table based on year of publication. Demonstrate its working
with a simplequery.

create view V_PUBLICATION_dbms as select Pub_year from BOOK_dbms;

select * from V_PUBLICATION_dbms;

5. Create a view of all books and its number of copies that are currently available
in the Library.

create view V_BOOKS_dbms as select b.Book_id, b.Title, c.programme_id, c.No_of_copies

from BOOK_dbms b, BOOK_COPIES_dbms c, LIBRARY_PROGRAMME_dbms lp

where b.Book_id=c.Book_id and c.programme_id=lp.programme_id;

select * from V_BOOKS_dbms;

x
i

You might also like