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

Database Management Systems

22AD2102A

STUDENT ID: ACADEMIC YEAR: 2023-24

STUDENT NAME:
22AD2102A` –Database Management Systems

Table of Contents
1. Installation of POSTGRESQL client & server .............................................................. 3

2. Installation of TERA ER Tool & Case Study-1 & 2.................................................... 16

3. Case Study-3& 4 (convert ER to relation model). ....................................................... 26

4. Implementation of DDL & DML Commands .............................................................. 35

5. Implementation of Joins: Inner Join, Outer Join, Natural Join ................................ 46

6. Implementation of Nested Sub Quires .......................................................................... 63

7. Study & Implementation of: Sub Queries and Views ................................................. 73

8. Implementation of PL/SQL programs, procedures, functions ................................... 82

9. Study & Implementation of Triggers & Cursors ........................................................ 90

10. Aggregate Functions, Group by & Having Clauses and Set Operations ............... 98

11. Implement Correlated Nested, Views, Indices and DCL Commands .................. 105

12. Implementation of Transaction in SQL Server ..................................................... 113

13. MongoDB installation and configuration in windows ........................................... 120

14. Create and Drop Database in MongoDB ................................................................ 128

15. Creating the Collection and Drop the collection using MongoDB ....................... 135

16. Insert Document and Query Document in MongoDB collection .......................... 141

17. Update and delete document in MongoDB collection............................................ 148


22AD2102A` –Database Management Systems
18. MongoDB Projection ................................................................................................ 155

19. MongoDB indexing ................................................................................................... 162

20. Aggregations operations in MongoDB .................................................................... 168

21. Capstone Project-1 .................................................................................................... 176

22. Capstone Project-2 .................................................................................................... 178

23. Capstone Project-3 .................................................................................................... 180

24. Capstone Project-4 .................................................................................................... 182

25. Capstone Project-5 .................................................................................................... 184

26. Capstone Project-6 .................................................................................................... 186


22AD2102A` –Database Management Systems
Our Vision:
• To be a department of international repute through continuous research, innovation and
industry led curriculum.
Our Mission:
• To Impart Quality Education with social consciousness and make them Globally Competent.
Organization of the STUDENT LAB WORKBOOK
The laboratory framework includes a creative element but shifts the time-intensive aspects outside of
the Two-Hour closed laboratory period. Within this structure, each laboratory includes three parts:
Prelab, In-lab and post-lab.

Pre-Lab

The Prelab exercise is a homework assignment that links the lecture with the laboratory period -
typically takes 2 hours to complete. The goal is to synthesize the information they learn in lecture
with material from their textbook to produce a working piece of software. Prelab Students attending
a two-hour closed laboratory are expected to make a good-faith effort to complete the Prelab
exercise before coming to the lab. Their work need not be perfect, but their effort must be
real(roughly80percentcorrect).

In-Lab

The In-lab section takes place during the actual laboratory period. The First hour of the laboratory
period can be used to resolve any problems the students might have experienced in completing the
Prelab exercises. The intent is to give constructive feedback so that students leave the lab with
working Prelab software - a significant accomplishment on their part. During the second hour,
students complete the In-lab exercise to reinforce the concepts learned in the Prelab. Students leave
the lab having received feedback on their Prelab and In-lab work.

Post-Lab

The last phase of each laboratory is a homework assignment that is done following the laboratory
period. In the Post-lab, students analyse the efficiency or utility of a given system call. Each Post-lab
exercise should take roughly 120minutes to complete.
LAB CONTINIOUS EVALUATION SHEET

Pre-Lab In-Lab Post Lab Viva Total Faculty


S. No Date Experiment Name (5M) LOGIC (5M) Voce (50M) Signature
EXECUTION RESULT ANALYSIS
(10M) (10M) (5M) (5M)
(10M)
Installation of POSTGRESQL client &
1 server
Installation of TERA ER Tool & Case
2 Study-1 & 2
Case Study-3& 4 (convert ER to relation
3 model).
Implementation of DDL & DML
4 Commands
5 Implementation of Joins: Inner Join,
Outer Join, Natural Join
6 Implementation of Nested Sub Quires

7 Implementation of: Sub Queries and


Views
8 Implementation of PL/SQL programs,
procedures, functions
9 Implementation of Triggers & Cursors

10 Aggregate Functions, Group by &


Having Clauses and Set Operations
11 Implement Correlated Nested, Views,
Indices and DCL Commands
12 Implementation of Transaction in SQL
Server
13 MongoDB installation and
configuration in windows
22AD2102A` –Database Management Systems
LAB CONTINIOUS EVALUATION SHEET

S. No Date Experiment Name Pre-Lab In-Lab Post Lab Viva Total Faculty
(5M) (5M) Voce (50M) Signature
LOGIC EXECUTION RESULT ANALYSIS (5M)
(10M) (10M) (10M) (5M)
14 Create and Drop Database in MongoDB

15 Creating the Collection and Drop the


collection using MongoDB
16 Insert Document and Query Document
in MongoDB collection
17 Update and delete document in
MongoDB collection
18 MongoDB Projection

19 MongoDB indexing
20 Aggregations operations in MongoDB

21 Capstone Project-1

22 Capstone Project-2

23 Capstone Project-3

24 Capstone Project-4

25 Capstone Project-5

26 Capstone Project-6
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

1. Installation of POSTGRESQL client & server

Aim/Objective:
To download, install the PostgreSQL which is powerful and open-source object-relational database
system and study the basics of the PostgreSQL.
Description:
PostgreSQL is a popular relational database management system (RDBMS). PostgreSQL is not
controlled by any corporation or other private entity and the source code is available free of charge.
PostgreSQL runs on all major operating systems, including Linux, UNIX and Windows. It supports
text, images, sounds, and video, and includes programming interfaces for C / C++, Java, Perl, Python,
Ruby, Tcl and Open Database Connectivity (ODBC). PostgreSQL supports four standard procedural
languages, which allows the users to write their own code in any of the languages and it can be
executed by PostgreSQL database server. These procedural languages are - PL/pgSQL, PL/Tcl,
PL/Perl and PL/Python. Besides, other non-standard procedural languages like PL/PHP, PL/V8,
PL/Ruby, PL/Java, etc., are also supported.
Pre-Requisites:
The requirement to learn PostgreSQL is knowledge of the database, mainly the RDBMS and
MySQL. It is database software having different settings and procedures.
Pre Lab-Task:

Answer the following question before entering into lab. The following pre lab task has to perform at
home.

1. Define the term Data and Metadata?

2. Define the term Information and its benefits?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 3 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

3. What is Database? What is its need?

4. What are the Rolls of Database Administrator?

5. What is Database Management System? What is its need?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 4 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

6. list out some database management system software.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 5 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

In Lab Task
Installation of PostgreSQL

Download PostgreSQL Installer for Windows from URL:(https://www.postgresql.org/download/)

Since version 8.0, PostgreSQL offers an installer for Windows systems that makes the installation process
easier and faster. For development purposes, we will install PostgreSQL version 12 or above version on
Windows 10.

There are three steps to complete the PostgreSQL installation:


1. Download PostgreSQL installer for Windows
2. Install PostgreSQL on Windows 10
3. Verify the installation
1. Download PostgreSQL Installer for Windows

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 6 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

2. Install PostgreSQL on Window step by step


Step 1: - Double click on the installer file, an installation wizard will appear and guide you
through multiple steps where you can choose different options that you would like to have in
PostgreSQL.
Step 2: - Click the Next button

Step 3: - Specify installation folder, choose your own or keep the default folder suggested by
PostgreSQL installer and click the Next button

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 7 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Step 4: - Select software components to install:

✓ The PostgreSQL Server to install the PostgreSQL database server


✓ pgAdmin 4 to install the PostgreSQL database GUI management tool.
✓ Command Line Tools to install command-line tools such as psql, pg_restore, etc. These
tools allow you to interact with the PostgreSQL database server using the command-line
interface.
✓ Stack Builder provides a GUI that allows you to download and install drivers that work
with PostgreSQL.

For the tutorial on this website, you don’t need to install Stack Builder so feel free to uncheck
it and click the Next button to select the data directory:

Step 5: - Select the database directory to store the data or accept the default folder. And click
the Next button to go to the next step:

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 8 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Step 6: - Enter the password for the database superuser (XXXXXXX)

PostgreSQL runs as a service in the background under a service account named XXXXXXX.
If you already created a service account with the name XXXXXXX, you need to provide the
password of that account in the following window.

After entering the password, you need to retype it to confirm and click the Next button:

Step 7: - Enter a port number on which the PostgreSQL database server will listen. The
default port of PostgreSQL is 5432. You need to make sure that no other applications are
using this port.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 9 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Step 8: - Choose the default locale used by the PostgreSQL database. If you leave it as default locale,

PostgreSQL will use the operating system locale. After that click the Next button.

Step 9: - The setup wizard will show the summary information of PostgreSQL. You need to
review it and click the Next button if everything is correct. Otherwise, you need to click the
Back button to change the configuration accordingly.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 10 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Now, you’re ready to install PostgreSQL on your computer. Click the Next button to begin
installing PostgreSQL.

The installation may take a few minutes to complete.

Step 10: - Click the Finish button to complete the PostgreSQL installation.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 11 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

3. Verify the Installation

✓ There are several ways to verify the PostgreSQL installation. You can try to connect to the
PostgreSQL database server from any client application e.g., psql and pgAdmin.
✓ The quick way to verify the installation is through the psql program.

First, click the psql application to launch it. The psql command-line program will display.

Second, enter all the necessary information such as the server, database, port, username, and
password. To accept the default, you can press Enter. Note that you should provide the
password that you entered during installing the PostgreSQL.

Third, issue the command SELECT version(); you will see the following output:

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 12 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Sample VIVA Questions:-


1.What is PostgreSQL?
2.What are the advantages of PostgreSQL?
3.Which data types are used in PostgreSQL?
4.Why do companies use PostgreSQL?
5.What is the meaning of PGAdmin in PostgreSQL?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 13 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 14 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Post Lab:

Answer the following question before entering into lab. The following post lab task has to
perform at home.
1) Why we need to model data base.

2) What is meant by logical data model

3) What is meant by physical data model

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 15 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

2. Installation of TERA ER Tool & Case Study-1 & 2

Aim/Objective:
To download, install the TerraER tool which is designed to help users to learn and practice the basics
of database management.
Description: -
TerraER is a simple to use application which allows you to create data models in a graphic
environment. You can control the number and location of the entities, the relations or intermediate
elements, by manually placing them in the required form. The tool allows you to create diagrams of
entities and relations, in order to study the connections that link them. The elements are customizable,
allowing you to rename, resize and easily relocate them. The building tools include entities and weak
entities, relationships, entity relationships, roles, key / derived / multi-value attributes, connection
cardinality and adjacent functions. You may add disjunctions, overlapping elements, generalizations
and optional / required connections.
Pre-Requisites: The Pre-requisites of TerraER tool is to know the different notations used in it.
Pre Lab-Task:
Answer the following question before entering into lab. The following pre lab task has to perform at
home.

1. Define Entity. Types?

2. What is Data Independence?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 16 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

3. What is an attribute and explain different types of attributes?

4. What is the difference between entity type and entity set?

5. Define different types of Relationship Types?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 17 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

In Lab Task
Installation of TERA ER Tool

TerraER is a free open-source learning tool designed to aid students in the creation of entity-
relationship models. Our main goal is to provide students with a tool that reflects exactly the data
modelling concepts learned in the classroom.

Web Site: http://www.terraer.com.br/


Version tested: TerraER 2.02
System requirements: Java 1.5 or higher
License & Pricing: Open-Source GNU Public License, Freeware.

Introduction
Data modelling is one part of the database conceptual design process. The entity-relationship model
(ER model) is a largely used conceptual model proposed by Chen [1]. It defines the entities and the
relationships between these entities. The ER model is simple and easy to understand, making it
intelligible to both database designers and end users
Installation
TerraER is distributed in a single JAR file publicly available for download at our web
site www.terraer.com.br/download_en.html. The JAR file is auto-contained, i.e., it can be placed in
any folder, does not require the installation of additional libraries, and does not change operating
system files (e.g., windows registry). In a nutshell, TerraER requires only a Java Runtime
Environment (JRE) previously installed on the target computer
(www.java.com/en/download/index.jsp).

