0% found this document useful (0 votes)
6 views

Lab Manual 1

Uploaded by

nkpatel2355
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Lab Manual 1

Uploaded by

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

Computer Science & Engineering

A.Y. 2023-24 | Semester - III


Lab Manual
2101CS302 - Database Management System – II
Lab-1 Create Database with Name: Person_Info
(Joins) Create following table under Person_Info database. (Using Design Mode)
Person
Column_Name DataType Constraints
PersonID Int Primary Key
PersonName Varchar (100) Not Null
DepartmentID Int Foreign Key, Null
Salary Decimal (8,2) Not Null
JoiningDate Datetime Not Null
City Varchar (100) Not Null

Department
Column_Name DataType Constraints
DepartmentID Int Primary Key
DepartmentName Varchar (100) Not Null, Unique
DepartmentCode Varchar (50) Not Null, Unique
Location Varchar (50) Not Null

PersonID PersonName DepartmentID Salary JoiningDate City


101 Rahul Tripathi 2 56000 01-01-2000 Rajkot
102 Hardik Pandya 3 18000 25-09-2001 Ahmedabad
103 Bhavin Kanani 4 25000 14-05-2000 Baroda
104 Bhoomi Vaishnav 1 39000 08-02-2005 Rajkot
105 Rohit Topiya 2 17000 23-07-2001 Jamnagar
106 Priya Menpara NULL 9000 18-10-2000 Ahmedabad
107 Neha Sharma 2 34000 25-12-2002 Rajkot
108 Nayan Goswami 3 25000 01-07-2001 Rajkot
109 Mehul Bhundiya 4 13500 09-01-2005 Baroda
110 Mohit Maru 5 14000 25-05-2000 Jamnagar

DepartmentID DepartmentName DepartmentCode Location


1 Admin Adm A-Block
2 Computer CE C-Block
3 Civil CI G-Block
4 Electrical EE E-Block
5 Mechanical ME B-Block

From the above given table perform the following queries:


1. Find all persons with their department name & code.
2. Find person's name whose department located in C-Block.
3. Retrieve person name, salary & department name who belongs to Jamnagar city.
4. Retrieve person name, salary & department name who does not belongs to Rajkot city.
5. Find detail of all persons who belongs Computer department.
6. Find all persons who does not belongs to any department.
7. Retrieve person’s name who joined Civil department after 1-Aug-2001.
8. Display all the person's name with department whose joining dates difference with current date is
more than 365 days.
9. Find department wise person counts.
10. Give department wise maximum & minimum salary with department name.
11. Find city wise total, average, maximum and minimum salary.

Page 1 of 4
Computer Science & Engineering
A.Y. 2023-24 | Semester - III
Lab Manual
2101CS302 - Database Management System – II

12. Find all departments whose total salary is exceeding 100000.


13. Find average salary of person who belongs to Ahmedabad city.
14. List all departments who have no person.
15. List out department names in which more than two persons are working.
16. Produce Output Like: <PersonName> lives in <City> and works in <DepartmentName> Department. (In
single column)
17. Produce Output Like: <PersonName> earns <Salary> from department <DepartmentName> monthly.
(In single column)
18. Find city & department wise total, average & maximum salaries.
19. Give 10% increment in Computer department employee’s salary. (Use Update)

Lab-2 Create Database with Name: Worker_Info


& Create following tables under Worker_Info database. (Using Design Mode)
Lab-3
(SP) Person
Column_Name DataType Constraints
Primary Key, Auto
WorkerID Int
Increment
FirstName Varchar (100) Not Null
LastName Varchar (100) Not Null
Salary Decimal (8,2) Not Null
JoiningDate Datetime Not Null
DepartmentID Int Foreign Key, Null
DesignationID Int Foreign Key, Null

Department
Column_Name DataType Constraints
DepartmentID Int Primary Key
DepartmentName Varchar (100) Not Null, Unique

Designation
Column_Name DataType Constraints
DesignationID Int Primary Key
DesignationName Varchar (100) Not Null, Unique

WorkerID FirstName LastName Salary JoiningDate DepartmentID DesignationID


