Sie sind auf Seite 1von 16

DBMS LAB MANUAL

CSE/IT/MCA
Week 1 & 2: Students will be able t !e"ise #ile $andlin% in C
E&e!'ise 1 ( Write a program in C to create the following file
named Employee (Ename, Empno, Designation).
Empno Ename Designation
1 Anil Manager
2 han!ar "M
# $aya Engineer1
% &nil Engineer2
' (i)ay Engineer#
* +ra!ash Engineer2
, A)ay Engineer1
1. Add the records gi-en in the a.o-e ta.le.
2. Change the designation of Ename (i)ay to Engineer2.
Display the file.
#. Delete the record of Emp/o '.Display the file.
E&e!'ise 2 ( Write a program in C to create the following file
named Wor!s01n(Empno, +name,Designation,Cost).
Ename +name Designation Cost
Anil 2inancial Mgt Manager 1'33.33
han!ar D&c! ystem "M 2333.33
$aya M ystem Engineer1 1433.33
&nil D&c! ystem Engineer2 1,33.33
(i)ay 2inancial Mgt Engineer2 '333.33
+ra!ash 2inancial Mgt Engineer2 #333.33
A)ay D&c! ystem Engineer1 4333.33
5se the two files and perform the following operations6
1. Change the designation of employee Anil to "M in file
named Employee.
2. Delete the Employee named +ra!ash from Employee file.
2rom the foregoing, draw concl&sions a.o&t the efficacy of the
techni7&e &sed. 8ll&strate these concl&sions with e9amples
drawn from this pro.lem.
)$ase ( I *S+L,:
Wee! #6 Students will be able t )!a'ti'e DML n t$e #llwin% Tables.
Employee :a.le6
Clu-n Na-e Data T./e Si0e
Empno (archar2 *(+rimary ;ey)
Ename (archar2 23(/ot /&ll)
City (archar2 #3 (/ot /&ll)

Data for Employee :a.le6
Empno Ename City
1 Anil /agp&r
2 han!ar <om.ay
# $aya Madras
% &nil <om.ay
' (i)ay Delhi
* +ra!ash Calc&tta
, A)ay Madras
Emp0company :a.le6
Clu-n Na-e Data T./e Si0e
Ename (archar2 13
Cname (archar2 13
alary /&m.er ,,2
$date Date

Emp0shift :a.le6
Ename Cname alary $date
Anil ACC 1'33.33 1=May=4>
han!ar :A:A 2333.33 13=$&l=>3
$aya CMC 1433.33 ,=$&n=>1
&nil CMC 1,33.33 1=$an=44
(i)ay :A:A '333.33 #=$an=44
+ra!ash :A:A #333.33 2,=May=4>
A)ay ACC 4333.33 #3=A+?=>'
Amol ACC 1333.33 1,=Mar=>'
Clu-n Na-e Data T./e Si0e
Ename (archar2 13
hift (archar2 1
Ename hift
Anil A
&nil <
(i)ay <
+ra!ash A
Company :a.le6
Clu-n Na-e Data T./e Si0e
Cname (archar2 13
City (archar2 13
Ename City
ACC Madras
:A:A <om.ay
ACC /agp&r
CMC <om.ay
CMC Madras
:A:A Delhi
Manager :a.le6
Clu-n Na-e Data T./e Si0e
ename (archar2 13
mname (archar2 13
Ename Mname
Anil A)ay
han!ar (i)ay
$aya
+ra!ash han!ar
Week 1 : Students will /!a'ti'e sele't 2 3alue and l%i'al /e!at!s
E&/e!i-ent 1: imple elect, Char, /&m.er, Date f&nctions
Descri.e ta.les which are already created (Employee, Emp0comany,
Emp0shift).
Display all data from ta.le employee.
Displaying the names of the employees li-ing in the city /agp&r.
@ist the names of employees wor!ing with the company ACC and
recei-ing salary greater than 1333.33.
?etrie-e the list of employees who are not employees of company
ACC.
@ist the employees who are from :A:A or ACC.
E&/e!i-ent 2: *usin% Dual table,
?etrie-ing -al&es of system -aria.le in A@ 2ormat.
E-al&ating e9pression in A@ 2ormat.
E&/e!i-ent 1: 3alue and l%i'al 4/e!at!s
Display employees salary after addition of ?s 1333 to all records
in emp0company.
2ind the name of employees whose salary is .etween ?s. 2333 to
'333.
2ind the name of employees of ACC ha-ing salary greater than
e-ery employee of :A:A.
@ist the names of employees li-ing in the city that starts with
character E.
@ist the names of employees whose salary is not specified.
@ist the names of employees whose company name is not ACC.
E&/e!i-ent 5: Nu-be! 6un'tin
Display the a.sol&te -al&e of any n&m.er &sing f&nction.
2ind the s7&are root of a n&m.er.
E&/e!i-ent 7: C$a!a'te! 6un'tin
Display only month from the )date col&mn of emp0company.
Display the name of employees in the &pper case only.
E&/e!i-ent 8: Date 6un'tin
E9tract the day from the system date.
Add two months to the )date of all employees.
Week 5 : Students will /!a'ti'e Set 4/e!atins and A%%!e%ate #un'tins
6llw t$e Database st!u'tu!e %i"en in week19
E&/e!i-ent 1 *Set 4/e!atins,
Display the cities of companies ACC and :A:A.
A@B select city from d.231%0company where cnameCDACCD &nion select
city from d.231%0company where
cnameCD:A:ADE
C8:F
====================
<om.ay
Delhi
Madras
/agp&r
Display the name of the city that is common to companies ACC
and :A:A.
A@B select city from d.231%0company where cnameCDACCD intersect
select city from d.231%0company wh
ere cnameCD:A:ADE
no rows selected
2ind the cities where ACC is located, .&t not :A:A.
A@B select city from d.231%0company where cnameCDACCD min&s select
city from d.231%0company where
cnameCD:A:ADE
C8:F
====================
Madras
/agp&r
Display the names of employees li-ing in /agp&r, and wor!ing
with company ACC.
A@B select Ename from d.231%0Employee where cityCD/agp&rD intersect
select ename from d.231%0Emp0co
mpany where CnameCDACCDE
E/AME
==========
Anil
Display the names of employees li-ing in /agp&r, .&t not wor!ing
in company ACC.
A@B select Ename from d.231%0Employee where cityCD/agp&rD min&s
select ename from d.231%0Emp0compan
y where CnameCDACCDE
no rows selected
Display the names of employees li-ing in /agp&r, wor!ing in
company ACC .&t not wor!ing in shift GAH.
A@B select Ename from d.231%0Employee where cityCD/agp&rD intersect
select ename from d.231%0Emp0co
mpany where CnameCDACCD min&s select Ename from d.231%0Emp0shift
where hiftCDADE
no rows selected
Display the names of employees who are li-ing in /agp&r or
<om.ay .
A@B select Ename from d.231%0Employee where cityCD/agp&rD
&nion select Ename from d.231%0Employee w
here cityCD<om.ayDE
E/AME
==========
Anil
han!ar
&nil
Display the employees names &sing 5/81/ and 5/81/ A@@
operator.
A@B select Ename from d.231%0Employee 5/81/(select Ename from
d.231%0Employee 5/81/ A@@ select Enam
e from d.231%0Employee)E
E/AME
==========
A)ay
Anil
$aya
+ra!ash
han!ar
&nil
(i)ay
, rows selected.
Display the employees names &sing 5/81/ A@@ and 5/81/
operator.
A@B select Ename from d.231%0Employee 5/81/ A@@(select Ename
from d.231%0Employee 5/81/ select Enam
e from d.231%0Employee)E
E/AME
==========
Anil
han!ar
$aya
&nil
(i)ay
+ra!ash
A)ay
A)ay
Anil
$aya
+ra!ash
E/AME
==========
han!ar
&nil
(i)ay
1% rows selected.
E&/e!i-ent 2* A%%!e%ate #un'tins,9
@ist ma9im&m salary in all companies.
A@B select ma9(salary) from d.231%0Emp0companyE
MAI(A@A?F)
===========
4333
Display ma9im&m salary of employee of ACC.
A@B select ma9(salary) from d.231%0Emp0company where
CnameCDACCDE
MAI(A@A?F)
===========
4333
Display the n&m.er of employees wor!ing in ACC.
A@B select co&nt(ename) from d.231%0Emp0company where
CnameCDACCDE
C15/:(E/AME)
============
#
Display the names of employees ha-ing ma9im&m salary.
A@B select ename from d.231%0Emp0company where salary
in(select ma9(salary) from d.231%0Emp0company
)E
E/AME
==========
A)ay
Display the names of employees ha-ing ma9im&m salary in their
company.
A@B select e1.ename from d.231%0Emp0company e1 where
e1.salary in(select ma9(e2.salary) from d.231%
0Emp0company e2 where e1.cnameCe2.cname)E
E/AME
==========
$aya
(i)ay
A)ay
Week 7: Students will /!a'ti'e :;4U)IN:2 <4INS
E&/e!i-ent 1: "ro&ping cla&ses
Display the names of companies and the ma9im&m salary in that
company.
Calc&late the n&m.er of employees for each company.
Display the companies ha-ing more than one employee.
2ind the a-erage salary of each company.
2ind the name of companies ha-ing a-erage salary more than
1'33.
E&/e!i-ent 2: 1rder <y
Display employee name and Company name .y sorting the o&tp&t
on employee name.
A@B select ename, cname from d.231%0emp0company 1?DE? <F
enameE
E/AME C/AME
========== ==========
A)ay ACC
Amol ACC
Anil ACC
$aya CMC
+ra!ash :A:A
han!er :A:A
&nil CMC
(i)ay :A:A
4 rows selected.
+erform the sorting in ascending order, and if cname is same , then
it is sorted on ename in descending order.
E&/e!i-ent 1: $oins
@ist the name, li-ing city and salary of all employees.
8mplement the a.o-e 7&ery &sing Cartesian prod&ct (cross )oin).
Create a ta.le manager with the following data6
Ename Mname
Anil A)ay
han!er (i)ay
(i)ay
A)ay
&nil $aya
$aya
Display employee name, name of manager and the associated shift
&sing /at&ral )oin.
8mplement the a.o-e 7&ery &sing o&ter )oin if the employee
doesnHt ha-e a shift, then only the employee name and manager
name is displayed.
8mplement the a.o-e &sing f&ll o&ter )oin.
Week 8: Students will /!a'ti'e SELECT wit$ sub=>ue!ies2 Ca!tesian
/!du't2 3iews2 Se>uen'e
E&/e!i-ent 1: &.=7&eries ( &sing 8/ , EI8: cla&se)
2ind employees names, the cities they li-e in, and wor!ing in
company ACC.
Display the names of employees ha-ing li-ing city same as A)ay.
Display the salary of employee li-ing in delhi.
Display the names of employees ha-ing li-ing city same as
A)ay(&sing e9ists).
E&/e!i-ent 2: Cartesian +rod&ct
Display information of employees in company :A:A.
@ist the names of employees li-ing in city <1M<AF and ha-ing
company located in DE@J8.
Week ?: Students will /!a'ti'e DDL
Tables:

create ta.le deposit (actno -archar2('), cname -archar2(23), .name
-archar2(23), amo&nt n&m.er (4,2), adate date
create ta.le .ranch (.name -archar2(23), city -archar2(23)
create ta.le c&stomer (cname -archar2(23), city -archar2(23)
create ta.le .orrow (loanno -archar2('), .name -archar2(23), amo&nt
n&m.er(4,2)
E&/e!i-ent ( 1
+ro.lem tatement6
Create deposit, .ranch, c&stomer and .orrow ta.les with the following
col&mns.
ol&tion6
1. 5nderstand create ta.le synta9.
2. Decide the name of the ta.le.
#. Decide the name of each col&mn and its data type.
%. 5se the create ta.le synta9 to create the said ta.les.
E&/e!i-ent 2:
+ro.lem tatement6
Alter .orrow ta.le to add cname -archar2(14) col&mn which is of
string data type.
?ename the col&mn to cname of the ta.le .orrow.
Modify the col&mn with new datatypes of the ta.le .orrow.
E&/e!i-ent 1:
+ro.lem tatement6
8nsert data into deposit, .ranch, c&stomer and .orrow ta.les.
E&/e!i-ent 5:
+ro.lem tatement6
Create a d&mmy ta.le called my0.ranch with the same definition as .ranch
ta.le and than drop the ta.le.
Week @: Students will /!a'ti'e DDL wit$ 'nst!aint 2 3iews and Se>uen'e
E&/e!i-ent 1:
+ro.lem tatement6
Alter ta.les to assign primary !eys and foreign !ey.
ol&tion6
1. @earn alter ta.le synta9.
2. Define the new constraint Ktype, name, col&mns effectedL
#. 5se the alter ta.le synta9 for adding constraints.
E&/e!i-ent 2 *De#inin% Cnst!aints,
+ro.lem tatement6
Create ta.le st&dent0mar!s with the following str&ct&re6
roll n&m.er n&m.er(#)
name -archar2(23)
city -archar2(23)
mar!s n&m.er(',2)
remar!s -archar2(23)
5se the following constraints on the a.o-e ta.le6
1) ?oll n&m.er sho&ld ha-e a range from 1 to 2'3 and n&ll -al&es
are not accepted.
2) 2irst character of the name is .etween A and M.
#) City sho&ld ha-e length # and all characters sho&ld .e in
&ppercase.
%) Mar!s sho&ld .e .etween 3 to 133.
E&/e!i-ent 1 *De#inin% Cnst!aints,
+ro.lem tatement6
Create ta.le a.c with the following specifications6
A n&m.er(2), < n&m.er(2), C n&m.er(2), D n&m.er(2), E n&m.er(2)
8mplement the following constraints6
1) A and < .oth as primary !ey.
2) C and D .oth as &ni7&e !ey.
#) E as 5ni7&e !ey.
E&/e!i-ent 5: (iews
Create a -iew that gi-es information a.o&t employee name, salary
and li-ing city.
Create a -iew for retrie-ing company name. its a-erage salary, its
ma9im&m salary and minim&m salary.
E&/e!i-ent 7: e7&ence
Create a se7&ence named st&did0se7&enceE with starting -al&e 1
and incrementing .y 1, ma9im&m -al&e is >>, with cycle and
cache.
8nsert a record into st&dent ta.le &sing the se7&ence named
st&did0se7&ence.
Week A: Students will /!a'ti'e DD@,DC@
E&/e!i-ent 1:
Create ta.le emp0company1 with three col&mn N ename, cname
and salary ha-ing the same datatypes as of the col&mns from
emp0company.
Jint 6 Create ta.le &sing 7&ery.
5sing ?1W/5M display the se7&ence of rows retri-ed.
5sing ?1W8D to display the location of row in data.ase.
Create a ta.le st&dent with two col&mns st&did and st&d0name.
8nsert at least fi-e records for the same. Create local inde9 named
st&d on name of st&dent information ta.le.
E&/e!i-ent 2: DCL
Week1B: Students will /!a'ti'e E; Case Tls
)!ble- State-ent 1:
Draw an E? schema.
Constr&ct an E=? diagram for a car=ins&rance company whose
c&stomers own one or more cars each. Each car has associated with it
Oero to any n&m.er of recorded accidents.
Constr&ct an E=? diagram for a hospital with a set of patients and a set
of medical doctors. Associate with each patient a log of the -ario&s
tests and e9aminations cond&cted.
A college r&ns a hostel that has single, do&.le and triple=seated rooms.
:he charge for each of these !inds of rooms is different from one
another. t&dents opt for and are allotted rooms of their choice. :he
hostel has messes with different c&isines. t&dents register for these
messes for a period of one month at a time. :hey pay the monthly
charges at registration time. ?ecord is !ept of the n&m.er of meals not
ta!en .y a st&dent and a ref&nd is made for these at the end of the
month. :he hostel pro-ides a n&m.er of facilities li!e washing
machines, film cl&., lending li.rary. t&dents register and pay for
these.
Week 11: Students will d )!Ce't W!k
Week 12: Students will d )!Ce't W!k

Das könnte Ihnen auch gefallen