TerraER was initially designed for academic purposes, i.e., to help students and professors in
the task of creating ER models. Therefore, we developed the graphical user interface to be
practical, intelligible, and intuitive
Course Title Database Management Systems ACADEMIC YEAR: 2023-24
Course Code(s) 22AD2102A Page 18 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

CaseStudy-1 (convert ER to relation model)

COVID-19 is also known as Corona Virus. It was first reported to the World Health Organization
(WHO) on the31st of December, 2019 in Wuhan, China. Mr. John employed the services of a Data
Analyst for the design of a COVID-19 database. Mr. John gave requirements to the Data Analyst to
carry on his work in designing the database. This database system is helpful in finding out the number
of cases in a particular day and in a particular country. It should also give the no. of persons recovered
or died based on the data stored in the database. By analyzing the data, we can find out the most
Covid affected areas over the globe. This system requires a database for storing the details of all the
countries with their details of country code, name, population count and such other details related to
the country. There should be Person database where all the details of the people are stored who came
for taking the test. Initially the status of the person is taken as negative. There is a need of another
database where the affected person’s data is stored. Data is inserted in to this whenever a person is
found covid positive. It should also contain the information about the recovered or death cases.
Include any other entities which are required according to your requirement.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 19 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 20 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

CaseStudy-2 (convert ER to relation model)


Andhra Hospitals is a multi-specialty hospital that includes several departments, rooms, doctors,
nurses, compounders, and other staff working in the hospital. Students at KL University are assigned
the task of designing and developing a database for the hospital to maintain the records of various
departments, rooms, and doctors in the hospital using the following information: In hospital, there are
many departments, each department has department name, department location, and facilities
available in that department. Department name will be unique for each department.
Two types of the doctors in the hospital namely, regular doctors and call on doctors. Regular doctors
come to the hospital daily. Calls on doctors are called by the hospital if the concerned doctor is not
available. Each doctor is given an identity number starting with DR (regular doctors) or DC (calls on
doctors) prefixes only. Regular doctors are referred to by their identity number, name, qualification,
address, phone number, salary, date of joining, etc. Calls on doctors have some additional attributes
like fees per call, payment due.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 21 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Viva Questions:
1.Name some of the tools for ER design that are available in the market?
2.List the Advantages & Disadvantages of TerraER Design tool?
3.Justify the importance of TerraER design tool with respect to the real time project
environment?
4.Give the symbol for representing the Relationship in TerraER tool?
5.List out the software industries that are using TerraER tool before the creation of any database
design?
Course Title Database Management Systems ACADEMIC YEAR: 2023-24
Course Code(s) 22AD2102A Page 22 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 23 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Post Lab

Answer the following question before entering into lab. The following post lab task has to
perform at home.
Draw an ER Diagram for the following description.

EMPLOYEE WITH ATTRIBUTES (EMPNO, ENAME, AL, CONTACTNO, DOB, AGE, ADDRESS,

DEPTNO), DEPARTMENT WITH ATTRIBUTES (DEPTNO, DNAME, LOCATION)

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 24 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 25 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

3. Case Study-3& 4 (convert ER to relation model).

Aim/Objective:
The aim of this program is to draw the Entity Relationship (ER) Diagram for the below case
studies of three and four.
Description:
In this program, we will draw the Entity Relationship (ER) Diagram. ER Diagram stands for
Entity Relationship Diagram, also known as ERD is a diagram that displays the relationship of
entity sets stored in a database. In other words, ER diagrams help to explain the logical structure
of databases. ER diagrams are created based on three basic concepts: entities, attributes and
relationships.
Pre-Requisites:
The machine is to be installed with TerraER software /tools to accomplish the given task.
Pre Lab-Task:

Answer the following question before entering into lab. The following pre lab task has to
perform at home.
1) Explain about derived attributes

2) Explain about simple attribute

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 26 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

3) Explain about composite attribute

4) Explain about key attribute

5) Explain about Multi-valued attribute

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 27 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

In Lab Task

Draw an ER Diagram for the case study 3, Railway reservation system.

The railway reservation system facilitates the passengers to enquire about the trains available based
on source and destination, booking and cancellation of tickets, enquire about the status of the booked
ticket. Our aim here is to design and develop a database maintaining records of different trains, train
status, and passengers. the record of train includes its number, name, source, destination, and days on
when its available. Passengers can book their tickets for the train in which seats are available. Before
booking a ticket, the validity of train number and booking date is checked. Once they are validated,
seat availability is checked, and ticket is booked. Ticket once booked can be cancelled at any time.
For this we need to provide ticket id. Also consider that initially passenger needs authentication as
well. Design a database for the above scenario. Include the entities whatever are required according to
your requirements.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 28 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 29 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Draw an ER Diagram for the following case study 4.

In a university, there are several departments and each department has a head of department
who belongs to Faculty. Department have a name, phone extension, specific mailing address and
Students that belong to the department. Students can belong to only one Department at a time and
Department can have more than one or no Student. Students and faculty have names and unique
identification numbers, with address, age, gender and other information. Student studies different
Courses offered by university. Faculty teaches these Courses. In each semester one student can take
more than one course and Faculty can teach more than one courses. Faculty members can teach in
multiple Departments. Each course can be taught by many faculty members or no one. Faculty
members are also working on multiple research projects. These projects are funded by government
and university. One project can have more than one faculty member and one faculty member can
work on more than one project.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 30 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Sample VIVA-VOCE Questions (In-Lab):

1. What is an ER Diagram?

2. Why are composite keys important when modelling databases with entity-relationship diagrams?

3. What does it mean to generalize/specialize an object in an ER diagram?

4. What is an identifying relationship?

5. What is a primary key? How is it represented in an ER diagram?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 31 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 32 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Post Lab

Answer the following question before entering into lab. The following post lab task has to perform
at home.
Draw an ER Diagram for the case study, University online Exam system.
We are all aware of the current pandemic situation, our university is providing the online exams to
complete the semester on time. These exam systems come with online invigilation and proctoring
features to ensure a fair examination process. This system is very much useful in conducting the
exams online maintain the social distance which is very much to be followed in the current scenario.
Students also will be benefited by not losing their academic year and can continue their studies
without any break.
To design this system, the database should contain the information about courses, sections, exam
details and staff conducting the exam like squad, proctors involved in the exam duty. Courses
database should contain the details of the courses for which exam is being conducted along with the
no. of students enrolled for each exam. Online Exam database contains the exam details like exam
id, exam date, squad etc. Depending on the number of students enrolled for the exam in a course,
rooms should be allotted for the students. This is done in the ROOM database where the no. of
students should not be more than 50 and contains the details of proctors allotted for those rooms.
There is a faculty database which contains the details of the faculty to whom the exam duties should
be allotted. Design a database for the above scenario. Include the entities whatever are required
according to your requirements.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 33 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 34 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

4. Implementation of DDL & DML Commands


Aim/Objective:
The aim of this program is to implement the data definition language and data manipulation language
commands
Description:
In this program, we will implement DDL and DML commands Data Definition Language (DDL) is
used to define database schema in DBMS. Data Manipulation Language (DML) is used to manipulate
data present in the database
Pre-Requisites:
The machine is to be installed with PostgreSQL software /tools to accomplish the given task.

Pre Lab-Task:
Answer the following question before entering into lab. The following pre lab task has to perform at
home.

1. What does SQL stand for?

2. Which SQL statement is used to extract data from a database?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 35 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

3. Which SQL statement is used to update data in a database?

4. Which SQL statement is used to delete data from a database?

5. Which SQL statement is used to insert new data in a database?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 36 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

In Lab Task
Implementation of basic SQL Queries DDL commands, DML commands.
Problem Description:
SAILORS (SID: INTEGER, SNAME: STRING, RATING: INTEGER, AGE: REAL);
BOATS (BID: INTEGER, BNAME: STRING, COLOR: STRING);
RESERVES (SID: INTEGER, BID: INTEGER, DAY: DATE).

SAILORS BOATS RESERVES


SID SNAME RATING AGE ID BNAME COLOR SID BID DAY
22 DUSTIN 7 45 101 INTERLAK BLUE 22 101 1998-10-10
102 INTERLAK
E RED
29 BRUTUS 1 33 103 E
CLIPPER GREEN 22 102 1998-10-10
31 LUBBER 8 56 104 MARINE RED 22 103 1998-10-8
32 ANDY 8 26 22 104 1998-10-7
58 RUSTY 10 35 31 102 1998-11-10
64 HORATIO 7 35 31 103 1998-11-6
71 ZOR 10 16 31 104 1998-11-12
74 HORATIO 9 40 64 101 1998-9-5
BA
85 ART 3 26 64 102 1998-9-8
95 BOB 3 64 74 103 1998-9-8

Questions:
1. Create tables for Sailors, Reserves and Boats with appropriate key constraints?
2. Write SQL Queries to insert values as per the given above Data Base?
3. To retrieve distinct Sailor name and Sailor Age from Sailors?
4. To retrieve boat name, boat id of the red and green color boats?
5. Find the names of sailors who have reserved a red boat, and list in the order of age?
6. Find the ids of sailors who have reserved a red boat or a green boat?
7. Find the names of sailors who have reserved at least one boat?
8. Display the Insert ‘twenty’ in age column
9. Display the Insert sid: 100 bid: 205, day: 12-09-17 in reserves table.
10. Create a query that displays the Insert sid: 95, Sname: anil, Rating:3, age: 64 in sailor’s
table.
11. Create a query that displays the update 10.5 as rating where sailor id= 95
12. In the reserves table give date as per this format like did/mm/yyy

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 37 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 38 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 39 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Sample VIVA-VOCE Questions (In-Lab):

1. What is the difference between Drop, Delete and Truncate statements in postgreSQL?
2. list various DDL commands
3. List various DML commands
4. Differentiate the commands ALTER and UPDATE
5. What is the use of Select command in postgreSQL?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 40 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 41 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Post Lab:
Answer the following question before entering into lab. The following post lab task has to perform at
home.
Use the tables below and implement the below queries

CUSTOMER ARTIST

CID PID RENATL_D RENTAL_ AID NAME ADDRESS PHONE


ATE PERIOD
200 JOHN DELHI 7786549803
104 300 10-06-2020 6
201 SAMUEL MUMBAI 7123458790
105 302 05-07-2020 10
202 SAMSON LUCKNOW 9460367777
108 304 15-07-2020 3
203 DAVID HYDERABAD 9797276764
109 305 25-06-2020 6
204 RAGHU HYDERABAD 8134185751
205 RAVI MUMBAI 7471094738
206 KIRAN DELHI 9808003725

PAINTING
CID CNAME ADDRESS PHONE CATEGORY
100 RAJU HYDERABAD 9876045789 BRONZE
101 HARI VIJAYAWADA 8877678956 GOLD
102 DEVI GUNTUR 7879312123 SILVER
103 RANI DELHI 8780945290 PLATINUM
104 JAYA MUMBAI 9612578457 GOLD
105 HARITHA KOLKATA 9611665513 SILVER
106 KALYAN VIJAYAWADA 9610752569 BRONZE
107 ROJA HYDERABAD 9609839625 PLATINUM
108 AMAR VIJAYAWADA 9608926681 GOLD
109 PADMA VIJAYAWADA 9608013737 BRONZE

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 42 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

OWNER
PID OID NAME ADDRESS PHONE
300 500 RAJU HYDERABA 9460367777 RENT
D
301 500 HARI VIJAYAWAD 8134185751 PID AID RENTAL_ TYPE
A COST
302 501 GIRI HYDERABA 7808003725 300 201 4500 HIRED
D 301 202 3500 NOT HIRED
303 501 GOPI DELHI 9481821699
302 203 7500 HIRED
304 503 KRISH MUMBAI 7155639673
303 205 2500 NOT HIRED
NA
305 502 VERM DELHI 8829457647 304 202 10000 NOT HIRED
A 305 201 8000 NOT HIRED
306 502 GUNA DELHI 7503275621
306 203 6500 NOT HIRED

