







Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!








SGL fs^ hased^ on^ Reiatino^ Ngebra,^ 3. REFE RE TRC SE &EL Seuenhal^ tmlzh^ Gueny^ lanquoe^ whee xo
CREATE eHEMA)^ Cnn (^) A0TlOIenTio
CREATING TABE AND CONST RAINS ON T foREIEN CRTE TALE EmpLOYE No^ ir NAmE VARCHAR(i5)^ NO^ NULL the^ aie SSN NOI^ NOL, The
Sute Ssn CuPR ) PRimERY KEY(ssN) hen^ te tOREGN (^) KEY (^) (ue-sin) REFERENCES (^) EMpLOYE(ssh); Emploje
Fove igr de culeu, NUL bH defauit. h (^) Vactoys (^) dakadupex hat (^) ave (^) usee) (^) NUME RIC (^) cHAR(m), VAREN INT }icdelete mALINT t REAL aemtro (^) ctraato (^) ake (^) |2 (^) a SE CItCK (DNO>O AND DNO ) > chen Se^ loced the Netlcables ui Fa ev Relo
5 ALIAS ING it e ls (^) For each (^) empoee, (^) etveive (^) 4he 4he tiGst^ and^ oame (^) o his (^) Immediade utevvisor. ee 1n rCEult empeyee^ yt^ ard^ lastname (^) and FrployeeFrome, Mi^ nit,^ Lrame, (^) SShn, (^) PdaBe, Depot mentDam, DhumbeY, Addhexs,^ sex,^ saalay,Y-sn, he atiu (^) Mar-Employe (^) n, (^) Mgr- stoot (^) date ) Sutevisopo)
Boject (^) Cpnae, (^) pnumbon, (^) plocation) t0ls-O (Easn,^ pno, (^) tours) Depen (^) dent Esan, (^) Dependert- (^) name, (^) sca, (^) pdade, Relotionship). Aliasing Employee^ aa^ E
s=0CEmploy^ Employee ESSN N LN S sA) (^) SSSr FN LN ESS (ue^ ae^ doiq select^1 Cros^ prduct^ on 1oc theReame^ 2rme^ kkO it axs cotfor SELECT (^) E.FN,LN, S (^) Frame, SLnarne FRom EmployEE ASE,EMpLO YEE AS S NHERE E, FsSSN S. SSSN; TULES AND^ SET^ 0PERAT(ONS CBe the^ beycmd^ DISTINCT^ to^
SELECT (^) DISTINCr FName Atl the fnames oemplye FRom (^) Employee (^) ho cwoK Odept no^ (Wo WHERE (^) DNO= dupli^ catons)
No f ant Cmployee oo thid letter tn Frane ia 'vthe
name LIKE
No unnt to incvecose the olany o a the ermployees then
SELECT *
R toC0D^ SALARY^ s^20 td
Retveive aUst oemployee ard the project. they ae Dig 0, Ovdeed b depcoitmert and cothin each depoutmen ordeed phaboaly
b Ba^ C fiakrame c eDER BY uned to^ Ode the^ Dutpa
SELeT (^) I,.iu 11e, EFra, jct 1)e 1O NSER he Cem tpoyec Ai O u,^ noject^ P,^ Deratnent^ D 4ERE (^) DrumbeE.Dno AND E.an -32n AND W.NS= Pprn IN^ SE^ RT -INSEP CRDtR 3Y Doame,E.Lname, (^) E-trame e (^) deloult o CRDER (^) By t (^) Azcendng (^) Ase Nod, Dercendinq desc=^ Nol vaues deault
. (^) ExAm (^) pLE (^) ON (^) ORDER AB select ABc (^) ERoM R ORDERBY A.BC L. DEET NoD then, DELETE DROP
12 DER The tosle e
n GL Cve NOLL Cnsidened to he diatinct * to tet) toith hern tuo re Cpeadi3. S"^ ANn^ "1SNOT^ ate^ Trt odcn.
13 IN tirnd od a4fe Frames Aldheme empode
SELECT (^) tram Acddhes ĆN R ON
INHE RE (^) Dno IN (1,2,4)
DANO: 2 Dio 2 v ONO: VONo Fnd^ FNme
Rod rum, Acdcs c employee uho wcx fn depzmtment tocation SELU CT in Sttord FRON SELECTFmme, Adhen WHLE
FRO EptoATOS S NENTE
DNO Locati RE^ TRIEVE St
D 3 Sotd StLECTLD FRCEA (^) Eve .ANY.SE LECT ALLDISTINCT SomE En HERE
Trianduced P^ he^ Sree^ Guemy (^) iI (^) give, 9 o TO A Cho (2o0)^3010 (^1020) The Cudo Gueny praduces The (^) Guesy s (^) fnd out ail^ he^ Enplorys e 6N SomE (^) ho (^) Fove (^) ec cn (^) C (^) poject ON ANy (^) Oaohich Employee no-1o has uted the (^) ame no (^) o (^) Houn d FNhme a|l employee whooAe alamp Ts qmeadon tian *e a a empoyee in defuoment no s 2ent locotion (^) SELE CT FName
WHERE (^) SLDRY ALL SELCT SALAR
OHERE (^) DNO S) 5 NESTED COREL RETRIEVE the fsame oeach empcyee who has a perdert wth e me trume and is he e c as e employee
FROM EMpLOYEE AS E
INHE RE^ E. frome) e^ D.^ Detendent. rae AND F Sex - .sea ); ON h^ e 'to) fer
caces 11.^ Ex^ IsTS^ ExAm^ plE Listthe Frames (^) omandgey ho (^) have (^) atlest (^) one (^) dependent
FROM EmployEE WHERE EXISIS^ EtEC FROM (^) DE (^) PARTME NT NHERE SSn=Fn) AND ExSS (SELECT* FROM DEPARIMENT NHERE Ssn =May-ssn
NHERE (^) ExISIS (SEECTFROM^ DEPENDENT^ HERE^ SSn: (^) En) AND ExIS1S (SELEC FROM^ DE^ pRTIENT^ WHERE^ ssn^ Mgrn Deperdest (^) Depaseet fG-1on) FN E^ f-ton)f k ton ExiSTS ExampiE 2 oing RetreiveCortxolled^ t^ depatmenthame^ achumbe^ employee 5.^ o^ uots^ on^ authe^ ror SELECT rame FROM Employee (^) RITURNS Tu
FRo PRAT ECT
r=Fssnis (^) NoRKS-ON NHE RE SnESsn); Enp (^) Project NorExsSIS SSUFN Foum Drum PNo
fayi (^) oit be (^) printed
19 JOINS (^20) AGGR
ON NODNtnbe)
ean h (^) Eno to T thane,Lrame Adohess TRo (EmpioyE NATutA Jol A pait s (^) EpT (^) (Drorne, Dno, Mn, (^) MScdate)) e RE Ome estotih ttect (^) home (^) AS (^) Empe (^) OYLt. rome LNcaroe AS (^) iA- FRot (^) (Emptore e ASE (^) LEFT OiER (^) JotN Cmpt EE AS ON E.Se n : S. san ) e Naketai SEILcT
ABD (^) hin,
eect sLt anjoin) (^ (R^ der^ jon) AN. data SELcT elec
a AGGREGAE PUNC^ loNNS 7.^ TRANS
ATan8acta Tinolay) I pial^ uniB min(DSTINC SrnRY)1 (^) hans (la (^) Son(tlaig) max(uny) UNT al) max^ (lsTINCT^ ShtPYl=
23GRoUp By
A Le u Cc= te , e eect (^) ern snop bu
RiA)-
A CouNT )t mR
tCep (^) By clause (^) ther) (^) lhe 3houlcd (^) alutuy" p (^) i 3eled (^) cause OA)- tlo (^22) rons acdion each (^) depet ment, Ret (^) efve (^) the (^) no, the (^) num (^) oh (^) tmptoee Aori citr Cosi enc
e (^) dent (^) rnent and (^) their (^) aveKYe (^) tly ) Isdaio
-0, (^) (outnt (^) C), (^) A (^) Yg{ala
e (^) tae (^) oil (^) enln a (^) 7epeale Gx, (^) (y Xah^ 1li