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

LAB ASSSIGNMENT 2 for dbms

The document contains a DBMS Lab assignment for B.Tech. (CS) III Semester students, detailing SQL queries to be executed on given relational schemas for employee and student databases. It includes tasks such as retrieving employee information based on department work, creating and populating tables for student members and departments, and analyzing sales and product data across various queries. The assignment aims to enhance students' practical skills in database management and SQL query formulation.
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)
5 views

LAB ASSSIGNMENT 2 for dbms

The document contains a DBMS Lab assignment for B.Tech. (CS) III Semester students, detailing SQL queries to be executed on given relational schemas for employee and student databases. It includes tasks such as retrieving employee information based on department work, creating and populating tables for student members and departments, and analyzing sales and product data across various queries. The assignment aims to enhance students' practical skills in database management and SQL query formulation.
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/ 3

B.Tech.

(CS) III Semester


(SECTION A & B)
DBMS Lab. (CS 212L) Assignment -II

1. Consider the following relational schema. An employee can work in more than one
department; the pct_time filed of the Works relation shows the percentage of time that a given
employee works in a given department.

Emp (eid: integer, ename: string, age: integer, salary: real)


Works (eid: integer, did: integer, pct_time: integer)
Dept (did: integer, dname: string, budget: real, managerid: integer)

Write the following queries in SQL:

a. Print the names and ages of each employee who works in both the Hardware department
and the Software department.
b. For each department with more than 20 full-time-equivalent employees (i.e., where the
part-time and full-time employees add up to at least that many full-time employees), print
the did together with the number of employees that work in that department.
c. Print the name of each employee whose salary exceeds the budget of all of thedepartments
that he or she works in.
d. Find the managerids of managers who manage only departments with budgetsgreater than
$1 million.
e. Find the enames of managers who manage the departments with the largestbudgets.
f. If a manager manages more than one department, he or she controls the sum of all the
budgets for those departments. Find the managerids of managers who control more than $5
million.
g. Find the managerids of managers who control the largest amounts.
h. Find the enames of managers who manage only departments with budgets larger than $1
million, but at least one department with budget less than $5million.

2. a. Create a relational database that contains the following tables and insert the following data
into these tables

STUD_MEMBER

Roll_No FName MName SName Dept_ID Semester Contact_No Gender


1 Ankur Samir Kahar 1 1 272121 M
2 Dhaval Dhiren Joshi 1 1 232122 M
3 Ankita Biren Shah 1 1 112121 F
10 Komal Maheshkumar Pandya 2 3 123123 F
13 Amit Jitenkumar Mehta 3 3 453667 M
23 Jinal Ashish Gandhi 2 1 323232 M
22 Ganesh Asha Patel 2 3 124244 M
4 Shweta Mihir Patel 3 1 646342 F
7 Pooja Mayank Desai 3 3 328656 F
8 Komal Krishnaraj Bhatia 2 3 257422 F
43 Kiran Viraj Shah 1 1 754124 F
DEPARTMENT

Dept_ID Dept_Name
1 Information Technology
2 Electrical
3 Civil
4 Mechanical
5 Chemical

b. Now, solve the following SQL Queries

i. Display the names and contact numbers of all student members.


ii. Give the names and roll numbers of all students of Information Technology who are
members.
iii. Display names of Departments whose students are members.
iv. Display names of Departments for which no students are members.
v. Display names of all Departments.
vi. Find the number of students of Electrical Department who are members.
vii. Display information of student members whose name begins with the letter “A”.
viii. Display all details of Male members only.
ix. Display data of student members who are currently in semester „3‟.
x. Display data of student female members in alphabetical order.

3. Consider the following relational schemas:


Table: sales

OrderID OrderDate OrderPrice OrderQuantity CustomerName

1 12/22/2005 160 2 Smith


2 08/10/2005 190 2 Johnson
3 07/13/2005 500 5 Baldwin
4 07/15/2005 420 2 Smith
5 12/22/2005 1000 4 Wood
6 10/2/2005 820 4 Smith
7 11/03/2005 2000 2 Baldwin
8 12/22/2002 1000 4 Wood
9 12/29/2004 5000 4 Smith
Table: products
Product_id OrderId Manufacture_Date Raw_Material Vender_id
AZ145 2 12/23/2005 Steel 1
CS784 4 11/28/2005 Plastic 2
AZ147 6 08/15/2002 Steel 3
FD344 3 11/03/2005 Milk 1
GR233 3 11/30/2005 Pulses 2
FD123 2 10/03/2005 Milk 2
CS783 1 11/03/2004 Plastic 2
CS435 5 11/04/2001 Steel 1
GR567 6 09/03/2005 Pulses 2
FD267 5 21/03/2002 Bread 4
FD333 9 12/12/2001 Milk 1
Table: vender_info
Vender_id Vender_name
1 Smith
2 Wills
3 Johnson
4 Roger
Table: venders
Raw_Material Venders Vender_id
Steel Smith 1
Plastic Wills 2
Steel Johnson 3
Milk Smith 1
Pulses Wills 2
Bread Roger 4
Bread Wills 2
Milk Wills 2
i. Display product information which are ordered in the same year of its manufacturing
year.
ii. Display product information which are ordered in the same year of its manufacturing
year where vender is „smith‟.
iii. Display total no. of orders placed in each year.
iv. Display total no. of orders placed in each year by vender Wills.
v. Display the name of all those persons who are venders and customers both.
vi. Display total no. of food items ordered every year.
vii. Display total no. of food items ordered every year made from Bread.
viii. Display list of product_id whose vender and customer is different.
ix. Display all those customers who are ordering products of milk by smith.
x. Display total no. of orders by each vender every year.
xi. Display name of those venders whose products are sold more than 2000 Rs. Every year.

You might also like