Questions
1. Create the tables identifying the constraints and relationships
2. Insertatleast10recordsinto these tables
3. Display the customer details who got the category as “Gold”
4. Display the list of artists who belong to “Hyderabad”
5. Create a query display the painting details which are not hired
6. Create a query to update the rental cost of the painting with 1000forthepaintings which are not
hired
7. Display the details of the artist whose paintings are hired

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 43 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 44 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 45 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

5. Implementation of Joins: Inner Join, Outer Join, Natural Join


Aim/Objective:
The aim of this program is to implement inner join, outer join and natural join
Description:
In this program, we will implement to implement inner join, outer join and natural join. Joins are mostly
used when a user is trying to extricate data from multiple tables (which have one-to-many or many-to-
many relationships with each other) at one time. The join keyword merges two or more tables and
creates a temporary image of the merged table. Then according to the conditions provided, it extracts
the required data from the image table, and once data is fetched, the temporary image of the merged
tables is dumped.
. Pre-Requisites:
The machine is to be installed with PostgreSQL software /tools to accomplish the given task.
Pre Lab-Task
Answer the following question before entering into lab. The following pre lab task has to perform at
home

1. Explain about joins

2. Discuss about left join

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 46 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

3. Explain about right join

4. Difference between nested query and sub query

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 47 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

In Lab Task
Implementation of distinct types of Joins: Inner Join, Outer Join, Natural Join etc.
ENTITIES ATTRIBUTES
CUSTOMER CUST_ID, CUST_NAME, DOB, CITY, STREET, STATE, PINCODE,
PH_NO, DEAL_NO, PHOTO_IDENTITY,
V_ID
VEHICLE V_ID, VEH_TYPE, VEH_NAME, VEH_NUMBER
EDU_BUS EDU_ID, EDU_NAME, PH_NO,
CITY,STREET,STATE,PINCODE,DEAL_NO
DEALER DEAL_ID, DEAL_NAME, CITY, STREET,
STATE,PINCODE,D_NO,PH_INT
BRANCH BRANCH_ID, B_NAME, STATE, CITY, PINCODE, STREET, D_NO,
PHNO1, PHNO2,
C_ID, V_ID, E_ID
RENEWAL BRACH_ID, CID, CHECK_LICENSE_PERIOD
REGISTRATION CUST_ID, V_ID, DEALID, DATE
CONTRACT_PERMISSION V_ID, BRANCH_ID, NO_OF_DAYS, AMOUNT_PER_SEAT

CUSTOMER

VEHICLE

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 48 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

EDU_BUS

DEALER

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 49 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

BRANCH

RENEWAL REGISTRATION

CONTRACT_PERMISSION

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 50 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Questions:

1. Create the database in PostgreSQL and create the necessary tables for the given case study using
appropriate keys and relationships between the tables
2. Display the vehicles that were registered by the dealer name 'Raghu'
3. Display the list of customers who have applied for new license
4. Display the vehicles who have been given 30 days of contract permission.
5. Create a query to display all the records who applied for renewal of license.
6. Display the count of vehicles of different types.
7. Create a query to display customer details who have 2-wheeler vehicle.
8. Create a query that displays the customer details whose license expires in 5 days.
9. Display the list of educational institutions who applied for permit.
10.Display the total number of vehicles license allotted by each branch.
11.Display the number of customer present under each dealer.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 51 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 52 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 53 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 54 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Sample viva voce questions


1. What is Cartesian product?
2. Differentiate is Equi join & Non-Equi Join?
3. Why should we use Natural Join?
4. Describe the importance of outer join
5. Differentiate Left outer join and Right outer join

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 55 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 56 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Post Lab

Answer the following question before entering into lab. The following post lab task has to perform at home.
Use the tables below and implement the below queries
Student:
REGNO NAME ADDRESS PHONE AGE
101 SAI VIJAYAWADA 9455123451 18
102 TEJA GUNTUR 9652431543 18
103 DINESH DELHI 9156253131 20
104 TAURN CHENNAI 9156768971 18
105 DHANRAJ MUMBAI 9156253132 19
106 ROHIT BANGALORE 9652431544 18
107 NIRAJ GOA 9455123452 18

Course:
COURSE_ID REG NO
1 101
2 102

2 103
3 104
4 105
5 106
1 107

1. Show the names and age of students enrolled in different courses


2. All the rows of the table on the left side of the join and matches rows for the table on the right side
of the join
3. Creates the result-set by combining results of both LEFT JOIN and RIGHT JOIN.
4. Find all students and their respective course

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 57 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 58 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 59 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Use the tables below and implement the below queries


Employee:
EMPID EMPFNAME EMPLNAME AGE EMAILID PHONENO ADDRESS

1 VARDHAN KUMAR 22 VARDY@ABC.COM 9876543210 DELHI

2 HIMANI SHARMA 32 HIMANI@ABC.COM 9977554422 MUMBAI

3 AAYUSHI SHRESHTH 24 AAYUSHI@ABC.COM 9977555121 KOLKATA

4 HEMANTH SHARMA 25 HEMANTH@ABC.COM 9876545666 BENGALURU

5 SWATEE KAPOOR 26 SWATEE@ABC.COM 9544567777 HYDERABAD

Project:
PROJECTID EMPID CLIENTID PROJECTNAME PROJECTSTARTDATE

111 1 3 PROJECT1 2019-04-21

222 2 1 PROJECT2 2019-02-12

333 3 5 PROJECT3 2019-01-10

444 3 2 PROJECT4 2019-04-16

555 5 4 PROJECT5 2019-05-23

666 9 1 PROJECT6 2019-01-12

777 7 2 PROJECT7 2019-07-25

888 8 3 PROJECT8 2019-08-20

1. All the rows of the table on the left side of the join and matches rows for the table on the right side
of the join
2. Creates the result-set by combining results of both LEFT JOIN and RIGHT JOIN

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 60 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 61 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 62 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

6. Implementation of Nested Sub Quires


Aim/Objective:
The aim of this program is to implement nested sub queries in postgreSQL
Description:
In this program, we will implement to implement nested sub queries in postgreSQL. A nested query in SQL
contains a query inside another query. The outer query will use the result of the inner query. For instance,
a nested query can have two SELECT statements, one on the inner query and the other on the outer query

Pre-Requisites:
The machine is to be installed with PostgreSQL software /tools to accomplish the given task
Pre Lab-Task
Answer the following question before entering into lab. The following pre lab task has to perform at home
1. What it means ‘%S__k’

2. What it means ‘%___k’

3. Explain about min, max functions in SQL

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 63 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

4. Explain about various conditional operators in SQL

5. Explain about various logical operators in SQL

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 64 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

In Lab Task:
Use the tables and data in Experiment–5, In-Lab section and work on the following queries

1. Display the list of customers available in a branch.


2. Create a PostgreSQL query to know the older of all the customers
3. Write PostgreSQL query to calculate the total amount generated by giving contract permission for amount
per seat
4. Create a query to display all the type of vehicles present
5. Write PostgreSQL query to display all the cities present in a given state.
6. Display the number of vehicles of customers who are not having photo id entity.
7. Write PostgreSQL statement to search for vehicle type which is having the vehicle id as the smallest number.
8. Create a PostgreSQL query to know the branch name an dphonenumber of a customer who is having
license period of 2years.
9. Display the vehicle details for which hmaximum amount is paid per seat for contract permission.
10. Write Co-related nested subquery to know the customer name, phone number, city whose branch name is
‘Madhapur’
11. Create a view “Present_Customer” with customername, phonenumber, state and city of customer and
display the view.
12. Write PostgreSQL query to show indexes on customer table.
13. Create a query to display the count of dealers from “Andhra Pradesh”

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 65 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 66 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Sample viva voce questions


1. What is a nested query?
2. Describe the necessity of using IN and NOT IN in sub queries
3. Describe the necessity of using ALL and ANY in sub queries
4. Illustrate the pattern matching command in postgre SQL
5. Explain the necessity of Aggregate operations in nested queries

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 67 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 68 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Post Lab: -
Answer the following question before entering into lab. The following post lab task has to perform at home.
WORKER:

WORKER_ID FIRST_NAME LAST_NAME SALARY JOINING_DATE DEPARTMENT

001 MONIKA ARORA 100000 2014-02-2009:00:00 HR

002 NIHARIKA VERMA 80000 2014-06-1109:00:00 ADMIN

003 VISHAL SINGHAL 300000 2014-02-2009:00:00 HR

004 AMITABH SINGH 500000 2014-02-2009:00:00 ADMIN

005 VIVEK BHATI 500000 2014-06-1109:00:00 ADMIN

006 VIPUL DIWAN 200000 2014-06-1109:00:00 ACCOUNT

007 SATISH KUMAR 75000 2014-01-2009:00:00 ACCOUNT

008 GEETIKA CHAUHAN 90000 2014-04-1109:00:00 ADMIN


BONUS:

WORKER_REF_ID BONUS_DATE BONUS_AMOUNT

1 2016-02-20 :00:00 5000

2 2016-06-11 :00:00 3000

3 2016-02-20 :00:00 4000

4 2016-02-20 :00:00 4500

5 2016-06-11 :00:00 3500


TITLE:

WORKER_REF_ID WORKER_TITLE AFFECTED_FROM

1 MANAGER 2016-02-2000:00:00

2 EXECUTIVE 2016-06-1100:00:00

8 EXECUTIVE 2016-06-1100:00:00

5 MANAGER 2016-06-1100:00:00

4 ASST.MANAGER 2016-06-1100:00:00

7 EXECUTIVE 2016-06-1100:00:00

6 LEAD 2016-06-1100:00:00
3 LEAD 2016-06-1100:00:00

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 69 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

1. Create the database in PostgreSQL and create the necessary tables for the given case study using
appropriate keys and relationships between the tables
2. Create a SQL query to display employees details whose salary is greater than 30000 and less than
50000
3. Display the no. of employees in each department
4. Display the count of employees with same designation in an organization

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 70 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 71 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 72 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

7. Study & Implementation of: Sub Queries and Views


Aim/Objective:
The aim of this program is to implement sub queries and views in postgreSQL

Description:
In this program, we will implement to implement sub queries and views in postgreSQL. Subqueries are queries that
are nested within another SQL query. A subquery can contain more than one query inside it, one after another.
They allow us to select specific rows that satisfy certain conditions at the run time. They are also known as the inner
query or inner select, and the query that contains them is known as the outer query or outer select. Subqueries are
nested inside statements like SELECT, INSERT, UPDATE, DELETE, or any other subquery. A View in SQL is simply a
virtual table created based on a result set of another SQL statement. Views were introduced to reduce the
complexity of multiple tables and deliver data in a simple manner. Views help us maintain data integrity and
provide security to the data, thus acting as a security mechanism.

Pre-Requisites:
The machine is to be installed with PostgreSQL software /tools to accomplish the given task

Pre Lab-Task
Answer the following question before entering into lab. The following pre lab task has to perform at home
1. Explain about various conditional operators in SQL

2. Explain about various logical operators in SQL

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 73 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

3. What is the use of BETWEEN command

4. Explain about various aggregation functions in SQL.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 74 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

In Lab Task
PATIENT:
PID FNAME LNAME EMAIL PHNO ADDRESS DATE_ADMN

200 DAVID SAMSON AAA@GMAIL.COM 7654328976 MUMBAI 13-10-2019

201 BHARATH KUMAR BBB@GMAIL.COM 8765438907 HYDERABAD 22-01-2020

202 ESWAR PRASAD CCC@GMAIL.COM 9876548838 VIJAYAWADA 15-03-2020

203 JAYA LAXMI DDD@GMAIL.COM 8765489765 DELHI 06-07-2020

204 LAXMI DEVI EEE@GMAIL.COM 7654430692 MUMBAI 12-03-2020

