0% found this document useful (0 votes)
34 views21 pages

Adobe Scan 15-Oct-2024

Uploaded by

Adi
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)
34 views21 pages

Adobe Scan 15-Oct-2024

Uploaded by

Adi
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/ 21

DBMS ASS JENMENT-2

Norne Sauya
% Ra Sernestox : d
Ado, No. 6- 283cSE IIE3I
Cousce ? 8Tech CSE
Setien' 18
al. sn the cantert e a elakional model, dicuus oah
cadh

the fallouaing coneept


(a) Rotaten
sealatonal molal , is a samad sot
A ealaten,,un the
tujples , lehene each tefle supasents in
dt's analogous te a table
e

sclate valuss. coueesonls to a


&fiwodshet Gouch oug n the table te an attibute.
ech column coiasends te
teuple, and
(b) Attibuttas
Attsibutas aee the amed pepsdis oalums af a abla
dapine the
a selotien. They peatie dhta
eoah aHeibute has e vales d can
doteununas the kind al
Sing , dote ) that
heal
oe in a seelatien t uafscsants
A' euple is a asinglealuas ,ench coeypondang to a shacfa
a colleolien custor table, a
atbubte for earnbla, in a
mighi wepuaert a QLstorne witth theve mana,
addrass and contoot anformatten.
(a) Canoliraliy
Caudinaky vles o the ruumbor o tls in a sclaten
ncicotas the nunbe o
table
(e) Demoin
tat an attibte
A doman tthe st at al pable valuas
paytaar
Can tako St dalinos teng af acceptablo valuws er aQtibute:
@ Dsouss the vaipus tyfpes that ae
kaya thod used sn
Helational molol.
Angi gn olatnal modl, keys ave used 4o uniquely idarky
tdas ethin
SOme ae dascussed beloes
() Bámauy Key ? Ameng the candidate keyb, Gre is chen
as tthe puny key . Ths is the unique Sdertiticr
dn Customgt
7ot ooch tuble n the eloction> Fe g:
table, CustomonD coun b psmay key
Forg an

attobte) in one ulafien that eales te tha pünoy


koy o anothexalaian. dt estoblishas a walaliorhipP
batseen the too valaiens, oten inelicotng a
dapenelancy oe asoaialon. ores An 'Orelar'akeation
hane a' Custome attbute as a
might
(D Canddate Keyi ACandidato kay is a rinimal per koy
t a et
Cannst be untheedced uithoat
oach tuutle and

() Campolte Kays Acantaste a pomay kay ton


koysttributes.
that cots multipa sAis
seo ehen
ongle attaibute cannct

() Altoscnato Key 3 Any candidate kuy that is wot chosen


called an altate ky
pYmayCustorestb candidate kay (auy):
Safockey A
engle atAsbute
Cenbihaieu
Custms D, CustomenJame, Atdoais, hene Nunbe
, aliinai wulatans,
heo fecon tupla alConbins
l (u): unon Sat 2.
welatous. tuso
oheates Cheatos TBinany
Suda
nenmame
mame attbute
teChanget (): Ronarnig
(enplaye) 500ooSalany>
)
condou geen'
þased elaien toma tatles Sulects (o)iSaleelkcn 2.
(enlaye) SolaNarte, Exanlo
st 6
An(R) A2,- A, Jl
Sytax
elaten.
-a
Agebea Ralatianal Sfeuatos
dlatalaes
matthamatcal
conley ayprss conbened
to becau hat
at 'oidesa
set sA Lelatioal
Jarguag
manspulada
daba quydatoßaes.
nal t sed
Rolatanal As?
ie algbeaselalioual tela by
bymaan
mean you do ha GB
l
R-S
Eanle r enployee - Manage tefles thal ae un
4. Set 3ateseetio (n) RatuensR and S,
bat

( ) i fois ho alalious bassd au


5. Naksal toin commou ettibetes, elinialig

Sylaxt RS
Sme enlaye Dapasutmant
speci<iod eonditian.
" Syutay ReS
Dutastnant, Salay
baaatment.
men steuctue o< ellional

deman the eelatanal mmolel.


Ans Sisuctue o Rolatkaual Mealel -
he elattonal model coneebtal foamewcl
olala
Aelatenal mede
The' stct c
dazined by componuta
whee each
Bles,
ale ouprsands colleátiou o! latod vals.
Rota
elational' model
2. Atribute b Amamed chareterisie
Pp the amns
toile
cteibte' fake
'colleko values, eaeh
speafe atbute.
Kay Aset ofKithin tuat wigaly idantis
atuabdescelateau
onaaints olateHe
Rues that etoraewitin
Qund
latabase n te Relatiol Modeli
* Sigutcanee o! Domain elatiaual
cucial ole in the
Jemans play a
Data Vatidaloe Domains daline te valid sange o
yaluas or attbute Trs helbs to enswe
afpreiate data u enteved to tue databas
"Jata
attbte oie caun a catlau
Buch as
as ensing thatvalues ar
oet. wed
epteizatian & Domans ean be exeautoa te

