0 ratings0% found this document useful (0 votes) 59 views13 pagesDBMS Experiment 3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
Page No.
a)
Create the following tololes based on tne below schema dial
gram with appropriate data “types and constrains
EMPLOYEECPmame, mi, Iname ssn ) kdate , yender-sakary vad
dress, Superssn,dno) ;
DEPARTMENT Cdname, dno, mgrssn , Mgrstartdate)
DEPT. Locanions. Cadnumber, location >)
PROTECT Cprare, prumber, Plocation ,dnum>
WORKS-ON Cessn, pno, hours) :
DEPENDENTCessn, deperdent— rare , sex, boate, relgtons
Create and insert tne following tables
S@L> create table emp204¢Gfname char@20);m? charcl), in
fame charc20), ssn number Clo) Primary key , ledcrte do!
Pee gender charci), salary number(s), address vareho|
40)» SUperssn numbercie), dno Numbercid) |
[Table created
IS@L> insert into emp204 values C'£Frame!, ‘emi? Zinamf!
2ssn ,\2bdate’, ‘Rqender |, salary, Racdgress /-Lsuph
Ferssn,,&dno>;
Enter value for mi:
Enter value for iname:> smith
enter value for Ssn : 123456789
Enter value for bdate : @—jan-6s
Enter value for gender: m
Enter value for Salary + 30000
lenter value for address + 73), -fordern, houstan, tx
Enter value for e } jonn
tb
Laki Reddy Bali Reddy College of EngineeringPage No.
enter value for Superssn »- 333445555
Enrer Value for dno: S
\ row created
IS@L> /
Enter value -For ~Pname: franklin
enter value for mi:t -
lenter value for tname: wong
Enter value for ssn . 33344S5S5°
Enter value for fdorte : (3-aUug-63
Enter vaiue for gender =m
enter value for Salary : 40000
enter Value for address : 638, Mev, houstan tx
Enter value for Superssn: 8egeqssss
Enter, value for dno: Ss
Table created -
IS@L> Select % from emp204 )
BOL> Create table depart2o4 Gnome charC20), dnumbe
rumberC> primary Key , mgrssn) Number@), marstary
Ldate date >:
Tolle created
ISQL> insert Into depart2o4 values C'S dMame!, elnumbel
Bmgrssn , 'Smgrstartadate y:
Enter value for dname : research
Enter value for dnumber 1S
enter Value for marssn: 333445855
Enter volue for morstartdate | 22—moy- &
( row created
Laki Reddy Bali Reddy College of Engineering| Page No.
seu> / :
Enter value for dname > administration
|
| Enter Volue -for dnumber :4
| Enter value for MATSSN | 98165432}
Encex value for ma rstartdate : 1-jan -AS
l row created
IS@L> Select * from depart20+;
IS@L> create table depart—loc204+Cdnumber NUMmberci
e Ikloacation varcharC20), primary key Cdinumber , dlocat|
Fron):
Table created.
S@L> Insert into depart loc204 values CZdnumber , Ballo
reatton'D;
Enrer yolue for drumber: |
enter value for diocation » houstan
kK Pow Created
IS@L> |
® |lenter value for daumber .4
lenter value for diocation: Stafford
l row created
Is@L> select * From depart-loc204 »
ls@L> create tale proj204+ values C pname varcharc20)|
pnumber number) primary key, plocation varcharcid
drum numbercid))
alole crecttect
Laki Reddy Bali Reddy College of EngineeringPago No.
ISOL> insert ito proj2o4 valuesC Kprame', Spnumber ,
‘Rplocation!, Ldnumd ;
Enter value for prame : product %
enter value for pnumber: |
Eater Value for plocation : bellafre
enter value for dnum:S
\ raw created
SQL> /
Enter value for pname: product y
Enter value for pnumber : 2
enter value for plocation : sugariand
Enter value for dnum: Ss
( row created
SOLS Select x from proj204:
S@L> create table Work -at20+(
pberc2), Pamary key cessn,
[Tolle created
Cessn numberdo>, pro nun
PNod, hoUrs number CJ)
SQL> insert into work ct204 values C2essn, 2pno, Lhourd
Enter vatue for essn -12345678q
lentey value for pro: )
Ente’ value for hours + 3:25
\ row created
SQL>/
Enter value for essn :1234567189
Enter value for poo. 2
lentey value for hours: 7S
| row created.
Laki Reddy Bali Reddy College of EngineeringPage No.
SQL> Select * From work -ot204¢ 5
SQL> Create table depend204 Cessn numberCioy, dependent:
name charc20), gender charcid, bdate date, relation
Fhip charcio>, primary key Cessn , dependent-name)) ;
Table created. | ,
Is@L> insert into depend20+ ValuesCZessn , Bdepe rdent—
fhame', ‘Bqender', ‘Zedate ', \grelationship'>:
Enter Value for essn: 333445SSS°
enter value for dependent—name ‘alice
Enter value for gender :
Enter Value For bdate S-apr—86
Enter value for relationship : dovohter
\ row created.
IS@L>/
Enter value for essn: 333445555
Earer value for deperdent-name : theodore
enrer value for gemder=™
enter value fer bdate” 25~act ~83
Enter solve for relationsnip = Son
\ rw created
IS@L> select * from depéend2ot 5
| |DIsploy all employee homes along with their depart]
ment names
IS@L> Select e-Ffname, e-mi,e-iname, d-dname from
lemp20¢+ @, depart204 d winere e-dno = d-dnumber ;
Laki Reddy Bali Reddy College of EngineeringoO
a)
2
#)
»D
®
Page No.
pisplay all employee names along with their dependent
Idetatls
IS@L> gelect e-frare,e-mi’, e-iname ,d-essh ,d-de pendent—nare|
Id gender, d - bdate,d relationship from emp2.04 e, depend
20% d 5
List the names of employee who have ot least one depe|
Pndent
Is@cy select €-fname,e-mr', e-1name , d-essn,
hame from emp204 e ; depend204 d Where e
-sn 5
d-dependent-
ssn = dees}
Display name and address of all employees who wort #
roy research department
IS@L> select Frame, Address from emp204 where dno inc
select dnumber from depart204 where dname= ‘resa.
Prch D>
List the names of all employess with two or More
dependents
IS@L> Select frame from emp20+ Where select Count
cx) From depend204 where ssn = esSN)> =2/
ust the name of employees who have no depende|
Lnts
IS@L> Select e-frame from emp204 © Where not exs
Ltscselect '#! From emp204 # where £-Superssn ~
le-ssn);
List tne names of the employees along with the nam]
Fes of their Supervisor using alias.
BQ@LYSelect e-fname, S:-fName from emp20+ ©, emp204
Laki Reddy Ball Reddy College of Engineering
paS where e-superssn = S-Ssn )
pisplay names of the department and names Of mdrog)
er for al) departments
IS@L> Select d-drarre , e-Fframe from emp204 e, depart2
-o4 do where €-Ssn = d-mgrssn ;
ptsplay the mame of cach employee who has depende|
Lint with tne same first name and gender as the
lemployee
IS@L> Select e-fname, e-fhame from emp204e Where
k.csn in Cselect ess from depend2o4 d where e-fro|
Lme = d-dependentname and e.gender = d-gendey))
Ino rows selected
Taki Reddy Bali Reddy College of EngineeringEMPLOYEE
FNAME [MINIT] NAME
ssn | spate] AvpRess | Sex _[Satary | superssn | DINO
PARTMENT
DNAME
ONUMBER
MERSSINV M@RSTARTDATE
DEPT _LOCATIONS
LenomBer
LOCATION
prosecr
[ename | ewuMBER | elocation ] ONOM
WORKS_ON |
ESSN eNO HOURS |
DEPENDENT
ESSN
DEPENDENT- NAT
SEX _| BDATE RELATIONSHIPFNAME _ _
Jonn b
franklin t
123456789 OI-TAN m
smith
WONG BBSHSSSS
BoAtE _G _SALARY_
30000
~6s
13- AUG 401
Ses m 1000
_appress a
731 ,forder 22244
—n houston F355
(ta
638, MOv,- BRece
houston td Sssss
eae — zelayo AeABBTTTT (Q-TAN~ ¢ 2asq00 B321,castle, qa7gs
68 houston tx -+32!
oe wallace . 96165432) 22 oe # 43000 29) berry, gegeg
beraive ta SSSS
ee K harayan 66688444 See mM 38000 995 ,,Firecak, 3344
humble ta SSs5
sates a english 45354345 ora # 25000 S63, rice, aa
houstan,€% -S)
‘ames i. brog = BB BEESSS —I-NOV-E_ F S5D00 —n\| BsIT6eS
e ® .
'g
a4
nwdepart 204
DNAME CNOMBER MaRSSN ME RSTARTDATE
research 5 233r-45SSS 22-MAN-88
adminstraton + 981654321 Ch geem a
headquarters ' 88866555 oe a
depart loc204+
DNUMBER _ __ _ DLBCATION __—
' hovstan
4+ stafford
= betlatre,
a sugar land .
Proj2o¢ table
- PNAME __ _PNUMBER _ _ PLOCATION ____DNUM__ __
Product % ' bellarre s
Product y 2 sugariand =
Product 2 3 houstan, a
computer i) stafford
work —at204% table
SSN __ ENO HOURS ___
123456789 ! 23
123456789 2 VW
666884444 - =
453453343 > Ee
453452345
depend20% table
ESSN __DEPENDENT_NAME § OATE _ RELATIONSHIP _
33344555 alice F OS-APR-86 daughter
S5344 555° theodore m 25-0cT-83 sonb)
Jonn
Pranktin
allera.
jennifer
ramesh
Joyce
James
ENAME __ Sf
_ NAME _
smi th
wong
zelaya
wallace
noaayon
english
brogq
__DNAME _ _ _
research
rese dycTh
administration
administraton
research
research,
head quartersID | ENAME __M_ TNAME_ _ ESSN _ _ DEPENOEMTAME 4 _ BDATE _ _ _RELETIONSHP
Jorn b smith 333445555 alice CS-APR—8G daughter |
Leranklin t wong 333445555 alice # OS-APR ~86 daughter |
alicia t Zelaya 333445555 altce ¢ OS-APR-86 daughter |
jennifer SS Wallace SBE4SSSS alice 7 ares 86 chugnter
ke Marayan 33345585 alice S-APR-86 clughter
ee ' Ie f OS-APR-86 daughter
joyce a english 333445385" alee 5 ee oe
James e bog B3a44sss5 lice = eoaneey
John b smith 383445555 theedore 7 2S-ocr. : sch
leonkiin « & «SO wORG«—«-8344SSSS" Theodore = ™ oa
Litera. & 2elayq 3334455SS thecdore m 2s-0cT-83
jennifer - S_—Walllace 933445555 Thendore me ene 4
emest kK Rarayan 33344555 theodore = pas non
royce a english S38dqssss theodore ee an
lames e brog = Baa¢¢sS55 theodoreoo —
dD) FNAME M orNAME — — _ESSN ___ DEPENIDENT_NAME _
prankiin wong 333445585 ‘theodore
franklin tt Wong 333445555, altce
e} _ENaMme ADDRESS Lt
John 713), Fondem, houstan ta
franktin 638, Mov, houstan tx
| ramesh qs, Frreoat , huMb!e ȣ%
joyce SoBl, A ce, houstan, tx
#) ENAME __
franktin
FNAME __
ramesh
joyce
james
altelo
John
WwW) —ENAME_ _ _ ___ ENAMEE
Jonn Franklin
Net AK Jenorter
Dp] _ONeME os __ CENOME
research Prankliin
administration / Jennifer
head quorters james
You might also like
ASSINGNEMENT On Employee, Department, Dept - Location, Dept - MGR, Project, Works - On, Dependent
ASSINGNEMENT On Employee, Department, Dept - Location, Dept - MGR, Project, Works - On, Dependent
10 pages