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

dbms pdf

Uploaded by

Trial
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

dbms pdf

Uploaded by

Trial
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

A

Practical File
On
Database Management System Lab
BCA- 306
Session: 2022-23

Submitted by: Submitted to:


Prabhav bhumbak Mrs. Pooja rani
Roll no.: 1321014 (Assistant Professor)

M.M. INSTITUTE OF COMPUTER TECHNOLOGY & BUSINESS MANAGEMENT


MAHARISHI MARKANDESHWAR (DEEMED TO BE UNIVERSITY)
MULLANA–AMBALA, HARYANA (INDIA) - 133207
(Established under Section 3 of the UGC Act, 1956)
(Accredited by NAAC with Grade ‘A++’)
INDEX
S. No. Name of Experiment Date of Page Signature
Practical No.
1. Write a Query for creating new Database Named 1-3
“Microsoft_Corporation”. Use currently created
Database. Create at-least Three Tables “EMP1, EMP2,
EMP3” in “Company”. EMP1: Includes Professional
Information of Employee, EMP2: Personal
Information of Employee and EMP3; Salary related
records, EMP4: Empty Table. Attributes are:
1. EMP1: Emp_Id, Emp_Name, Emp_Dept,
Emp_Des, Emp_Contact, Emp_Email,
Emp_Qualification, Emp_Research_Area.
2. EMP2: Emp_Id, Emp_FatherName,
Emp_Mother_Name, Emp_DOB,
Emp_Address, Emp_Gender, Emp_Religion.
3. EMP3: Emp_Id, Emp_Date_of_Joining,
Emp_Basic_Salary, Emp_TA_DA.

2. Write a Query for Inserting, Deleting, Updating, Alter, 3-7


Drop Data of Database Tables i.e,
1. Emp1 and Emp2 having 15 and Emp3 having 10
records.
2. Alter/Modify command perform alteration of
attribute Type and Adding New Column i.e., in
Emp3 e.g. change the column name
Date_of_Joining toJoining_Date, Add Column
in same Table Monthly_Salary_, Yearly_Salary.
3. Drop Table Emp4.
3. Write a Query for using: 8-9
Primary Key Constraints on EMP_ID Column, Unique
Key Constraints on EMP_CONTACT
Column,
Not Null Key Constraints on
EMP_QUALIFICATION Column,
EMP_RESEARCH_AREA Column. Also use Foreign
key Constraints in “EMP2 tables not on EMP3. Apart
from use Check Constraints for
EMP_BASIC_SALRY i.e., it shouldn’t greater than
Rs. 30000 of any employee.

4. Write a Query: 10
A) Find Average of Salaries of those Employees
having designation=”Asst. Manager”.[use of
where clause].
B) Find Id, Name, BasicSalary of those Employee
having Research Area=”Software Engineering”
and Gender=” Male”.
5. 11-12
Write a Query for: (Order By,
Group By and Having Clause)
Select EmpName, Salary from
table and Order ByEmpName.
Select Average Salary from table and Group By
Department.

Select Average Salary from table and Group By


Department Having Designation Associate
Professor.
Practical No. 1

AIM: Write a Query for creating new Database Named


“Microsoft_Corporation”. Use currently created Database. Create at-least
Three Tables “EMP1, EMP2, EMP3” in “Company”. EMP1: Includes
Professional Information of Employee, EMP2: Personal Information of
Employee and EMP3; Salary related records, EMP4: Empty Table.
Attributes are:
1. EMP1: Emp_Id, Emp_Name, Emp_Dept, Emp_Des,
Emp_Contact, Emp_Email, Emp_Qualification,
Emp_Research_Area.
2. EMP2: Emp_Id, Emp_FatherName, Emp_Mother_Name, Emp_DOB,

QUERY : EMP1- Professional Information of Employee

create database Microsoft_Corporation;


use Microsoft_Corporation;
create table Professional_Information_of_Employee(
Emp_Id int ,
Emp_Name varchar(54),
Emp_Dept varchar(43),
Emp_Des varchar(64),
Emp_Contact varchar(10),
Emp_Email varchar(43),
Emp_Qualification varchar(554),
Emp_Research_Area varchar(65) );
Desc Professional_Information_of_Employee;

[1]
QUERY : EMP 2- Personal Information of Employee