types for attibetes, This enscs that


(snupien andl inconsiencles'.
Sehema Detinitoni Domawns are wsed bo defle
the schema o a nelatlon, ohic speoifs
the tactue anol

ae endameutal to mantabug the


Domals dala
and
dalabedes.
Satagty
by Ralntional laleulus haf
elateal enlols
cleclaratiue
te quey and mapulate date cin nattaal
dlatalbases t procdwae
wolich ocses what ata mees to be
conditlow tat tee
suticuad
dala
by peto
m spli
must
based on pedicate leghe, whee qusnies ae
t is
pressed as
(rons).
hee se t e mowtypes relationad caloulus s
fuple Relotisnal laleulus CTRC)G
Qe
salatfoa (tade)
baed

Foums ft | Pt)
t shularts At. Age >204
" Byarnlle G St |+e
2. Doman Ralatioual Caleuls (DR) ave base
Aelecling ttibetes vales (domains)athe thau
ae
eltaibutes.

" eyanbleo f<Narne, Age> | ulards (Nama,Ag) Cge>9


betuen TNNER JOIN & OUTER

Ans tNNER JOING


dnnex oin etwns anly the
matching valuus ath tabes
os n ethen 4able dos not
na houe a
n

taba FROM fabl


l.d
TNNERJOJN Table 2 N Table
Table2.idj
Tnn Jon
OUTER JOIN:
e oe both tablas,
nateh

JOÍN : Rotns al suouss Loem


frem the lalf eble
() tEFT oUTER 8
ig table. Uwatehad
and mateked ess em he
thm the bogt tasle oilecoutain ULL Vales.
Habialoa 2

s01N Retus alL wous oom the ight


(t) RrGHT OUTER
table and mateled

toblel able2

Reens all os len bott teabls.


) Foe 00TER sOIN 6 eset ie osntein
asntaun
thee j ne maleh, t
tthe nen nalehis
NULL values un te coimns o n
telle Aabel toba

tso oe mose talbles based


bteen Hheno
econds mateing as
etrieues that on tyfeas weell
JOJN OUTER (3)
BA A
e luat be
at dihsuld thee dh ’
!compevissn nane Jare Be utellze not’Dses
CM) fon Noteat 2)
6.ColuonB
t6) RA.Cclumê&-
B)cnitieu eqivalene
nnes yon equu )
and.B) fablesA (hor 58ser A
,# , <,>, incde
aubased combied ane etytables ushsclh
pe a
mne
tebis? todel
eeñdeten jen tre match that
tein
es both
ÍOIN INER ()
foun ute (s)
son Natoal (2)
gen equi
Case
Seueal Jheee
’ (xamay dale mengd aheld be cin agt sile.
A (A DO B)

aide

A (A B)

Cuentes
both tEF T J0IN and
Contein dl ess luon
conbog
RIGHS doT
Loth tablas.
’ For the
the reseult wll outan NULL
Kohich ee
ales
matdhig
(A DT B)
68. heite shot nates en the

DML conasts ot SaL connands that alous ass to


ubdata, nd dadote data
vutailse, ünsnt, ubdota, na
datalase
Comnands ed: SELECT, INSERT, UPDATE, DELETE
Llsed to manage and manpulate dala ater a tabe
has been eueated usi ng DDL
(i) Data Definitou Lagge (DDL) dafine,
’ DDL conilsts a sQL commands ued tostlos
altar, and manaae database sehema
Ctables, ineleyes,el)
Commands wsedB eRATE, AurER, DRof, TRUNCATE
the sfauottre
üi Juaockien Contscol fatemewbo, (1co)
’ TeS ae SOL commands hat manoge twwatt us,
he

Cemmand used: COMMIT, ROLLRACK, SAVEPOINT, SEI


TRANSACTION
tlaed to coudyeol 4esaios cuel onsue eat oll

(v) Data Couta


%
tongug
dota in thedataba

Cemmas sedi GRANT, REVOKE


’ Ubed to mansge seeuiy and aceas contrel datatass
shont motes Anbqushís and agggat
Aes Subauóas
mestid iside anothe
(such as SELECT, NSERT, DebATE oe DELErE satements)
the man quat thee
-usdes Muti
Coelated auqy. Subquenes
daba, peajom caleulatiou
Aggregte funeions
AggoteB uekos
e npofom
a
caleulasious en asd o
dunale value These tnetbs
cemnay GhRoUP By elases fe
Summoou22
Common A4gugat neiens
CoUNT C)3 Rekns tae nunb
SUMC) Retuns tue n & valas a celunMno
Ava C)I Rete tha numee
aslemn
MAXC) Ketuns te maum alue uh
MINC) Retns the vale a coluumn.
Uaed to petor matematical and tatit anl ealaulakios
PROBLE BALED ON SQL GUERY AND RELATIONAL AtGEBRA

