0% found this document useful (0 votes)
91 views20 pages

Theory of Computation

1. The document defines and explains different types of keys used in relational databases like primary key, candidate key, alternate key, and foreign key. 2. Relational algebra operations like selection, projection, join, and rename are explained along with their symbols, notations, and examples. Types of joins like inner join, left outer join, right outer join, and full outer join are also covered. 3. Examples of relational algebra expressions are provided to demonstrate selection, projection, natural join, and rename operations on tables.

Uploaded by

parmar pratik
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)
91 views20 pages

Theory of Computation

1. The document defines and explains different types of keys used in relational databases like primary key, candidate key, alternate key, and foreign key. 2. Relational algebra operations like selection, projection, join, and rename are explained along with their symbols, notations, and examples. Types of joins like inner join, left outer join, right outer join, and full outer join are also covered. 3. Examples of relational algebra expressions are provided to demonstrate selection, projection, natural join, and rename operations on tables.

Uploaded by

parmar pratik
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/ 20

Onit-Chaptex = 3 Relatiomal u e sy anguaye

Assignment = 2 Date

Sub Puxuni TluKKumux Hemantbhui

Enxollement No 19018010
104056

FTimaryY
1.DofineSupeK Ke Cndidute Key amd
AtenateK e y

A Supex Key is GSet ot dne oy