205 PRAMOD REDDY FFF@GMAIL.COM 6543371619 HYDERABAD 05-02-2020

206 CHARAN KUMAR GGG@GMAIL.COM 5432312546 VIJAYAWADA 22-04-2020

207 KALYAN REDDY HHH@GMAIL.COM 4321253473 DELHI 10-07-2020

208 RAJESH YADAV IKLMN@GMAIL.COM 3210194400 CHENNAI 03-03-2020

209 NAVEEN KUMAR JGHFR@GMAIL.COM 2099135327 HYDERABAD 22-04-2020

PCASE SHIFT
BEDNUM PID DOCTOR ID DAY STARTTI ENDTIME
ME
20 200
100 12-04-2020 9 5
21 201
101 20-06-2020 4 8
22 202
102 01-08-2020 6 12
23 203
105 05-08-2020 13 18
24 204 13-10-2019
106 4 8
25 205 22-01-2020 6 12
107
26 206 108 15-03-2020 13 18
27 207 06-07-2020
109 9 5
28 208 110 12-03-2020 4 8
29 209 05-02-2020 6 12
111
112 22-04-2020 13 18
PID AMT
113 10-07-2020 4 8
200 200 03-03-2020 6 12
114
201 200
115 22-04-2020 13 18
202 300
203 600
204 200
205 300
206 200
APPOINTMENT
207 200
208 200
209 600

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 75 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Question:
1. Write an POSTGRESQL query to display who are patients required to stay in the hospital?
2. Write an POSTGRESQL query to display who paid amount between 1000 and 3000 for the appointment
3. Write an POSTGRESQL query to calculate average amount of appointment.
4. Write an POSTGRESQL query to display patient number in descending order
5. Write an POSTGRESQL query to display bed number of patient with least patient id.
6. Write query for creating view from patient table.
7. Write a POSTGRESQL query to update view the Patient view where patientid >3 by using replace
view statement
8. Display the patient date of joining into format “dd month yyyy’ for example as “24 March 2020”
9. Display the patient joining time in 24-hour format. For eg: 3:30pm should be displayed as 15:30
10. Write a POSTGRESQL query to display count of patients who come from same city.
11. Write a POSTGRESQL query to first name of patient who admitted and allotted the bed no.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 76 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 77 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Sample viva voce questions


1. What is Sub query?
2. List the aggregate functions used in sub queries
3. Differentiate simple view and complex view
4. What are the advantages of views?
5. Is view is updatable? If so explain

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 78 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 79 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Post Lab

Answer the following question before entering into lab. The following post lab task has to
perform at home.
1. Write a Query to display Patient name who has paid the Highest room rent?

2. Write a Query to display the Doctor id who treated the patient admitted in bedno 24

3. Write query for creating view from doctor table

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 80 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 81 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

8. Implementation of PL/SQL programs, procedures, functions


Aim/Objective:
The aim of implementing PL/SQL programs, procedures, and functions in a database management system
(DBMS) is to enhance the functionality and efficiency of database operations.
Description:
PL/SQL (Procedural Language/Structured Query Language) is a procedural extension of SQL that is used
in Oracle Database systems. PL/SQL provides a robust and powerful programming language to develop
applications that interact with the database. PL/SQL programs are composed of blocks of code that can
contain SQL statements, procedural constructs, and exception handling mechanisms. Within PL/SQL, you
can define procedures, functions, and anonymous blocks.
Pre-Requisites:
This Section contains the list of Software/Tools or required knowledge (Glossary) to complete the task
under the Laboratory Session.
Pre Lab-Task
Answer the following question before entering into lab. The following pre lab task has to perform at
home
1. Compare SQL & PL/SQL

2. What is PL/SQL?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 82 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

3. What is the basic structure of PL/SQL?

4. Explain the uses of database trigger?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 83 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

In Lab Task
Execute the following queries:

1. Write a PL/SQL stored procedure to know the current age of customers who are associated with
APtransport department.
2. Write a PL/SQL stored function to know that, from how many years vehicles are registered with the
APtransport department.
3. Create a trigger before insert to maintain the summary of Dealer Center table into Dealer Center
stats. Whenever the capacity of Dealer Centers is increased or decreased then the total statistics
should be reflectedin Dealer Center stats
4. Create trigger after insert in members table, a trigger should check the value of attribute name and
if it is updated then show the message for updating on name in reminder table.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 84 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 85 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Viva-Voce Questions (In-Lab):


1. What is PL/SQL, and how does it differ from SQL?
2. Explain the benefits of using PL/SQL programs in a database system.
3. What is a PL/SQL block?
4. Differentiate between procedures and functions in PL/SQL.
5. Explain the concept of cursors in PL/SQL and their purpose.
6. What is a cursor variable, and how is it different from a regular cursor?
7. Can you use PL/SQL programs to handle transaction management? If yes, elaborate on how it is
done.
8. Discuss the importance of error handling and exception propagation in PL/SQL programs.
Course Title Database Management Systems ACADEMIC YEAR: 2023-24
Course Code(s) 22AD2102A Page 86 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 87 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Post Lab

Answer the following question before entering into lab. The following post lab task has to perform at home.
Problem Description:
1. Write a PL/SQL function that returns the level of customer based on credit limit in customer’s table
2. Write a PL/SQL procedure without parameter to get the count of records in the account table.
3. Write a PL/SQL procedure that returns the number of orders by order status from orders table?

TEST CASES:

Insert into customers values ('c001', 'mani', 40000);

Insert into customers values ('c002', 'manasa', 10000);

Insert into customers values ('c003', 'Reshmi', 6000);

Insert into customers values ('c004', 'Raji', 50000);

Insert into customers values ('c005', 'mani', 10000);

Insert into departments values ('d001', 'cse');

Insert into departments values ('d002', 'ECE');

Insert into departments values ('d003', 'IT');

Insert into departments values ('d004', 'EEE');

Insert into departments values ('d005', 'MECH');

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 88 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 89 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

9. Study & Implementation of Triggers & Cursors


Aim/Objective:
The main objectives of DBMS triggers and cursors are to enhance data integrity, enforce business rules,
provide security, facilitate data manipulation, enable iterative processing, and offer finer control over
transaction management and complex query processing within a database system.
Description:
DBMS triggers are special stored procedures that are automatically executed or fired in response to specific
events or actions occurring within a database. Triggers are associated with tables, and they can be defined
to execute either before or after specific database operations, such as INSERT, UPDATE, DELETE, or
even DDL (Data Definition Language) statements. DBMS cursors provide a way to retrieve and manipulate
data from a result set returned by a SQL query. Cursors allow you to iterate over the rows in a result set,
one row at a time, and perform operations or computations on each row individually.
Pre-Requisites:
This Section contains the list of Software/Tools or required knowledge (Glossary) to complete the task
under the Laboratory Session.
Pre Lab-Task
Answer the following question before entering into lab. The following pre lab task has to perform at home
1. What is the difference between a function and a stored procedure?

2. How do you declare a user-defined exception?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 90 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

3. What do you understand by explicit cursors?

4. What are the steps that need to be performed to use an explicit cursor? Discuss briefly.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 91 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

In Lab Task
Use the tables and data in Experiment– 5
1. Write a PL/SQL stored procedure to know the current age of customers who are
associated with AP transport department.
2. Write a PL/SQL stored function to know that, from how many years vehicles are
registered with the A.P transport department.
3. Create a trigger before insert to maintain the summary of Dealer Center table into Dealer
Center stats. Whenever the capacity of Dealer Centers is increased or decreased then the total
statistics should be reflected in Dealer Center stats
4. Create trigger after insert in members table, a trigger should check the value of attribute
name and if it is updated then show themes age for updating on name in reminder table.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 92 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 93 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Viva-Voce Questions (in-lab)


1. What is a DBMS trigger?
2. Explain the purpose and benefits of using triggers in a database.
3. Describe the difference between a BEFORE trigger and an AFTER trigger.
4. What is a DBMS cursor?
5. How does a cursor differ from a result set?
6. Explain the purpose of using a cursor in a database application.
Course Title Database Management Systems ACADEMIC YEAR: 2023-24
Course Code(s) 22AD2102A Page 94 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 95 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Post Lab

Answer the following question before entering into lab. The following post lab task has to perform at home.
Use the tables and data in Experiment– 6
1. Write PL/SQL program to display doctor appointment fee amount value.

2. Write PL/SQL program to delete appointment amount value 200

3. Write a PL/SQL program using functions to display the address details from where the number of

patients is more than 3.

4. Write a PL/SQL program using triggers to raise an exception on invalid patient ID

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 96 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 97 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

10.Aggregate Functions, Group by & Having Clauses and Set Operations


Aim/Objective:
The main aim of this experiment is to learn the DBMS aggregate functions ,group by and having clauses
and set operations.
Description:
Aggregate functions are built-in functions in a database management system (DBMS) that perform
calculations on sets of values and return a single result. They are commonly used to summarize or derive
useful information from a set of rows in a table or the result of a query. Some common aggregate functions
include SUM, AVG, COUNT, MAX, and MIN. The GROUP BY clause and the optional HAVING clause
are used together to further filter and aggregate data based on specific conditions in a SELECT statement.
Set operations in a DBMS allow you to combine the results of two or more queries into a single result set.
The common set operations are UNION, INTERSECT, and EXCEPT (or MINUS, depending on the
DBMS).
Pre-Requisites:
This Section contains the list of Software/Tools or required knowledge (Glossary) to complete the task
under the Laboratory Session.
Pre Lab-Task
Answer the following question before entering into lab. The following pre lab task has to perform at home

1. What is the difference between a function and a stored procedure?

2. How do you declare a user-defined exception?

3. What do you understand by explicit cursors?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 98 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

4. What are the steps that need to be performed to use an explicit cursor? Discuss briefly.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 99 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

In Lab Task
Employee Database an Enterprise wishes to maintain a database to automate its operations. Enterprise
is divided into certain departments and each department consists of employees. The following two
tables describes the automation schemas DEPT (DEPTNO, DNAME, LOC) EMP (EMPNO, ENAME,
JOB, MGR, HIREDATE, SAL, COMM, DEPTNO)
1. Update the employee salary by 15%, whose experience is greater than 10 years.
2. Delete the employees, who completed 30 years of service.
3. Display the manager who is having maximum number of employees working under him?
4. Create a view, which contain employee names and their manager

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 100 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Viva-Voce Questions (In-Lab):


1. What are aggregate functions in a DBMS?
2. Provide examples of commonly used aggregate functions and explain their purposes.
3. How do aggregate functions differ from regular scalar functions in a database?
4. Explain the purpose of the GROUP BY clause in a SELECT statement.
5. What happens if you include a column in the SELECT clause that is not listed in the GROUP BY
clause?
6. How does the GROUP BY clause affect the result set of a query?
7. Describe the purpose of set operations in a database.
8. What are the common set operations available in a DBMS? Provide examples.
Course Title Database Management Systems ACADEMIC YEAR: 2023-24
Course Code(s) 22AD2102A Page 101 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 102 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Post Lab Task

Answer the following question before entering into lab. The following post lab task has to perform at
home.
1. Create Sales table with the following fields (SALES NO, SALESNAME, BRANCH, SALES
AMOUNT, DOB)
2. Insert at least 10 record sin to every table that is implemented in the case study
3. Calculate total Sales Amount in each branch
4. Calculate average Sales Amount in each branch.
5. Display all the salesmen, DOB who are born in the month of December as day in
character format i.e., 21-Dec-09
6. Display the name and DOB of salesman in alphabetical order of the month.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 103 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 104 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

11.Implement Correlated Nested, Views, Indices and DCL Commands


Aim/Objective:
The aims of correlated nested queries, views, indices, and DCL commands are to enhance data retrieval, simplify
query construction, improve query performance, provide data abstraction and security, ensure data integrity, and
enable efficient database administration and access control.