create table Personal_Informatio_of_Employee(


Emp_Id int ,
Emp_FatherName varchar(54),
Emp_Mother_Name varchar(63),
Emp_DOB date,
Emp_Address varchar(654),
Emp_Gender varchar(645),
Emp_Religion varchar(356) );
Desc Personal_Informatio_of_Employee;

QUERY : EMP3- Salary related records

create table Salary_related_records(


Emp_Id int ,
Emp_Date_of_Joining date,
Emp_Basic_Salary int,
Emp_TA_DA varchar(650) );
Desc Salary_related_records;

[2]
Practical No. 2
AIM: Write a Query for Inserting, Deleting, Updating, Alter, Drop Data of
Database Tables i.e,
1. Emp1 and Emp2 having 15 and Emp3 having 10 records.
2. Alter/Modify command perform alteration of attribute Type and Adding
New Column i.e., in Emp3 e.g. change the column name Date_of_Joining
toJoining_Date, Add Column in same Table Monthly_Salary_,
Yearly_Salary.
3. Drop Table Emp4.
QUERY : 1 – EMP_1

create table Emp1(


Emp_Id int,
Emp_Name varchar(54),
Emp_Dept varchar(43),
Emp_Desig varchar(64),
Emp_Contact varchar(10),
Emp_Email varchar(645),
Qualification varchar(34),
Reserch_area varchar(654) );
select*from Emp1;