attxibutes hoso Values Uniquely
identities Rach KeCoYd Nithin
Koltion (table

WWK Pinmudy Key


Apximax Keu is a_Candidte Koy
thatis chasnbydutaba dsiymey
toideatity tuplis uniquelyH in a
Kelation (tahle)
Oneod MaQ CUibte mC b
on pYimaxy a Kelatioy
Can't bo
Nalue- doe not Chwns-

(3AHemod Key is
A (andidwde Ky thcd not

KtGsNchos@nby duuta bay desicn2Y t0


Uniq uey i n a delation
idendu HIp]es

Foseign key- used to ink two


Re9_ FoKeiqn_Key Is
gelutions (taplLS)
Date
Page

A foxeign Key is an atbibute


ax callection - Gttihidtes isone-
tublethut- KPXS ho in0aiu-
Ke cnatheytablo
A tublQ (taininq he toxelqm Kay-
iscalled the child tblo and
the tuble cantuininq the primaxy
Keyis callecd the puu ehle

2 Explain follocainqRelutioncl AlqebYa


0pexation with example
SolectionOpeKcto
Sumbol 6Sigmc
Notatio1 6ontitio Relatio
OpeiadtionSele cts tuplesfom b
xelation that sctisty a
qiven Conditiom
OpexatorS
A CAND)N(OR)
Salection dpexocto examp le
ernditen- (relodion
Lgranch CE Students)
BramthT CE ASPI> K (Studeta )
Beanch=EE VBunth=
ME (Studen
Date
PAiga.

Write docan t h e 6eltioncu alLgebxa fos


t h follo.caing tublo

Display the detail o f all emplayee

Emplayee_
Emp ID Name1 Dept SalaryL
101 Niles h_ Sales 000Q
402 Muyus HR 250000
103 Haxdik HR J5000O

104 Ajo Admiml20000

2 e c t i o n Opaseto

Symbo Lattxibute (Relction) I


=
Notadtion Latxibte s e (Reltion)
Opexatian=Seleeis Spacitied attribuky a
el ction
duplicete tuploz
(secoxd m he Kesutt

Wite downthe alqebiC fo tte A.oruiuA


le
Studon-.
Roll mO.|Naua Bamh SPT
o Ray CE
lo2 Meet ME
o3 Harsh EE
Punit CE 9
Dote

Lisp
of lay xal na, naae af SPI cf al
2Tple
Student
otro ameSPTsona Stelerdt
R1*
Qtput Studet
Roll no NamoSPT
Aa Tuplay6-
Ra
02 Mpet
lo3 Haxch
lo Pumit
Ra2
3 Coaxtejiam_Podut_Llxoss Rraduet
Oymba X (coss)
Notution Relation-1 (Rai)X Rolatim-2 (R2
Opexatiam Ttil mu tiplyaiRALh uple
at Relation 40 eauhtupleg dt
Peluton-2. 06D
Atributeof0 f Reulttunt Relutio
Attxibt ofR+ AHxibudy af Ra
of Regulta Rolution uple

E both xelotiens hu Som0attaibute


cith thoSuaga. (um be
distinguishedby cambing reldiom-_
name cdtoibute-ncime

Rall NO NCn (Studan) X IRallAlo SPT , RL[RO


Date
Page
Notuxal Joim CInnexJoin)
Sumbol X
Natution Relution-1 (R1) PM Rolution-2
Opexcction Natusal A2)
jain I_ <etxieve
Consistont duta ho
6elucionS
tublestrbte=t
liple
5 t t Combime ecords Kom
o loctionsthct diffexent
Sutists a g i e n_comdition
Steps
Step- 1 t _ pexfoYmsCastesian Product_
Step-2 lhenit deleteS nconsistent uple
Step-3 Then it moag am_cktxihte tcom
L dupliute attxibute
Naturc JoinCTmex Join)

Select Coluha 0ame


FRom table a
anex Join tableb
ON able a (ol-nam tableb.col_hayne

OudesJon
Opooong In natux jaisame KeCrd
OR Missiny- we ant that mìssîn
huweto e uteYjain
ecord thun
Dete
Frge6

Types hxee types ct Oude Toin


Left Outex Jcin ANB.
SRiaht Oute Jaio (A KB
Fl Outex Toin A
Left OudexJo A B)
taetusns a h KoNS amthe
table- thelefAieveit no
mtchinq saws hwe been toumd
in h tuble th ight Whey
no matchinq Xecoxd foLnd i n he_
Heblo o
HAble th ight NULLis rekuvned
left Otey
A B Jo
A
Allousrom uft Tabl

A NB

A LAg R
Num Squre Nurm Cube Num Squg Cube
2 S 2

16
39

LRight Outex Join (A E B)


etuxn al
he uble O h Kiqht g QVON_f
no cotchimg- XoS
hawe been 4ound
the ttble on he lett Whee no
Date
Pag?.

mutches hANe beem


table on the left
foundin the
Null is Rtuene d RIaHT Outey JOIN is
the 0pp.asite LEET JOIN
e.Kaapl e les sSumo tha yau
meed to get he a e at Me mberKs
and oviesrentod bythexn Naul
haw ne u membey whohay
not nted any aaie ot

A D B
RiyOuwtev
(A Join

AlL xodas fsonn Rîghi


Table

A BB
Nun CLubeSquso
2

Full Oudes Joio AX B)


Join alltuples Íona
n a ulA_Otex
bath reltion axe included in the
xeult 1IKeSpective of the matchLng
Condition
Date

A B
Num Squxe Cub&
2

Thexe xo muinly tua typas ojoins


in DMS G)Inne Join (2 Outex _Join
A n nnel jainisth widaly wed jain
apeiaticn Consideiad ay a
clefault join-tp

An Outejain
jain_dnemt equjreecu
Yecosd i n t h e t u0jaimiahigs
0 +o_ha
C A.otchimq XLCOxd

Outesjoin is fusthezdivided into


Subtypes are1 Lett Qutex Join
2) Riobd Oude Join G) Ful Oude Jaisa
The LEFT Outes Jom tuSN`Lcdl th
sosAaM he tuble an the lefE
mctthinq OS
been foumq the oble_cHhe

The RLRHTOutt_JsinKltuTms a the


Col umnS a m h o t blo on the Ieft,
DaBa

matching s s howe bee


found in the table On tHhe et.

(6 Re name OpeSotoY_

Symho p (Rho)
Notation ACXL x2Xn) Reltion)
Opexation The xenam apexato tusns an
isting 1 selutio umdex C nea mamno
Haw
p x (E)
Ketuxns a xelatton_E umdex a nR

A1, A2 AN CE).
Reu G elution E undRy Ci ne Mamae
Tenmed to
A1 A2 An

Kenanm pe<ctoy 2xCmaple

Student
Rno Novme SPT
101 Raj-
02 Maet

PeLso(Student
RmoNameCPT
lo Ra
0 2 Met
103 a h
Date
Pege

Student
Roll mo Stude Namecp1
loi Raj
M20
SuRh

6 DNisia Opaxatoxl
Symbol

SNatatian Relatia 1 Relatiom2


Condition to pex toxm Oplatiom
Atibuteg of gdutio 2 ipxape-
Subset attsihute ef election L.
Opa Sctio
The Outp of the divisioa
ill hauo cdtxibute
opeKta
=Al| attxibude
Telation 1 ALLttsibutej f
ylatiam 2
hene Oudput 0 he elatio J, which-
aSs.acidted tth the aUL iple-
Kelatio 2
Date
P7 2 U
List thes a m e0 f Students doinq C
Pxajeciin_ techmologies

Student
Rno Name Technalogy| Pxopect
l o Raj NET- TID echnalogy
lo Raj 1phone NET-
jo2 Meet NET 2 PHP
J02 Meet PHP 3
IPhome
lo2 M e2 t i Phone Androd
lo2 Meet Andxoid
lo3 Viicuy PHP datputE
Jay NET Name2
loy Jay PHP Meet
lo iPhone Jo
lo Ja Android

lpNameTchnalagy(Stud2nt) Fechmotog (Proec


et
plaln-
3 Explai0 diffexet ggegate- functions-
with_ example-

Symbol g os G
Notation q tum ction ncme Ccolumn)
CRelution.
Opexatioms It tuke C mor thano e
Value a input anc eturnS C

Sla Nalue2 Gutput eud.


( 13C
Agaxeqodto fumctions
iSu (1 etusns_the su Cadditian
Naulueg0t
taCa-lumn
Max xekanthe aimuonsralue
for acaumn)n
Min(Tsetum he nimiumNLue_
fox calumn)
Vclue to a Celumn
Count (T Teturns atal mumba OE-
aulue qivA ColuMn
Sudet
Name CPT
sumCaLPT)studnt
Rai
Rohit &

Outpt
SU m_

w Min (SHudeat)
6 CouwndCCeT)Min (Student)_
Ou ptat Outpud
Cout max
Considexthe folloinq elationa dukubase
Cheye he pximaxy_KeySex Undeslbaed
eipLSSioa i the xaludion a
alyebxa toRXpsa eaehat h e folloti9
iNalue quxie

ue Rmploy SSn Mamedno, falmy, hahh.ysend)


depaxenn.ent(dno4 dname4 budet,lacutianmgrssm)
Workss on SSnpno)
pjetPno Phamn budget Locuta+Joaly
LList all paiKS Ofemploye name aacd
Pajet mumb2x heu Co«kS

dint Lpso-ome- (emploepe D woxKonj


2 List aut depactmen na depackamet
ncua emddepartnent buidg.ot
Ldepne dmamebudya DDepcux tmet

Listll pcoact h Roj2jh Kumay


udk SS_ by pxoject name

aamtPnemeemplay.a rgect)
oP
T.
lpnone- Oncaame= Rajuh Kumay pA (WoYks Om)_
(Proj.e+) aployA
eaploye@ ho5upeVise
hems g -
snaYte Ossm SupesSS (Employee
Dole
uge

5 SA Cansldex he fullawincnelutin.
dudabae Ldhex ha pslma iy-kys
aseundeslined. Givesa
CneLpseISia.
the Ulitiomcl alaebra-
-Qth ar heollatbmgquexig

CauxseCouxsa id, title_deptaamo,Yedi


instsuttax id Mratedept nam Koloul
Secon CouxsQidSe-dSPmgjtey us
bualdins ooma-notme -slotjd
LeaahoCid CourIPid_Se-idSennegfey

iAstruutas
in fhe physîcs depaxt ment

lpamaLOdapt ncam Physcs"Gastbucto


2.Fncell hocOLTO tauqht iin Ahe
Hall 2019 Semestekbtndt
Sping SexaestR
Teourse vei
CouTSe id teuche. Couse f
Saashy Spcbag Sc oti
3. ad
mstiudtoxs n the Comp_Sci.dkfaxhet
togethe ithsa he Causse tHes
Cauas&s e 62msdauciuxs
teuh
Date

Thame titteOd@ptnuma-Coap-SC
instrcLctox teulhes corse)

Salary n_euehdegartmend
dept -name l dercy (salay Lintutto

TLCosu3e id 6gamagte ="FalL AyeuE


2019 (satian))

Exexcise-1

site Wxite dotun_ xelutianalaluah fa


falncdi duta.

1Display the detail af l emplayne


Tnput Emplayee
Output
Emp T Name Dep:t Solury
Niesh p Sale
lo2 Mayui HR 25,000
Hondi HR 15,00o
Ajay Admin 25,00G
Dote
Page

2 Displas tae deiailof mPloyee


ohoDse laxy aas thaM load.
Tnput Ogalaxy>loooO(Empoyeo
Otput
Exap TD Nam Dept Salu
Mayu 25,o0
03 HcedikLHR IS,o00
Ajay Adsa 20,00o
Displayhedrtarl st emplose
belongs HR Dopthving Sulany-
MoK ham 201000

mput_ 6papt HR A Sukuru 20,00.0


(Emplay
Otp
EmpTD_ Nam Q Dept Scury
Mauu 25,co0
Psphg he dotloi &mplayRQ_ belang
H eHhex HE"04 L
Dept Adonim
mpud 6pttt Admin"(Empeya)
Otp
Nomo DapE Sodux a
102 May He
lo3 Hacdik HR
2SooG
ASdO-S
Ajay Acmi 20 Oud
Diplathe detil ot ernpl ayee hay-
Salan beiwen lo0o Gomd 2Soco rnd
belongs to "Hp' Dept
npt 6saluxyloco 2 1Soo0A DeptHR
(Emplay
utpu
NAm Dept Swun
LSOOO
03 Hardi

Exercise-2

Display oll n nume md SpT Of


al Student
Ieall na Nan0SPL Chudet)

Roll NO_ NamR SPT

02 Meet

lo3 Haxsh
Punit

2 Display name OMd SCPT af_all


Studznts,
iarae SPT(Studoyt)

Nammo o a_Studenti
3 Dis play-
CsHuden
Date
Page

Displa hemasneaf a bxanhe


H8ra-ehCStdent

Xx cike 3
Wslto celuttonal algebxai o tobl
1 Studant (Rno,Saamé Addrags ciHMcbile
Addxrs
Roll No0 Cty Mabile
Sándip Adaxsh Surc 93226ruj
lo 2 Divyeshh Sama ladedcaxu Yl23s431E
DeDepcostment
Did DnamQ
3 CE
Electiul
3 Acadmic
Did SPT CPI
3 Baokog
l02

uldo
PnunNMe Etd
Domth 20
o2 Avmeet 202
Date
Page 2 0 C

FoLulty-
Fid Suejet id Salay
Pah oasd
202 ay EC

Students with
heix dspactment nam c
student belonop toCEdepxtment

name0name, St1 6pname "E


Shadadt M C0epaxtment Acdennai

* usite lhethey allo


Co mpa tiblanO nat

AFLst nume_(the), ast nanme (had DOBLdede

Fane Chax)Liane lchux) ehasa2 [Niunokey


NotConopadible

A:Fane Cthud Lagt NcAnL4 chu)


DatR dade)
FstNama CChux),L Nama [chu
DOR Cdde)
Coapatibl
Date
Rxge2-

W t e down elatianaalgabxa
to fallati tabl

fiadAa j and cliepfsuidence


ot all- mplayeRs(wh0 cadsKfa
TCS

IgseA-AeeA compaunaae cctur-


(wOYK J)
End-namei nd iHes f TeyideneR
at al emplaye ho uaák foy
TCS"_
HpassGn-ume CH emloyeyhPeNan
uaNEL Pexton NCm ANO(Gmp.aa NUMe
TCS

3 d mam Street cd t of
Kesid!ncg qlemp loyreg ho
uok fox Tatosys"and
mox
L0400o
TIpe soM mcme ctiRA) .(OCm player,peden Ya-
woiKi PL<SON nom e AN DdgdarySlocoo
PS AND_Canmpan nanao Tntoys

databoe namedho_ o iemplaye of


a Companyfox
IVpe<san-ctome) hich
0Sapleyelci INRyuTvk
cmpcLnATy

You might also like