Description:
Correlated nested queries, also known as correlated subqueries, are SQL queries in which the inner query
references values from the outer query. The inner query is executed for each row of the outer query, allowing for
dynamic and contextual data retrieval. correlated nested queries, views, indices, and DCL commands are important
components of a DBMS. They contribute to data retrieval, abstraction, performance optimization, security, data
integrity, and efficient database administration.

Pre-Requisites:
This Section contains the list of Software/Tools or required knowledge (Glossary) to complete the task under the
Laboratory Session.

Pre Lab-Task
Answer the following question before entering into lab. The following pre lab task has to perform at home

1. Discuss a bout GRANT, REVOKE and SYNONYM

2. Give the differences between AVERAGE and ROUND commands?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 105 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

3. What is the use of VIEW statement in SQL?

4. Discuss about any 5 aggregate functions.

5. What do you mean by a nested query in SQL?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 106 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

In Lab Task
Use the tables and data in Experiment – 5, In-Lab section and work on the following queries

1. Display the list of customers available in a branch.


2. Create a PostgreSQL query to know the older of all the customers
3. Write PostgreSQL query to calculate the total amount generated by giving contract permission
for amount per seat
4. Create a query to display all the type of vehicles present
5. Write PostgreSQL query to display all the cities present in a given state.
6. Display the number of vehicles of customers who are not having photo identity.
7. Write PostgreSQL statement to search for vehicle type which is having the vehicle id as the
smallest number.
8. Create a PostgreSQL query to know the branch name and phone number of a customer who is
having licenseperiod of 2 years.
9. Display the vehicle details for which maximum amount is paid per seat for contract permission.
10. Write Co-related nested subquery to know the customer name, phone number, city whose
branch name is‘Madhapur’
11. Create a view “Present_Customer” with customer name, phone number, state and city of
customer anddisplay the view.
12. Write PostgreSQL query to show indexes on customer table.
13. Create a query to display the count of dealers from “Andhra Pradesh”
14. Display the number of cities in each state Drop the view “Present Customer

15. Drop the view “Present Customer”

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 107 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 108 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Viva-voce Questions (In-Lab):


1. What is a correlated nested query, and how does it differ from a regular subquery?
2. Explain the purpose and benefits of using correlated nested queries in SQL.
3. Can you provide an example of a correlated nested query and explain how it works?
4. What is an index in a DBMS, and what is its purpose?
5. Explain the benefits of using indices in a database system.
6. What is the purpose of DCL commands in a database system?
7. Explain the difference between the GRANT and REVOKE commands.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 109 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 110 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Post Lab Task

Answer the following question before entering into lab. The following post lab task has to perform at home.
CONSIDER THE FOLLOWING SCHEMA: SAILORS (SID, SNAME, RATING, AGE) BOATS (BID, BNAME,
COLOR) RESERVES (SID, BID, DAY(DATE))

1. Find the names of the sailors who have reserved both a red or a yellow boat
2. Find all SIDs of sailors who have a rating of 10 or have reserved boat 111.
3. Find the names of sailors who have reserved a red boat, and list in the order of age
4. Find the names of sailors who have reserved boat 103.
5. Find the name and the age of the youngest sailor.
6. Find the ids and names of sailors who have reserved two different boats on the same day

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 111 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 112 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

12.Implementation of Transaction in SQL Server

Aim/Objective:
The aim of implementing transactions in SQL Server is to ensure the atomicity, consistency, isolation,
and durability (ACID) properties of database operations.
Description:
Transactions in SQL Server provide a mechanism to group multiple database operations into a single
logical unit, ensuring that they are executed as a whole or not at all. Transactions ensure the atomicity,
consistency, isolation, and durability (ACID) properties of database operations. In SQL Server,
transactions are managed using the BEGIN TRANSACTION, COMMIT, and ROLLBACK statements.
Pre-Requisites:
This Section contains the list of Software/Tools or required knowledge (Glossary) to complete the task
under the Laboratory Session.
Pre Lab-Task
Answer the following question before entering into lab. The following pre lab task has to perform at
home.
1. What are Transactions?

2. Explain ACID properties?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 113 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

3. What is concurrency control?

4. Draw the transaction state diagram

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 114 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

In Lab Task
Implementation of Transaction in SQL Server
Student Data:
REGNO NAME ADDRESS PHONE AGE
101 SAI VIJAYAWADA 9455123451 18
102 TEJA GUNTUR 9652431543 18
103 DINESH DELHI 9156253131 20
104 TAURN CHENNAI 9156768971 18
103 DINESH DELHI 9156253131 20
102 TEJA GUNTUR 9652431543 18

Execute the following queries:

✓ Delete those records from the table which have age = 20 and then ROLLBACK the changes in the
database.
✓ Write the SQL queries delete those records from the table which have age = 20 and then COMMIT
the changes in the database.
✓ Delete those records from the table which have age = 18 and then COMMIT the changes and then
try to use ROLLBACK to the previous save point. What you observed at this stage?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 115 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Viva-voce Questions (In-Lab)


1. What is a transaction in SQL Server, and why is it important?
2. Explain the ACID properties of transactions in SQL Server.
3. How do you start a transaction in SQL Server? Provide an example.
4. What is the purpose of the COMMIT statement in a transaction?
5. How does the ROLLBACK statement work in a transaction? When would you use it?
Course Title Database Management Systems ACADEMIC YEAR: 2023-24
Course Code(s) 22AD2102A Page 116 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 117 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Post Lab Task

Answer the following question before entering into lab. The following post lab task has to perform at home.
1. Consider a simple checkpointing protocol and the following set of operations in the log. (start, T4);
(write, T4, y, 2, 3); (start, T1); (commit, T4); (write, T1, z, 5, 7); (checkpoint); (start, T2); (write,
T2, x, 1, 9); (commit, T2); (start, T3), (write, T3, z, 7, 2); If a crash happens now the system tries to
recover using both undo and redo operations, what are the contents of the undo list and the redo list.
(A) Undo: T3, T1; Redo: T2 (B) Undo: T3, T1; Redo: T2, T4 (C) Undo: none; Redo; T2, T4, T3, T1
(D) Undo: T3, T1, T4; Redo: T2
2. Consider the following transaction involving two bank accounts x and y. read(x); x: = x–50;
write(x); read(y); y: =y+50; write(y) The constraint that the sum of the accounts x and y should
remain constant is that of (A) Atomicity (B) Consistency (C) Isolation (D) Durability

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 118 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 119 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

13.MongoDB installation and configuration in windows

Aim/Objective:
The aim of this experiment is to install the Mongodb software in windows/Linux/Macos operating
system
Description:
MongoDB is the most popular NoSQL database, is an open-source document-oriented database. The
term ‘NoSQL’ means ‘non-relational’. It means that MongoDB isn’t based on the table-like relational
database structure but provides an altogether different mechanism for storage and retrieval of data. This
format of storage is called BSON. MongoDB was designed to work with commodity servers. Now it is
used by the company of all sizes, across all industry.
In this experiment, we will provide the sequence of steps for installing of the Mongodb software in
windows/Linux/Macos.
Pre-Requisites:
This Section contains the list of steps or required knowledge (Glossary) to complete the task under the
Laboratory Session. Before Learning MongoDB, the students must have the basic knowledge of
SQL& OOP's.
Pre Lab-Task
Answer the following question before entering into lab. The following pre lab task has to perform at
home.

1. What type of database is MongoDB?

2. What does ACID stand for in the context of databases, and is MongoDB ACID-compliant?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 120 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

3. What is the primary language used for interacting with MongoDB?

4. What is a document database?

5. What is the maximum size for a MongoDB document?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 121 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

In-lab: MongoDB Installation on Windows

Objective: To install MongoDB on a Windows machine and verify the installation.

Materials:

• Windows operating system (Windows 7/8/10)


• Internet connection
• MongoDB installation package (downloaded from the official MongoDB website)

Procedure:

1. Download the MongoDB installation package from the official MongoDB website
(https://www.mongodb.com/try/download/community).
2. Locate the downloaded installation package and run the installer.
3. Choose the setup type (Complete or Custom) based on your preference.
4. Accept the license agreement and click "Next."
5. Choose the destination folder where MongoDB will be installed or leave it as the default location.
Click "Next."
6. Select the components you want to install (MongoDB Server, MongoDB Compass, etc.). Click
"Next."
7. Configure the MongoDB service by choosing either "Run service as Network Service user" or "Run
service as a local or domain user." Click "Next."
8. Configure the MongoDB data directory by specifying the path where the database files will be
stored. Click "Next."
9. Choose whether to install MongoDB as a Windows service or not. Click "Next."
10. Review the installation summary and click "Install" to start the installation process.
11. Wait for the installation to complete. Once finished, click "Finish."
12. Open the command prompt or PowerShell as an administrator.
13. Navigate to the MongoDB installation directory (e.g., C:\Program
Files\MongoDB\Server\{version}\bin).
14. Run the mongod command to start the MongoDB server.
15. Open another command prompt or PowerShell as an administrator.
16. Navigate to the MongoDB installation directory.
17. Run the mongo command to start the MongoDB shell.
18. Verify the installation by executing MongoDB commands in the shell (e.g., db.version() to check
the MongoDB version).

Observations:

• The installation process completes successfully.


• The MongoDB server starts without any errors.
• The MongoDB shell opens, and MongoDB commands can be executed.
• The MongoDB version is displayed correctly.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 122 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 123 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Sample VIVA-VOCE Questions (In-Lab):


1. What is MongoDB, and why is it used?
2. What are the system requirements for installing MongoDB on a Windows system?
3. What are the different installation options available for MongoDB on Windows?
4. Can MongoDB be installed on a different drive or directory? If yes, how would you do it?
5. What is the purpose of adding the MongoDB bin directory to the system's PATH variable during
installation?
Course Title Database Management Systems ACADEMIC YEAR: 2023-24
Course Code(s) 22AD2102A Page 124 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 125 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Post Lab Task

The following post lab task has to perform at home.

MongoDB Configuration on Windows

Objective: To configure MongoDB on a Windows machine by modifying the configuration file.

Materials:

• MongoDB installation on a Windows machine (completed in the previous in-lab experiment)

Procedure:

1. Locate the MongoDB configuration file named mongod.cfg. By default, it is located in the
C:\Program Files\MongoDB\Server\{version}\bin directory.
2. Open the mongod.cfg file using a text editor.
3. Modify the configuration options based on your requirements. For example:
o Change the port option to specify a different port number (default: 27017).
o Modify the bindIp option to listen on a specific IP address or bind to all available IP
addresses.
o Configure the storage options to specify a different data directory or enable journaling.
o Customize other options such as logpath, logappend, etc., as needed.
4. Save the changes to the mongod.cfg file.
5. Restart the MongoDB server by stopping the existing instance and starting it again.
6. Open the command prompt or PowerShell as an administrator.
7. Navigate to the MongoDB installation directory.
8. Run the mongod command to start the MongoDB server.
9. Open another command prompt or PowerShell as an administrator.
10. Navigate to the MongoDB installation directory.
11. Run the mongo command to start the MongoDB shell.
12. Verify the configuration changes by executing MongoDB commands and checking the updated
settings (e.g., db.serverCmdLineOpts() to view the server command line options).

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 126 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 127 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

14.Create and Drop Database in MongoDB

Aim/Objective:
The aim of this experiment is to creation of database and dropping of that created database.
Description:
In this experiment, we will create a database in mongodb by using the commands in the mongodb shell.
Pre-Requisites:
This Section contains the list of Software/Tools or required knowledge (Glossary) to complete the task
under the Laboratory Session.
Pre Lab-Task
Answer the following question before entering into lab. The following pre lab task has to perform at home.

1. What is the purpose of a replica set in MongoDB?

2. What is the difference between a document database and a relational database?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 128 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

3. What is the syntax for inserting a document in MongoDB?

4. What is the syntax for updating a document in MongoDB?

5. What is the syntax for deleting a document in MongoDB?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 129 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

In-lab: Create and Drop Database in MongoDB

Objective: To create and drop a database in MongoDB using the MongoDB shell.

Materials:

MongoDB installed and running (follow the installation steps mentioned earlier)

Procedure:

1. Open the command prompt or PowerShell as an administrator.


2. Navigate to the MongoDB installation directory.
3. Run the mongo command to start the MongoDB shell.
4. By default, the shell connects to the test database. To switch to a different database or create a new
one, use the use command. For example, to create a database named mydatabase, enter the
following command:
use mydatabase
5. The shell will output switched to db mydatabase to confirm the database switch.
6. To verify the current database, execute the db command without any arguments. It will display the
current database name.
7. Perform database operations such as creating collections, inserting documents, etc., in the current
database.

To Drop a Database:

1. To drop a database, ensure that you are connected to the correct database in the MongoDB shell.
2. Execute the db.dropDatabase() command to drop the currently selected database.
3. The shell will display a confirmation message indicating the database has been dropped.

Observations:

• The database creation command (use) switches to the specified database successfully.
• The current database name is displayed correctly.
• Collections and documents can be created and manipulated within the database.
• The db.dropDatabase() command successfully deletes the database.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 130 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Sample VIVA-VOCE Questions (In-Lab):


1. What is the command to switch to a specific database in the MongoDB shell?
2. What happens when you switch to a non-existing database in MongoDB?
3. How can you back up a MongoDB database before deleting it?
4. Are there any restrictions or limitations when naming a database in MongoDB?
5. How do you check if a database exists in MongoDB?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 131 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 132 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Post Lab Task

The following post lab task has to perform at home.

Create and Drop Database using a MongoDB Driver

Objective: To create and drop a database in MongoDB using a MongoDB driver (e.g., Python).

Materials:

• MongoDB installed and running (follow the installation steps mentioned earlier)
• MongoDB driver for your programming language (e.g., pymongo for Python)

Procedure:

1. Install the MongoDB driver for your chosen programming language (e.g., pymongo for Python).
2. Open a text editor or IDE and create a new script file.
3. Import the required MongoDB driver module in your script.
4. Establish a connection to the MongoDB server using the driver's connection methods.
5. To create a database, use the driver's appropriate method (e.g., client.list_database_names()
in pymongo).
6. Verify the successful creation of the database by checking if it appears in the list of available
databases.
7. Perform database operations such as creating collections, inserting documents, etc., using the
driver's methods.