[3]
insert into Emp1
values(89,'Aris','BCA','coordinator','7488954127','[email protected]','MCA','so
ftware_engineering'),
(105,'Kasif','BCA','asst_manager','620645453','[email protected]','MCA','system
_engineering'),
(96,'ayan','BCA','asst_manager','8102660167','[email protected]','MCA','electric
_engineering'),(118,'Arif','BCA','manager','765543632','[email protected]','MC
A','web_engineering'),(129,'Akhilesh','BCA','asst_professor','76475826','mdk243@
gmail.com','MCA','web_designing'),
(101,'Sanjeev','BCA','asst_manager','81020167','[email protected]','MCA','softw
are_engineering'),
(107,'abhisek','BCA','asst_manager','8102360167','[email protected]','MCA','sof
tware_engineering'),
(1,'Njiya','MA','manager','7487369937','[email protected]','MCA','teacher'),
(2,'Chandni','BA','manager','8102360167','[email protected]','B_TECH','teacher,
(3,'Feziya','MCA','asst_manager','8102363467','[email protected]','MCA','softw
are_engineering'),
(107,'sana','B_TECH','asst_manager','8102360167','[email protected]','MCA','so
ftware_devloper'),
(93,'sogodogo','BCA','asst_manager','8106560167','[email protected]','MCA','so
ftware_engineering'),
(108,'abusalim','HM','food_manager','886545463','[email protected]','MCA','hot
el_management'),
(109,'sachin','HHA','front_office','6767545577','[email protected]','MCA','hotel_
management'),
(10,'imran','HHA','bilder','654424354','[email protected]','MCA','hotel_manage
ment');

[4]
QUERY : EMP_1

QUERY :1 – EMP_2

create table Emp2(


Emp_Id int,
Emp_FatherName varchar(54),
Emp_Mother_Name varchar(63),
Emp_DOB date,
Emp_Address varchar(654),
Emp_gender varchar(554),
Emp_Religion varchar(356) );
select *from Emp2;
insert into Emp2 values(89,'mofid','shakila','2003/03/18','sitamarhi','male','islam'),
(105,'akbar','shahida','2001/04/18','darbhanga','male','islam'),
(96,'farman','hadisa','2000/02/28','sitamarhi','male','islam'),
(118,'tauhid','ajmeri','2003/05/11','siwan','male','islam'),
(129,'subhas','laxmani','2003/07/16','kaimur','male','hindu'),
(101,'sarwan','suganti','1999/05/28','chapra','male','hindu'),
(107,'dinesh','sanju','1999/06/15','gya','male','hindu'),
(1,'ansari','sahina','2001/02/21','gaziabad','female','islam'),
(2,'mokhatar','sakina','2003/03/18','gaziabad','female','islam'),
(3,'mohammad','imarana','2001/03/12','meerut','female','islam'),
(107,'shaweb','sabana','1998/07/04','saranpur','female','islam'),
(93,'nagolo','fatoum','1999/03/18','abidjan','male','islam'),
(108,'mohid','sabida','2001/03/18','arariya','male','islam'),
(109,'yadav','shusila','2002/06/17','arariya','male','hindu'),
(10,'abdullah','shahina','2001/05/12','madhubani','male','islam');

[5]
QUERY : EMP_2

QUERY : 1 – EMP_3

create table Emp3(


Emp_Id int,
Emp_Date_of_Joining date,
Emp_Basic_Salary int,
Emp_TA_DA int );
select*from Emp3;
insert into Emp3 values(89,'2021/11/11',32299,12.323),
(105,'2020/05/06',32499,1232.112),
(96,'2021/09/09',42299,123232.34),
(118,'2020/10/12',22099,12132.343),
(129,'2021/02/02',31299,12123.43),
(101,'2020/03/03',32299,1212.356),
(107,'2020/01/14',34299,234345.3),
(108,'2021/02/19',32299,12312.453),
(109,'2021/02/11',42699,2324.54),
(10,'2019/10/22',12299,1212.34);

[6]
QUERY : EMP_3

QUERY: 2

alter table Emp3 change Emp_Date_of_Joining Joining_Date date;


alter table Emp3
add Monthly_Salary int,
add Yearly_Salary int;
select*from Emp3;

Solution : 3 - Drop Table Emp4


drop table Empty_Table;

[7]
Practical No. 3
AIM: Write a Query for using:
Primary Key Constraints on EMP_ID Column,
Unique Key Constraints on EMP_CONTACT Column,
Not Null Key Constraints on EMP_QUALIFICATION Column,
EMP_RESEARCH_AREA Column. Also use Foreign key Constraints in
“EMP2 tables not on EMP3. Apart from use Check Constraints for
EMP_BASIC_SALRY i.e., it shouldn’t greater than Rs. 30000 of any employee.
QUERY 1:
• Primary key constraints on Emp_Id.

alter table Emp1


add primary key(Emp_Id);
disc Emp1;

QUERY 2:
• Unique key constraints on EMP_CONTACT

alter table Emp1


add unique (Emp_Contact);
desc Emp_1;

[8]
QUERY 3:
• Not null key constraints on EMP_QUALIFICATION

alter table Emp1


modify Qualification varchar(34) not null;

QUERY 4:
• Foreign key constraints in “EMP2” table not on “EMP3”.

alter table Emp2


add foreign key(Emp_Id)
references Emp1(Emp_Id);
DESC Emp2;

QUERY 4:
• Check Constraints for EMP_BASIC_SALRY i.e., it shouldn’t greater than Rs. 30000 of
any employee.

[9]
Practical No. 4

AIM: Write a Query:


A) Find Average of Salaries of those Employees having designation=”Asst.
Manager”.[use of where clause].
B) Find Id, Name, BasicSalary of those Employee having Research
Area=”Software Engineering” and Gender=” Male”.
QUERY 1:
❖ Find Average of Salaries of those Employees having
designation=”Asst. Manager”.[use of where clause

QUERY 2:
❖ Find Id, Name, BasicSalary of those Employee having Research
Area=”Software Engineering” and Gender=” Male”

[10]
Practical No. 5

AIM: Write a Query for: (Order By, Group By and Having


Clause) Select EmpName, Salary from table and Order
ByEmpName.
✓ Select Average Salary from table and Group By Department.
✓ Select Average Salary from table and Group By Department Having
Designation Associate Professor.
QUERY 1:
• Select EmpName, Salary from table and Order ByEmpName.
select Emp1.Emp_Name,Emp3.Emp_Basic_Salary
from Emp1
join Emp3
on Emp1.Emp_Id=Emp3.Emp_Id
order by Emp1.Emp_Name;

[11]
QUERY 2:
• Select Average Salary from table and Group By Department.
select avg (Emp3.Emp_Basic_Salary),Emp1.Emp_Dept
from Emp3
join Emp1
on Emp3.Emp_Id=Emp1.Emp_Id
group by Emp1.Emp_Dept;

QUERY 3:
• Select Average Salary from table and Group By Department Having
Designation Asst_manager.

[12]
[13]

You might also like