ai n e names Acd paat


SCLECT DISINCT S.Sname
FROM Sujppliens s
TOIN Cataleg c ON s.sid e C.sid
JoIN Pa p ON c.pd p. ped
WHGRE p Colg ="ed';
H

heen paat.
SELECT DISTINCT C s
FROM
JoJN Pauts pp CN Cpicl po pid
NERE d! oR pcolon 'geen's
Some ned pot
ge at 224" packet saeet

fROM Suplins s
LEF1 To[N Cataleg c CN so Sid c, sid
ON
OHERE col ' hed coR S.ads 221 facket qrec;
sCme ned past
gen pant.
SELECT Co bid
FROM Catalag c
JOJN Posts p ON e-pid= prpial
WHERE P: cels ON opid pPped
oRERE cole IN (Aed
GROUP B Csd
HAVING CoUNT bISfIAct prcolen) 2j
e. pind e s

FROM
JOIN Paots ON Cpéd - ppil
OHERE P» colo lhedr.

HAVING coUNT ((STINCT copid) (SELECt coUN (bISTE Cr


p pe PROM Paate P p kHERE P. colo e'aelt

stECT C.i gaan peat.


FROM
JOIN Past P ON copud
boHERE p.colea N(aed'feen)
GROUP By co
HAUENG, CoUNT (ISTÍNCT Ceopid )= (SEEcT COUNT DIStINCT
FROM Pats p sHERS p-coles zN (ed'y gua );

SEleLT Csi
FROM Calaleg c
JoEN Pats ON copid = ppid
OHERE
GRoUP By CoC si
HAVING CoUNT (MSTI NCt Copid)(sEE CT COUNT /BTSTINeT
P' pad) ROM Paats P Pcotor
UNION
SELECT Cd
FeOM Cataleg C
Paats pp oN C.p-l
JOIN Pauts p-ped
1OHERE þ. color = 'geeu
GkOUP By
EAVING (oUNT (ArSTLNCT aopid) = (sELECT CoUNT (bISTINCT
ppid) FeoM Pals p ohane p cola ='pan');
een'
sidarqs more some past taa te sppliea
sELECT cd.si AS s&, 2. s ASsid9
FROM Clalog cl , Calaloy 2
OHERE el. Bide c2-pidl

gelect cpid
ROM
GikoUP By eil
HAVING CoUNT CDSstINCT Coco sid)>=2;

fhe same clos


cowpauies tor iich'e!
SEUEeT eo emploe_ame
FROM e , Woaks
WHERE Cemfany c
AND
AND e conta company-Mame
naned
sELECT
FRONM hSoaks w
WHERE w: compuy
mame eonfaus
SELECT Mo
Maunaga-Vame
FROM Manages M
wHERE
M. ewloe name LÍKE

all tee Vandos wo sufoy


prodleds
SELECT oname
FROM Vande V, Paoet
WHERE
GRoUP By
HAVING coUNT (Pp-code)2;
() t datails producs .ase paicss exeeed ta
aneg preduet pie.
SELECT

LOHERE eice >(seeT AVG, (Aice) FROM frodst ;


, addas an hgne of yonds ho
proaut.
name, s addaess, v. phene
PROM wendos V
ORERE wv-cede Not IN (SELECT P. v-codde FRO
PEeduct P);
(iN) st wame qnd phene wnhe
al prodcke
$ELECT
FROM
V,none
wendo
nephone
v
tonERE NOT ExsrS(
SELEET
FROM
tp-code
OHERE

) Retaieue the nane the enloye waho weorls


tae sane debateut as
eNMe
FROM Enp E , EMP R.
bOH ERE no Ro Dno AND Raae 'Kon':
( ) Rotioe the no.
hamel Raut',
sELECT coUNT (D.Dep NJame) AS num- debendents
FROM mp E, Dependent D
ohERE E. SSN = DESS N AND E Name = Rau
ohe hae
SEECT EName

wHERE E SSN = DL Man SSN AND


AND E.SN NOt IN

SEECt Do ESSN
FROM Dapendent D
OHER E D, Sey =lP,

mese'than bo000.
SELECT EName

\OHERe Eoo 20 AND

defaalwnt delails.
ROM Dept
ORERE Dnam l0se,

ind ae names pat


dallares
TLS name

(Pat)
(b) al he
pat
(fasts))

foats. pid =tatalog- pid (ala'gn'n


bat LI0o) (onta))
<Bo o and
gren paut too.

nan
te brandh 'c
SELECI Koll no,arne
FROM Student
OMELE BAoeh ' Cse';
(1) knd he name e fe sudent sho has issued a bock
published by 'AB publihen
SELECT SNae
FROM ult Sy TssueI, BockB
FRoM S. Rol, Ne.= 1.Rel NO AND T.tSBN = B.TSSN
AND BoPubiche z 'ABc';
all bophe and taia atnos seud
bude namd
nned Ram',
sacct B.Tite, Bstuta
FROM Boek B, sue I, Sheeni S
AND S.Nane = 'Ram':
iv) tist Litle all boples
Danbe s, 2s0.
SELECT
fROM Booe B Sss ue I
WHCRE Bisß N= 11se AND Jta. a- Jssue <= 2000-12

SELECT tile
FROM Bosle

tating Laet= 'Jones' (reachA enmsly)


() tut all shudeuts taleing otleast Bne couse that
aliser teachot

) iat thase eless who teneh mose hn oue


SELECT C+
ROM Teach

HAVING coUNT (bSINCI Secion) >1;


jvy ist al atelent mwnsens anel
StCT Stt
FROM *Enmgl?
(v) list he tulent number
umber nal munbe
SELECT St, cf
FROM Gaade
WHERE Guale tA';
Pin names
rt.nane 'Mioma lemployee))
2e whese salary >
1oo000.
salasy >loocoo (entou)
( ) And the names emjlope ho Unes Miam
ad saleny
hame (o. cty-'M iarné Salay >loopoo (eafimy)
(iv) fen name el each beme A
tt banndh. hame (a- haanchcty - 'Chcago (branh)
() eind the Ib of each bs41eu who has o loan
Dounton
T-3D (o- bhanch. nam=bougntoon(lean M
bosae)
(ú Rotaioue nane, addsass. and salasy e eneges uoho

(n) find he names all pmaiet


Coutnall n ditatmat mo, 4.
TL-Name (Ennp)

n
ale employees who atha uoale
Snfaause an
enloye who nosaks in defaahnt

Supes SsN
EMP. SSN))
(iv) Rethieue te ames enplayas ho have mo

t-Neme (Grne) TL NamelEMP DEPENDENT)


() Rethiue 'eac defaataant

tt- DNo, CouNT (SAN), AvG (slesy (CMe) DNo)


besle Fisk Bony coafoatien nd ean moe than
$l0000
SELECT e-emplayel -name e sisoct,
rROM empleyee e
ecity
ON
AND
LOH RE vo conngname - RAst Bant Cotpoa tian'
o. Saly> lcocoj
names

seLEcT eenfiaya n -nare

fRoM enploye e
BoZN \Ooks w eN eelepe
varne - C" companame
OHERE

names o all emhleyees ueho ive sn tte


Sane y and sihet as theis nanagers.
seLecT e'unplogee
FROM enleyle e
JON onages m ON e.eicyee-rarna : m. narme
JOZN ermpleee ancge ON Mmang-nane
morag. enlayaname
OHERE e-ty

Banie Conhoraien'.
sELECT w.pessen-name
PROM woks
vOHGE w. Company-name z FastBank Cantaaten';
Cind tee hanes and citess & eilenee ef all
Bank totoation'
GCCeT epeon name
IkOM omylogee e
ON e-peason-vame

moe han haee


aiNot 7il the ailan Ma
which
SAECT Co eid
FROM cerijicd o
GRove BY Coail
HAVING coUNT (C,oid) 3;

to Hone,
SELECT eonae
CRONM empleseee
wOKERE esalaylLLCT MN
OHCRE 'Les Anyeles
Honaluleu;

asont.
SELECT DrSTINCT eane

JOSN c ON eeid = ceiA


TOIN Aoat a oN C-oid a anail
OR ERE aomame UKE Boeirg ';
al he alsoateat can be uied
reutes tom les to 'chigo
D(8TNcT
(ROM Aiat
IoIN ed
JON
Los Angels' AND oto Cicagp
(a) fin may
saeoy naach dopastmal
saRt dapt-id, MAX(Salay) AsAs na. slay
ROM enplayes
aROUP BY t. i;
b) fin
hag
sELECT dapti, AVG Csolay) As aug salay
PROM
GROUP
emios
tHAVING CoUNT (enp id)> 5;
total

GEET eoUST (embid) As Toal emplaes


FROM

seLECT
ROM
dett
GROUP By datt id
HAVING AvG (Sala)>sOoco);
(d) ud names depastnents uotore no
a salar highe tean 70, o00.
sELLeT datnane
FROM Dajcs.imards
seeeT DisTINCT eodapt
FROM emplaess e
ORERE e salasy>70oce);

You might also like