To Drop a Database:

1. To drop a database, ensure that you are connected to the MongoDB server using the driver.
2. Use the appropriate method provided by the driver to drop the database (e.g.,
client.drop_database() in pymongo).
3. Verify the database deletion by checking if it is no longer listed in the available databases.

Observations:

• The script connects to the MongoDB server successfully.


• The database creation method creates the database without errors.
• The created database appears in the list of available databases.
• Database operations such as creating collections and inserting documents can be performed.
• The database deletion method successfully drops the database.
• The deleted database is no longer listed in the available databases.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 133 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 134 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

15.Creating the Collection and Drop the collection using MongoDB

Aim/Objective:
The aim of this experiment is to creation of collection and dropping of collection in Mongodb.

Description:
Creating a collection in MongoDB involves defining a logical container to store related documents. A collection is
analogous to a table in a relational database and provides a structure for organizing and storing data. When
creating a collection, we specify a name for the collection and may also define indexes or additional configuration
options. Deleting a collection in MongoDB refers to the removal of an entire collection and all its associated
documents. This operation permanently deletes the collection and its data, so it should be performed with caution.
Deleting a collection is irreversible, and the data cannot be recovered once the deletion is complete.

Pre-Requisites:
This Section contains the list of Software/Tools or required knowledge (Glossary) to complete the task
under the Laboratory Session.
Pre Lab-Task
Answer the following question before entering into lab. The following pre lab task has to perform at home.

1. What is the difference between find() and findOne() in MongoDB?

2. What is the $eq operator used for in MongoDB queries?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 135 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

3. What is the purpose of the $in operator in MongoDB queries?

4. What is the difference between the $and and $or operators in MongoDB queries?

5. What is the default write concern in MongoDB?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 136 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

In-lab: Create and Drop Collection in MongoDB

Objective: To create and drop a collection in MongoDB using the MongoDB shell.
Materials:
• MongoDB installed and running (follow the installation steps mentioned earlier)
Procedure:
1. Open the command prompt or PowerShell as an administrator.
2. Navigate to the MongoDB installation directory.
3. Run the mongo command to start the MongoDB shell.
4. By default, the shell connects to the test database. To switch to a different database or create a new
one, use the use command. For example, to switch to a database named mydatabase, enter the
following command:
use mydatabase
5. The shell will output switched to db mydatabase to confirm the database switch.
6. To create a collection, use the db.createCollection() command. Specify the collection name as
an argument. For example, to create a collection named mycollection, enter the following
command:

db.createCollection("mycollection")
The shell will output { "ok" : 1 } to indicate that the collection has been created
6. To verify the creation of the collection, use the db.getCollectionNames() command to retrieve a
list of collections in the current database.
7. Perform collection operations such as inserting documents, querying, updating, etc., in the current
database and collection.
To Drop a Collection:
1. To drop a collection, ensure that you are connected to the correct database in the MongoDB shell.
2. Execute the db.collectionName.drop() command, where collectionName is the name of the
collection you want to drop. For example, to drop the mycollection collection, enter the following
command:
db.mycollection.drop()
The shell will output { "ok" : 1 } to indicate that the collection has been dropped.
Observations:
• The collection creation command (db.createCollection()) creates the collection successfully.
• The db.getCollectionNames() command lists the created collection.
• Operations such as inserting documents, querying, updating, etc., can be performed in the
collection.
• The collection drop command (db.collectionName.drop()) successfully deletes the collection.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 137 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Sample VIVA-VOCE Questions (In-Lab):


1. What is a collection in MongoDB?
2. Is it possible to rename a collection in MongoDB? If yes, how would you do it?
3. How do you verify if a collection exists in MongoDB?
4. What is the command to delete a collection in MongoDB using the MongoDB shell?
5. Are there any precautions to consider before deleting a collection?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 138 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Post Lab Task

The following post lab task has to perform at home.

Create and Drop Collection using a MongoDB Driver

Objective: To create and drop a collection in MongoDB using a MongoDB driver (e.g., pymongo for
Python).

Materials:

• MongoDB installed and running (follow the installation steps mentioned earlier)
• MongoDB driver for your programming language (e.g., pymongo for Python)

Procedure:

1. Install the MongoDB driver for your chosen programming language (e.g., pymongo for Python).
2. Open a text editor or IDE and create a new script file.
3. Import the required MongoDB driver module in your script.
4. Establish a connection to the MongoDB server using the driver's connection methods.
5. To create a collection, use the appropriate method provided by the driver (e.g.,
db.create_collection() in pymongo).
6. Verify the successful creation of the collection by checking if it appears in the list of collections in
the current database.
7. Perform collection operations such as inserting documents, querying, updating, etc., using the
driver's methods.

To Drop a Collection:

1. To drop a collection, ensure that you are connected to the MongoDB server using the driver.
2. Use the appropriate method provided by the driver to drop the collection (e.g.,
db.collection_name.drop() in pymongo).
3. Verify the collection deletion by checking if it is no longer listed in the collections of the current
database.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 139 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 140 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

16.Insert Document and Query Document in MongoDB collection

Aim/Objective:
The aim of this experiment is to Inserting a document in a collection and querying the document in
Mongodb.
Description:
Inserting a document in a MongoDB collection involves adding a new record or document that conforms to
the collection's schema or structure. A document in MongoDB is represented in JSON-like format,
consisting of key-value pairs. Querying documents in a MongoDB collection involves retrieving specific
data that matches certain criteria from the collection. MongoDB provides a flexible and powerful querying
mechanism that allows us to find documents based on various conditions, such as matching field values,
using comparison operators, logical operators, or regular expressions.
Pre-Requisites:
This Section contains the list of Software/Tools or required knowledge (Glossary) to complete the task
under the Laboratory Session.
Pre Lab-Task
Answer the following question before entering into lab. The following pre lab task has to perform at home.

1. What is the purpose of the $sort operator in MongoDB?

2. What is the use of the $limit operator in MongoDB?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 141 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

3. What is a capped collection in MongoDB?

4. What is the purpose of the $unwind operator in MongoDB aggregation?

5. What is the purpose of the $group operator in MongoDB aggregation?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 142 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

In-lab: Insert and Query Documents in MongoDB Collection

Objective: To insert documents into a MongoDB collection and perform query operations using the
MongoDB shell.

Materials:

• MongoDB installed and running (follow the installation steps mentioned earlier)

Procedure:

1. Open the command prompt or PowerShell as an administrator.


2. Navigate to the MongoDB installation directory.
3. Run the mongo command to start the MongoDB shell.
4. By default, the shell connects to the test database. To switch to a different database or create a new
one, use the use command. For example, to switch to a database named mydatabase, enter the
following command:

use mydatabase
5. The shell will output switched to db mydatabase to confirm the database switch.
6. To insert documents into a collection, use the db.collectionName.insertOne() or
db.collectionName.insertMany() command, depending on whether you want to insert a single
document or multiple documents. Replace collectionName with the actual name of the collection.
For example, to insert a document into a collection named mycollection, enter the following
command:

db.mycollection.insertOne({ "name": "John", "age": 30 })


This command inserts a document with the fields "name" and "age" into the collection.

7. To verify the successful insertion of documents, use the db.collectionName.find() command to


retrieve all documents in the collection. For example, to query all documents in the mycollection
collection, enter the following command:
db.mycollection.find()

The shell will display the documents stored in the collection.

Perform query operations such as filtering, sorting, and projection using the appropriate query
operators in the find() command.

Observations:

• The database and collection are created successfully.


• Documents can be inserted into the collection using the insertOne() or insertMany() command.
• The find() command retrieves the inserted documents from the collection.
• Query operations such as filtering, sorting, and projection can be performed on the collection.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 143 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Sample VIVA-VOCE Questions (In-Lab):


1. How do you insert a single document into a MongoDB collection?
2. Explain the difference between the insertOne() and insertMany() methods in MongoDB.
3. What happens if the _id field is not provided while inserting a document?
4. Can you insert documents with different schemas into the same collection in MongoDB?
5. How can you ensure the uniqueness of documents based on a specific field during insertion?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 144 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 145 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Post Lab Task

The following post lab task has to perform at home.

Experiment: Insert and Query Documents in MongoDB Collection using a MongoDB Driver

Objective: To insert documents into a MongoDB collection and perform query operations using a
MongoDB driver (e.g., pymongo for Python).

Materials:

• MongoDB installed and running (follow the installation steps mentioned earlier)
• MongoDB driver for your programming language (e.g., pymongo for Python)

Procedure:

1. Install the MongoDB driver for your chosen programming language (e.g., pymongo for Python).
2. Open a text editor or IDE and create a new script file.
3. Import the required MongoDB driver module in your script.
4. Establish a connection to the MongoDB server using the driver's connection methods.
5. Switch to the desired database using the driver's methods (e.g., client.get_database() in
pymongo).
6. To insert documents into a collection, use the appropriate method provided by the driver (e.g.,
db.collection_name.insert_one() or db.collection_name.insert_many() in pymongo).
7. Verify the successful insertion of documents.
8. Perform query operations using the driver's methods to retrieve documents from the collection.
9. Use query operators and filters to refine the query results.

Observations:

• The script connects to the MongoDB server successfully.


• Documents can be inserted into the collection using the appropriate methods provided by the driver.
• The inserted documents can be queried using the driver's methods.
• Query operations such as filtering, sorting, and projection can be performed on the collection using
the driver's methods.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 146 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 147 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

17.Update and delete document in MongoDB collection

Aim/Objective:
The aim of this experiment is to perform the tasks of updating and deleting the documents in MongoDB.
Description:
Updating documents in a MongoDB collection involves modifying existing data within a document or
multiple documents. MongoDB provides powerful update operators that allow us to modify specific fields
or entire documents based on specified criteria. Deleting documents in a MongoDB collection involves
removing one or more documents based on specific criteria. MongoDB offers the deleteOne() and
deleteMany() methods for deleting documents.
Pre-Requisites:
This Section contains the list of Software/Tools or required knowledge (Glossary) to complete the task
under the Laboratory Session.
Pre Lab-Task
Answer the following question before entering into lab. The following pre lab task has to perform at home.