101 Rahul Anshu 56000 01-01-1990 1 12
102 Hardik Hinsu 18000 25-09-1990 2 11
103 Bhavin Kamani 25000 14-05-1991 NULL 11
104 Bhoomi Patel 39000 20-02-2014 1 13
105 Rohit Rajgor 17000 23-07-1990 2 15
106 Priya Mehta 25000 18-10-1990 2 NULL
107 Neha Trivedi 18000 20-02-2014 3 15

DepartmentID DepartmentName DesignationID DesignationName


1 Admin 11 Jobber
2 IT 12 Welder
3 HR 13 Clerk
4 Account 14 Manager
15 CEO

Page 2 of 4
Computer Science & Engineering
A.Y. 2023-24 | Semester - III
Lab Manual
2101CS302 - Database Management System – II

From the above given tables perform the following queries:


Stored Procedures (Lab – 2)
1. All tables Insert
2. All tables Update
3. All tables Delete
4. All tables SelectPK
5. All tables SelectAll (If foreign key is available than do write join and take columns on select list)
Stored Procedures (Lab – 3)
1. Create Procedure that show detail of first 3 persons.
2. Create Procedure that takes department dame as input and returns a table with all workers working in
that department.
3. Create Procedure that takes department name & designation name as input and returns a table with
worker’s first name, salary, joining date & department name.
4. Create Procedure that takes first name as an input parameter and display all the details of the worker
with their department & designation name.
5. Create Procedure which displays department wise maximum, minimum & total salaries.
6. Create Procedure which displays designation wise maximum, minimum & total salaries.

Lab-4 Perform the following queries.


(UDF) Scalar valued functions
1. Write a function to print "hello world".
2. Write a function which returns addition of two numbers.
3. Write a function to print cube of given number.
4. Write a function to check where given number is ODD or EVEN.
5. Write a function to compare two integers and returns the comparison result. (Using Case statement)
6. Write a function to print number from 1 to N. (Using while loop)
7. Write a function to print sum of even numbers between 1 to 20.
8. Write a function to check weather given number is prime or not.
9. Write a function which accepts two parameters start date & end date, and returns a difference in days.
10. Write a function which accepts year & month in integer and returns total days in given month & year.
Table valued functions (Use tables of lab-2)
11. Write a function which returns a table with detail of person whose first name starts with B.
12. Write a function which returns a table with unique first names from person table.
13. Write a function which accepts department ID as a parameter & returns a detail of the persons.

Lab-5 Create Database with Name: BANK_INFO


Mongo Deposite
DB ACTNO CNAME BNAME AMOUNT ADATE
101 ANIL VRCE 1000.00 1-3-95
102 SUNIL AJNI 5000.00 4-1-96
103 MEHUL KAROLBAGH 3500.00 17-11-95
104 MADHURI CHANDI 1200.00 17-12-95
105 PRMOD M.G. ROAD 3000.00 27-3-96
106 SANDIP ANDHERI 2000.00 31-3-96
107 SHIVANI VIRAR 1000.00 5-9-95
108 KRANTI NEHRU PLACE 5000.00 2-7-95

Page 3 of 4
Computer Science & Engineering
A.Y. 2023-24 | Semester - III
Lab Manual
2101CS302 - Database Management System – II

From the above given collection perform the following queries:


1. Retrieve/Display every document of Deposite collection.
2. Retrieve/Display every document of Deposite collection. (Use: pretty())
3. Display only one document of Deposite collection. (Use: findOne())
4. Insert following document to Deposite collection. (Use: insertOne())
109 KIRTI VIRAR 3000.00 3-5-97
5. Insert following documents to your collection. (Use: insertMany())
110 MITALI ANDHERI 4500.00 4-9-95
111 RAJIV NEHRU PLACE 7000.00 2-10-98
6. Display documents with CNAME, BNAME and AMOUNT fields.
7. Display every document of Deposite collection on ascending order by CNAME.
8. Display every document of Deposite collection on descending order by BNAME.
9. Display every document of Deposite collection on ascending order by ACTNO and descending
order by AMOUNT.
10. Display only two documents of Deposite collection.
11. Display 3rd document of Deposite collection.
12. Display 6th and 7th documents of Deposite collection.
13. Display the count of documents in Deposite collection.
14. Delete the collection Deposite.
15. Drop BANK_INFO database.

Page 4 of 4

You might also like