1. What is the role of the oplog in MongoDB?

2. What is a covered query in MongoDB?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 148 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

3. What is the purpose of the $text operator in MongoDB queries?

4. What is the purpose of the $lookup operator in MongoDB?

5. What is the difference between a single-field index and a compound index in MongoDB?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 149 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

In-lab: Update and Delete Documents in MongoDB Collection

Objective: To update and delete documents in a MongoDB collection using the MongoDB shell.
Materials:
• MongoDB installed and running (follow the installation steps mentioned earlier)
Procedure:

1. Open the command prompt or PowerShell as an administrator.


2. Navigate to the MongoDB installation directory.
3. Run the mongo command to start the MongoDB shell.
4. By default, the shell connects to the test database. To switch to a different database or create a new
one, use the use command. For example, to switch to a database named mydatabase, enter the
following command

use mydatabase
5. The shell will output switched to db mydatabase to confirm the database switch.
6. To update documents in a collection, use the db.collectionName.updateOne() or
db.collectionName.updateMany() command, depending on whether you want to update a single
document or multiple documents. Replace collectionName with the actual name of the collection.
For example, to update a document in a collection named mycollection where the "name" field is
"John", enter the following command:
db.mycollection.updateOne({ "name": "John" }, { $set: { "age": 31 } })

This command updates the "age" field of the document matching the query.
7. To verify the successful update of documents, use the db.collectionName.find() command to
retrieve the updated documents in the collection.
8. To delete documents from a collection, use the db.collectionName.deleteOne() or
db.collectionName.deleteMany() command, depending on whether you want to delete a single
document or multiple documents. Replace collectionName with the actual name of the collection.
For example, to delete a document in a collection named mycollection where the "name" field is
"John", enter the following command:
db.mycollection.deleteOne({ "name": "John" })

This command deletes the document matching the query.

To verify the successful deletion of documents, use the db.collectionName.find() command to


retrieve the remaining documents in the collection.

Observations:
• The database and collection are created successfully.
• Documents can be updated in the collection using the updateOne() or updateMany()
• The find() command retrieves the updated documents from the collection.
• Documents can be deleted from the collection using the deleteOne() or deleteMany() command.
• The find() command after deletion displays the remaining documents in the collection.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 150 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Sample VIVA-VOCE Questions (In-Lab):


1. Explain the difference between the updateOne() and updateMany() methods in MongoDB.
2. What are some common update operators in MongoDB, and how are they used?
3. How can you increment a numeric field in a document using an update operator?
4. Can you delete multiple documents using a single delete operation? If yes, provide an example.
5. What happens if the filter criteria in a delete operation match multiple document?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 151 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 152 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Post Lab Task

The following post lab task has to perform at home.

Update and Delete Documents in MongoDB Collection using a MongoDB Driver

Objective: To update and delete documents in a MongoDB collection using a MongoDB driver (e.g.,
pymongo for Python).

Materials:

• MongoDB installed and running (follow the installation steps mentioned earlier)
• MongoDB driver for your programming language (e.g., pymongo for Python)

Procedure:

1. Install the MongoDB driver for your chosen programming language (e.g., pymongo for Python).
2. Open a text editor or IDE and create a new script file.
3. Import the required MongoDB driver module in your script.
4. Establish a connection to the MongoDB server using the driver's connection methods.
5. Switch to the desired database using the driver's methods (e.g., client.get_database() in
pymongo).
6. To update documents in a collection, use the appropriate method provided by the driver (e.g.,
db.collection_name.update_one() or db.collection_name.update_many() in pymongo).
7. Verify the successful update of documents.
8. To delete documents from a collection, use the appropriate method provided by the driver (e.g.,
db.collection_name.delete_one() or db.collection_name.delete_many() in pymongo).
9. Verify the successful deletion of documents.

Observations:

• The script connects to the MongoDB server successfully.


• Documents can be updated in the collection using the appropriate methods provided by the driver.
• The updated documents can be verified by querying the collection using the driver's methods.
• Documents can be deleted from the collection using the appropriate methods provided by the driver.
• The deletion of documents can be verified by querying the collection again and confirming that the
deleted documents are no longer present.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 153 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 154 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

18.MongoDB Projection

Aim/Objective:
The aim of this experiment is to control and shape the data returned in query results by specifying which
fields to include or exclude from the result set.
Description:
MongoDB projection is a feature that allows developers to control the fields returned in query results,
shaping the structure and content of the retrieved documents. It provides a mechanism to include or exclude
specific fields from the result set, helping optimize performance and reduce unnecessary data transfer.
MongoDB projection plays a crucial role in optimizing query performance, reducing network overhead,
and tailoring the structure of query results to meet specific application requirements. By carefully defining
the projected fields, developers can streamline data retrieval and improve overall application efficiency.
Pre-Requisites:
This Section contains the list of Software/Tools or required knowledge to complete the task under the
Laboratory Session.
Pre Lab-Task
Answer the following question before entering into lab. The following pre lab task has to perform at home.

1. What is the purpose of the $push operator in MongoDB updates?

2. What is the purpose of the $addToSet operator in MongoDB updates?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 155 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

3. What is the purpose of the $regex operator in MongoDB queries?

4. What is the difference between a shard key and a shard tag in MongoDB?

5. What is the purpose of the $sample operator in MongoDB aggregation?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 156 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

In-lab:

MongoDB Projection

Objective: To perform projection operations in MongoDB, selecting specific fields to include or exclude
from query results.

Materials:

• MongoDB installed and running (follow the installation steps mentioned earlier)

Procedure:

1. Open the command prompt or PowerShell as an administrator.


2. Navigate to the MongoDB installation directory.
3. Run the mongo command to start the MongoDB shell.
4. By default, the shell connects to the test database. To switch to a different database or create a new
one, use the use command. For example, to switch to a database named mydatabase, enter the
following command:

use mydatabase
5. The shell will output switched to db mydatabase to confirm the database switch.
6. To query documents from a collection with projection, use the db.collectionName.find()
command with the projection parameter. Replace collectionName with the actual name of the
collection. For example, to query documents from a collection named mycollection and include
only the "name" and "age" fields in the result, enter the following command:
db.mycollection.find({}, { "name": 1, "age": 1 })

The { "name": 1, "age": 1 } object specifies the fields to include in the result. Fields set to 1
are included, while fields set to 0 are excluded.

Perform various projection operations by specifying different fields and their inclusion or exclusion.

Observations:

• The database and collection are created successfully.


• Documents can be queried from the collection with projection using the find() command.
• Projection allows selecting specific fields to include or exclude from the query results.
• Different projection operations can be performed by specifying different fields and their inclusion
or exclusion.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 157 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Sample VIVA-VOCE Questions (In-Lab):


1. What is the purpose of MongoDB projection?
2. How does projection help optimize query performance in MongoDB?
3. What are the two main ways to use projection in MongoDB to shape query results?
4. Can you provide an example of field inclusion in MongoDB projection?
5. How does field exclusion in projection help protect sensitive data in query results?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 158 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 159 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Post Lab Task

The following post lab task has to perform at home.

MongoDB Projection using a MongoDB Driver

Objective: To perform projection operations in MongoDB using a MongoDB driver (e.g., pymongo for
Python).

Materials:

• MongoDB installed and running (follow the installation steps mentioned earlier)
• MongoDB driver for your programming language (e.g., pymongo for Python)

Procedure:

1. Install the MongoDB driver for your chosen programming language (e.g., pymongo for Python).
2. Open a text editor or IDE and create a new script file.
3. Import the required MongoDB driver module in your script.
4. Establish a connection to the MongoDB server using the driver's connection methods.
5. Switch to the desired database using the driver's methods (e.g., client.get_database() in
pymongo).
6. To query documents from a collection with projection, use the appropriate method provided by the
driver (e.g., db.collection_name.find({}, projection) in pymongo).
7. Specify the projection parameter as a dictionary or object containing the fields to include or exclude
from the result. For example, to include only the "name" and "age" fields, use the following code:

projection = { "name": 1, "age": 1 }


cursor = db.collection_name.find({}, projection)

Iterate through the cursor object to retrieve and process the query results.

Perform various projection operations by specifying different fields and their inclusion or exclusion.

Observations:

• The script connects to the MongoDB server successfully.


• Documents can be queried from the collection with projection using the appropriate method
provided by the driver.
• Projection allows selecting specific fields to include or exclude from the query results.
• Different projection operations can be performed by specifying different fields and their inclusion
or exclusion.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 160 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 161 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

19.MongoDB indexing

Aim/Objective:
The aim of this experiment is to improve query performance and data retrieval efficiency by creating data
structures that allow for faster search and retrieval of information. Indexing enables MongoDB to locate
and retrieve specific documents more efficiently, reducing the need to scan the entire collection.
Description:

Indexing in MongoDB is a mechanism that enhances query performance and data retrieval efficiency. It
involves creating data structures, called indexes, that provide a way to access and retrieve specific
information from a MongoDB collection quickly.

When indexing is applied to a field or a combination of fields, MongoDB creates a separate data structure
that organizes the indexed field(s) in a sorted manner. This structure, known as the index, contains
references to the actual documents in the collection.

Pre-Requisites:
This Section contains the list of Software/Tools or required knowledge (Glossary) to complete the task
under the Laboratory Session.
Pre Lab-Task
Answer the following question before entering into lab. The following pre lab task has to perform at home.

1. What is the role of the WiredTiger storage engine in MongoDB?

2. What is the purpose of the $graphLookup operator in MongoDB aggregation?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 162 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

3. What is the difference between a TTL index and a regular index in MongoDB?

4. What is the purpose of the $replaceRoot operator in MongoDB aggregation?

5. What is the role of the mongodump command in MongoDB?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 163 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

In-lab:

MongoDB Indexing

Objective: To create and use indexes in MongoDB for improved query performance.

Materials:

• MongoDB installed and running (follow the installation steps mentioned earlier)

Procedure:

1. Open the command prompt or PowerShell as an administrator.


2. Navigate to the MongoDB installation directory.
3. Run the mongo command to start the MongoDB shell.
4. By default, the shell connects to the test database. To switch to a different database or create a new
one, use the use command. For example, to switch to a database named mydatabase, enter the
following command:

use mydatabase
5. The shell will output switched to db mydatabase to confirm the database switch.
6. Identify the collection on which you want to create an index. For example, consider a collection
named mycollection.
7. To create an index on a specific field, use the db.collectionName.createIndex() command.
Replace collectionName with the actual name of the collection and fieldName with the name of the
field to index. For example, to create an index on the "name" field, enter the following command:
db.mycollection.createIndex({ "name": 1 })

This command creates a ascending index on the "name" field. You can specify -1 for a descending
index.

Once the index is created, perform query operations on the collection and observe the improved query
performance.

Optionally, you can use the db.collectionName.getIndexes() command to view the list of indexes
created on a collection.

Observations:

• The database and collection are created successfully.


• Indexes can be created on specific fields using the createIndex() command.
• Indexing improves query performance by optimizing the search process.
• The created index can be observed using the getIndexes() command.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 164 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Sample VIVA-VOCE Questions (In-Lab):


1. What is the purpose of indexing in MongoDB?
2. How does indexing improve query performance in MongoDB?
3. Explain the concept of an index in MongoDB.
4. What are the benefits of creating indexes on frequently queried fields?
5. Can you create indexes on multiple fields in MongoDB? If yes, how?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 165 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Post Lab Task

The following post lab task has to perform at home.

MongoDB Indexing using a MongoDB Driver

Objective: To create and use indexes in MongoDB for improved query performance using a MongoDB
driver (e.g., pymongo for Python).

Materials:

• MongoDB installed and running (follow the installation steps mentioned earlier)
• MongoDB driver for your programming language (e.g., pymongo for Python)

Procedure:

1. Install the MongoDB driver for your chosen programming language (e.g., pymongo for Python).
2. Open a text editor or IDE and create a new script file.
3. Import the required MongoDB driver module in your script.
4. Establish a connection to the MongoDB server using the driver's connection methods.
5. Switch to the desired database using the driver's methods (e.g., client.get_database() in
pymongo).
6. Identify the collection on which you want to create an index. For example, consider a collection
named mycollection.
7. To create an index on a specific field, use the appropriate method provided by the driver (e.g.,
db.collection_name.create_index() in pymongo). For example, to create an index on the
"name" field, use the following code:

db.collection_name.create_index([("name", pymongo.ASCENDING)])

This code creates an ascending index on the "name" field. You can use pymongo.DESCENDING for a
descending index.
8. Once the index is created, perform query operations on the collection and observe the improved
query performance.
9. Optionally, you can use the appropriate method provided by the driver (e.g.,
db.collection_name.index_information() in pymongo) to view the list of indexes created on a
collection.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 166 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 167 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

20.Aggregations operations in MongoDB

Aim/Objective:
The aim of this experiment is to provide a powerful and flexible framework for performing complex data
processing and analysis tasks on collections. Aggregation operations allow for the transformation,
grouping, filtering, and computation of data, enabling developers to derive meaningful insights from their
MongoDB data.
Description:
Aggregation operations in MongoDB provide a powerful framework for performing complex data
processing and analysis tasks on collections. These operations allow developers to derive meaningful
insights from their MongoDB data by transforming, grouping, filtering, and computing data in a flexible
and efficient manner.
Pre-Requisites:
This Section contains the list of Software/Tools or required knowledge to complete the task under the
Laboratory Session.
Pre Lab-Task
Answer the following question before entering into lab. The following pre lab task has to perform at home.

1. What is the purpose of the $redact operator in MongoDB aggregation?

2. What is the purpose of the $out operator in MongoDB aggregation?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 168 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

3. What is the role of the mongorestore command in MongoDB?

4. What is the purpose of the $lookup pipeline in MongoDB?

5. What is the role of the WiredTiger cache in MongoDB?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 169 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

In-lab:
Aggregation Operations in MongoDB
Objective: To perform aggregation operations in MongoDB using the MongoDB shell.
Materials:
• MongoDB installed and running (follow the installation steps mentioned earlier)
Procedure:
1. Open the command prompt or PowerShell as an administrator.
2. Navigate to the MongoDB installation directory.
3. Run the mongo command to start the MongoDB shell.
4. By default, the shell connects to the test database. To switch to a different database or create a new
one, use the use command. For example, to switch to a database named mydatabase, enter the
following command:
use mydatabase
5. The shell will output switched to db mydatabase to confirm the database switch.
6. Identify the collection on which you want to perform aggregation operations. For example, consider a
collection named mycollection.
7. Use the aggregation pipeline framework to perform complex data processing and analysis operations
on the collection. The aggregation pipeline consists of multiple stages, each representing a specific
operation.
8. Some common aggregation stages include:

• $match: Filters the documents in the collection based on specified criteria.


• $group: Groups the documents based on specified fields and performs aggregate functions on
grouped data.
• $project: Modifies the documents to include or exclude specific fields.
• $sort: Sorts the documents based on specified fields.
• $limit: Limits the number of documents returned in the result.
• $skip: Skips a specified number of documents in the result.

9. Combine multiple stages in the aggregation pipeline to perform complex operations. For example, to
group documents by the "category" field and calculate the average "price" for each category, you can
use the following pipeline:

db.mycollection.aggregate([
{ $group: { _id: "$category", averagePrice: { $avg: "$price" } } }
])

Experiment with different stages and combinations to perform various aggregation operations.

Observations:

• The database and collection are created successfully.


• Aggregation operations can be performed using the aggregation pipeline in MongoDB.
• Different stages in the pipeline allow for complex data processing and analysis.
• Each stage in the pipeline modifies the documents based on the specified operation.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 170 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 171 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Sample VIVA-OCE Questions (In-Lab):


1. What is the purpose of aggregation operations in MongoDB?
2. How do aggregation operations differ from regular query operations in MongoDB?
3. Explain the concept of the aggregation pipeline in MongoDB.
4. What are some common stage operators used in the aggregation pipeline?
5. How does the $match stage operator work in aggregation operations?

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 172 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 173 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Post Lab Task

The following post lab task has to perform at home.

Aggregation Operations in MongoDB using a MongoDB Driver

Objective: To perform aggregation operations in MongoDB using a MongoDB driver (e.g., pymongo for
Python).

Materials:

• MongoDB installed and running (follow the installation steps mentioned earlier)
• MongoDB driver for your programming language (e.g., pymongo for Python)

Procedure:

1. Install the MongoDB driver for your chosen programming language (e.g., pymongo for Python).
2. Open a text editor or IDE and create a new script file.
3. Import the required MongoDB driver module in your script.
4. Establish a connection to the MongoDB server using the driver's connection methods.
5. Switch to the desired database using the driver's methods (e.g., client.get_database() in
pymongo).
6. Identify the collection on which you want to perform aggregation operations. For example, consider
a collection named mycollection.
7. Use the appropriate method provided by the driver (e.g., db.collection_name.aggregate() in
pymongo) to perform aggregation operations.
8. Construct the aggregation pipeline by specifying the stages and their parameters as a list of
dictionaries or objects. For example, to group documents by the "category" field and calculate the
average "price" for each category, you can use the following code:

pipeline = [
{ "$group": { "_id": "$category", "averagePrice": { "$avg": "$price" } } }
]
cursor = db.collection_name.aggregate(pipeline)

Iterate through the cursor object to retrieve and process the aggregation results.

Experiment with different stages and combinations to perform various aggregation operations.

Observations:

• The script connects to the MongoDB server successfully.


• Aggregation operations can be performed using the appropriate method provided by the MongoDB
driver.
• The aggregation pipeline allows for complex data processing and analysis.
• Each stage in the pipeline modifies the documents based on the specified operation.
• Aggregation operations enable powerful data transformation and analysis capabilities in MongoDB.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 174 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 175 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

21.Capstone Project-1

Project Name: Book Publishing Company


A publishing company produces scientific books on various subjects. The books are written by authors who
specialize in one particular subject. The company employs editors who, not necessarily being specialists in
a particular area, each take sole responsibility for editing one or more publications. A publication covers
essentially one of the specialist subjects and is normally written by a single author. When writing a
particular book, each author works with on editor, but may submit another work for publication to be
supervised by other editors. To improve their competitiveness, the company tries to employ a variety of
authors, more than one author being a specialist in a particular subject for the above case study.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 176 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 177 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

22.Capstone Project-2

Project Name: Car Rental Company


A database is to be designed for a car rental company. The information required includes a description of
cars, subcontractors (i.e., garages), company expenditures, company revenues and customers. Cars are to be
described by such data as: make, model, year of production, engine size, fuel type, number of passengers,
registration number, purchase price, purchase date, rent price and insurance details. It is the company
policy not to keep any car for a period exceeding one year. All major repairs and maintenance are done by
subcontractors (i.e., franchised garages), with whom CRC has long-term agreements. Therefore, the data
about garages to be kept in the database includes garage names, addresses, range of services and the like.
Some garages require payments immediately after a repair has been made; with others CRC has made
arrangements for credit facilities. Company expenditures are to be registered for all outgoings connected
with purchases, repairs, maintenance, insurance etc. Similarly, the cash inflow coming from all sources:
Car hire, car sales, insurance claims must be kept of file. CRC maintains a reasonably stable client base.
For this privileged category of customers special credit card facilities are provided. These customers may
also book in advance a particular car. These reservations can be made for any period of time up to one
month. Casual customers must pay a deposit for an estimated time of rental, unless they wish to pay by
credit card. All major credit cards are accepted. Personal details such as name, address, telephone number,
driving license, number about each customer are kept in the database.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 178 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 179 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

23.Capstone Project-3

Project Name: E-Commerce Website


The objective of this project is to build an e-commerce website for online sales of products and services
having operational convenience to all types of users. The important features to be built on the website are,
user-friendly menus, information-rich product catalog displayed with rich multimedia contents, easy
browsing, and navigation through product categories for finding best suitable product fitting the
requirements, efficient product search and filtering, high quality, attractive pictures etc. Product page
should contain 360O product view optimized for quick page load. Product page additionally should provide
product descriptions, delivery options and price, customer reviews etc. Also, website should provide a
simple to use shopping cart and a secure payment gateway.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 180 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 181 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

24.Capstone Project-4

Project Name: Insurance Agency Management System

There are many types of insurances ranging from health, conveyance, fortuitous, death indemnification, etc.
people enrol in the insurance as per their desideratum and the quantity of the indemnification to be
submitted as premium on a fine-tuned time interval. The agent suggests the client about the types of
insurances and convinces them to cover their indemnification which provides his commission from the
company on a fine-tuned substratum. The online insurance management system provides an online portal
that is beneficial for the client, agents, and even for the company as well. This system maintains the data of
the policy holder, agent information, premium details, and staff record as well. The admin is the
authoritative personnel who takes care of the full-fledged system work condition and provide vital support
throughout the process, he maintains the staff record and data of their circadian work, salary, and leaves
benefits, etc. the agent provides the details of the insurance policies to the customer and enrols him for the
policy as per his need apart from this he is also eligible so that the client pays the premium on time to
perpetuate the policy schedule

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 182 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 183 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

25.Capstone Project-5

Project Name: Wholesale Management System Database Project

In most developing countries such as ours, wholesale businesses are still managed using a pen and paper
methodology even with the advent of the age of technology and the internet. This can sometimes lead to
inefficient handling of day-to-day business matters and can also lead to security threats to the business due
to the presence of physical records. This project aims to develop sales management web application for a
wholesale business to Improve the efficiency and security of the business. The lightweight nature of the
web application makes it ideal for small businesses which cannot afford the expensive alternates present in
the market. The Wholesale Management System (WMS) has an administrator login for the wholesaler with
built-in features to keep a check on the sales and the inventory to efficiently run the sales division. The
customers and suppliers of the wholesale business can also be registered to ensure the smooth functioning
of sales. There is also a customer login option which helps the customer in monitoring his purchases from
the wholesaler. By having the above features, the WMS simplifies the daily functioning of the business.
Since many developed countries already use such software to speed up daily business activities, a lot of
information is available in the public domain regarding the desirable structure of such software. We have
used this information to design and model our project.

Features:

1. Maintain the details of stock like their id, name, quantity.


2. Maintain the details of buyers from which the manager must buy the stock like buyer id, name,
address, stock id to be bought.
3. Details of customers i.e., name, address, id.
4. Defaulter’s list of customers who have not paid their pending amount.
5. List of payments paid or pending.
6. The stock that is to buy if quantity goes less than a particular amount.
7. Profit calculation for a month.
8. Quantity cannot be sold to a customer if the required amount is not present in stock and the date of
delivery should be maintained up to which stock can be provided.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 184 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 185 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

26.Capstone Project-6

Project Name: General Hospital

A General Hospital consists of a number of specialized wards (such as Maternity, Paediatric, Oncology,
etc). Each ward hosts a number of patients, who were admitted on the recommendation of their own GP and
confirmed by a consultant employed by the Hospital. On admission, the personal details of every patient are
recorded. A separate register is to be held to store the information of the tests undertaken and the results of
a prescribed treatment. A number of tests may be conducted for each patient. Each patient is assigned to
one leading consultant but may be examined by another doctor, if required. Doctors are specialists in some
branch of medicine and may be leading consultants for a number of patients, not necessarily from the same
ward.

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 186 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 187 of 192
Experiment # <TO BE FILLED BY STUDENT> Student ID <TO BE FILLED BY STUDENT>
Date <TO BE FILLED BY STUDENT> Student Name <TO BE FILLED BY STUDENT>

Course Title Database Management Systems ACADEMIC YEAR: 2023-24


Course Code(s) 22AD2102A Page 188 of 192

You might also like