DBMS Notes - Sahil Choudhary

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

’ DA TABA SE LANGUA(G ¬S C-yeste, Ae , Moditt,

runcatk, te.
( Datoa definition) dop,
Slet,ln sert, Delete,
1. DDL

2. DML (Data Manipulation)


Grant, Revore, te.
3, DCl (Data Control)
Com mit, Rouba
4, TCL (Tronsachon Contro)

DATA MODEL

I. RD MODEL

2. MODE L

’ ER MODEL (Entitg- Relanonship)


y ENTITY havin plysi cal apeavan e
b Tangible
Intongible
’ ENTITY TYPE Mars DoB
Rou Shdut

Type 4 nity
Stydet

Rectonge ’ STUDE NT

’ENTITY
similan
Collechon 4
ARIBUTES

Snple STUOêNT
Composite name
Can be
more
divided (f-name (anam (boB)
Composik
a t bte.
-valul Multi - Value
Singie
Qan have
Name muli
Phone Values
Student

Double
Oval

3.

DoB (na me

Shude

deired
from DO8 (mars)
ag

AHribute
Desciphiv Desco phv
enolmeut detoil
(nome
na me

M
el
(stdent Couise

rUhon

Relabonship
Tgpe
(aka Cardinality Rato)
’ RELATIONSHIP TYPE

1. M:N
one - to one)

. I:M.
(many -to- one)

3,- I : |

KeyS
eys calleeton att bu te togete
Asso a ated oita
uat dishnaush wit oter nhty
SUpER
minimal Supr key
AND DATE KEY’
2.:
SOny one underre prmay
3 PRIMA RY

WEY
4,
5. ALTERNATE KEY (CK - PK ALTERNJATE
OANDDATE PRIMARY
bp-no
SUP E R

name
Rol name bp-no
name Secon
addres semeste
phone bp -no
8echon
8emester

bp-noi secton Coure dd cnomel sÀd


name
Resated
Sudeut 21
abc
fOReIGN
2 det 30
15
DEGREE Of RE LATION SHIP

I. BIN ARY (2 enhty)

TERONARY ( eniy)

QUARTERNARY (4 enhty)
3.

SIV ¬
4. REcUR

Teaches MANA 6¬S


PAcULTY)
DiretA

GON STRA)NTS
PATION
’ PA RTICI

ENROLS
CouRSE
STUDENT

PARTIAL
TOTAL

" Cach Shdet


optional
more)
enmlled in at
Mandatogé least One LoUrse
< "MaTked
double liue
STRONh
ENTITY
SET
wEAK

WE K ENTITY
STRON SET
SET

" Owner /identifier entity


ala
Depend ant on
(nde pendant
entity
existence
portfal key (--.)
har (ava descimi nator
hae primag
Ap-none)
Bno. B-name) Ap-no)

BuILDING <contain
APARTMENT ftoors)

foors weak
I dentita entit
Strorg Relah onsip
( Doublk)
TVere aluoag
tot! participaNon here.

Weau

al wey 3t Primary
PartiwE Key
SE
Con sru t Qn ER mo del conpaut
) employee
ú) Department
) Praject

HPRoJEcT)
DePARTMENT com pang

(dept
eM PLOY EE
emp-id)

(name)
salany)
id) (p-nome)
did dname e_no (fund'ng)
Under PROsECT
pEPARTMENT
Dno)

Qcount) foREIG)

undery (empid

¬MPLOYEE

empnom
bcode) nm)
(name)
(address)
(Code M BRANCH7-6dres
has
BANK

M
LOAN
M
take anont
has AccoUNT|

|CuSTO MER (bal)

sSN) (phon
(name) Qddres

BAN K SYS TEM


¬R

(code
BRANCH
BANK has,

M
AccouNT M

M CO ANS
CUSTOMER
avo
be oiHen in
¬ER LEx 4en ded ER)

1. õpecializati on
Q. heneralizath on
3, Aggregation.
address)
(|.) q SPECIAUSATION (name
Inverted PERSON
Triongle
ls a Employee presets
Person inheiton ce
Pers on is a. Custome
EM PLOY¬E
CUSTOMER

Credit
(salry) Tatig
(2) 6¬N ERALISATION Avdio
Song

Employee is a Person. Video is


Person
ustomer ts
(SoN G|

AUDIO VIDEO

JPRoECT
(3) AG REGATION
conneton
Evatuofor needs
eoch euhty sepurnty hUIDE STUDENT
(NSTRUCTOR
9 Mawe ae , a singe
entity called ag9regatlon,
G This
evalvaiy

TENALUAToR
d...l coURS E
STUDENT enols

max’eracty 4 particpahou
min
O.

RELATIONAL

MODEL
CON ST RA|NTS Rous < Tuples
’ INTEG RITY

æ) DoMAIN
u) ENTITY
REFERETIAL

Studeut Table
i) KEY
mark
name
Rou No.
CoNSTRA|NT
) DoMAIN
have
Rou No. should
Int aatatype O3.

caut be 05
NULL.
u) ENTITY one from
aistinguishes
another

NUL
Can't be
Department Toble
CoNSTRA INT
RECERENTIAL name
Studet Tabe D id
Name abe
Rou o.
det
each alur 19

muct be in
14 h tabe
else t violaes tuis conshrant
CON VERsION ER

TO RELATION AL MODEL
eid
ename) (eaddre)

L) ENTITY EMPLOYEE

2) Strong ehity
= (eid
ey- Employe
R= ) ename , eaddres)
Discmunetor
primoy

WEAM ENTITY (Dname)

eid

ename) eMPLOY EE

eodress)

ename
eddres )
I. Employee
(eid, did a-name )
2. Depedaut

2) A1TRIBUTES eid ename

EMPLON EE
Street)
Compoile
attn bwty (addrey

Pin
addrs -
Employee : (eid ename/ street,
addre
addved pin ) Can t o e
rmupe
vae

ename
eid (phone)
Mulh'vued tMPLOvEE

(eid,name)
I. Empoyee (eid,phone)
phone
Q. Employee -

RELATION SHIP TYPE

3l Biny (4:1)
(A-no
AADHAAR
PERSoN

foreign
p-name)
(P-id, P-name A-id)
li Person =
(A id,A-no)
Aadhar :

(or)
( ld,P-nome) foeign
Person.
Ano,
p-i4)
2. Aadhaar (A-d
32 I:m M: L
(e-id) (C-name)
sid
S_name M -caRsE
STUDENT<enros

forelan key
Proimary Key M.

.
Student (sid, S-name
Poreign
S-id)
loyrse (c_i4, Cname
deycnph'e
.attrbut

3-3 M:N
evolment)
date c-id
le-nowe)
Sname) M
ennols
N
STUDENT CoURSE

Sodent 2 (s-i4, s-nome) DescnpHe


Course (c-id name) attobute

enimet_date )
tnola' (s-kl Cid
3.

Recursive Relatonship
3.4
Teacher wor ks-s
PACULTY
Direchor

1. Pacuty Teacher_fid, Director_id)


Q. worw-as
SPECIALISATION ENERAUZ ATION
P-name)
Pid PERSON
(addre)

PersonP-id,p-nomegddre

ls A/ a. Teachene-i4, salarry )
3. Diector (p-id, prject)

DIRECTOR
TEACHER

(progct
salamy)
(Pname
(Pid
’ Disjaint (add
Specialiwton PERSON

L. Teacher =
(Teid, Tnome, Tadd,
to em ove Is A/
parent elebon< disjoint Salany)
J. Direchor
(D- p- id, d- name,
TEACHER DIRECTOR od-addo,peject)

(PRoJ ECT
AG 6 RE 6 ATION.

Project : (Pr_d, pr-norme) NSTRVeTORUIDE (s TOD


I. (i-id, i-nome)
Instrvchor
(s-id S. name)
3.
Stud

( re-i4, i. t4,s-id,anome)
Kevaluates
Evauato
4.
tvALUATOR
b

M
E1 £2

I. ¬l (a, b, c)
2, E2: (d,e)
(a,d)
RL
Minimun Tables
Te2 Reqd. = 3

R2

a2)
a
al
R A23

¬L (a, an as)

E a3 - (az) a 23

RL

m3

N (me
M ( ml m2,m 3, pl)
Pk

N (pL,n , n)
for porrt'al Kt
to wea
atacu
Grade) -euttt
CoUrse
erol
Student

lecturey

INStruchor
CoUr se

Tota Tables

take Swde
CUASs
teach
Pro7essor|

Total Tables 4.
’ SCHEM A TiER
RELATI ONAL
ALGEBRA
UNAR OPERA TORS

(r) NOTE
SELECTION OPER ATOR
A ’ AND
V’ OR
Condi hon (Relaton)
Shudent
Sname Sechon Age
abe 33 2

12 det (37 20

|3 33 19
Both these
j 20
TOUOS (tPles)
33
i5 Klm (9 U be
seleced
Just select
(nat prit)
age= doGg
sechon

9 coMMUTAT IVE

c2 a)
(a (studeut))
19
Sechon

NOTE
< JRI
melato nship.
Project ()

(R)
attribute list
Shows shdet |stu dent) =4 carolinaliby
the selechon
sid| Sna me Sechon age colun S

abe 33 2L

12 33 Dege n0. toupes


dupiaes metw'ned
33 19

4 33 2o
15 33

Sd,sname Secheu =33

SName
sid

|3

elemeu
yEliminatts dupueate

(svdeut ’ secfou studut)


1 Sname, sehn
Se cho
Sname secheu 33
abe 33
34
34
dey
33

33
(a---an)
(b.bn) (a))
Ta..on)
(o)
T(bl...bn)
CoMMU TATIVE
NOT he other)
(0ny poAsible one is subset 4

8. Rename operaho Y (1)

name
(stwdeut)
Name
melaban Studet
s l S2

(sL, s2, s3,su) (studeut)


3cdeuk_ deta Sksdent

3svdeut -detib (sid,s2, sechion, ag)


(stodunt) sidS2Se age

one
ont8 s
attibute na mel
changed
/but needs to wn'te
whole sat)
Union
BiNARY OPERATORS

Inkrsechou.
Union.: ompoti ble
a dege Catnbutes )
both elatiousip S ame

an) : domain (bË-.. bn)


Q. domain ( a..
Data-ype

Shudeut CouTse
Snam
sid hame

S abe 82
dbms
82

S3
dek 2 mtes
83

’UNI ON
Svdut
(caurse)
sid
81
s2
S3

FFERENCe
(shdut) (course)
TIsd
sid

’NTERSECTION (course)
(Sthvout)
sld

$3
S1. autput
Topks
les tup ta
l wtassodoted
elaton fhanu RS
[Kyusord
OPERAT1ON DVISI
DN ’
dbms S3
S2
dbms
dbms Subject Sid
ame CoUrSe-n
Shdeut
Course
abc
c3
abc
c2
S
doms abc
d
dd Sname
sld Cname huples
Total
attnbuths
no. Total
cartesian y
atuR
no
PRODUC7S CARTESIAN ’
Tneta join
R S
join ( 1) >Outer
Symbol joiu Natt

Borroweh
bran ch Qmt
Loanno
Cust-name loanno

bommeYloan-no =
Bomnen loan. ioan o

’NNER JOIN

’ Theta ’RD, S

attbte
conmon
haue one one the Omnon.
’ Natura ’ Must
wil contain ohy
boutput
No (Here, soon no)
Symnbot
OUTER JOIN NULL.
’ as
Valles
non- prs ent

Course
Sudet sid
cld S.
Sname
sid doms
abc S3
matts
c2

S3

sld Sname dd
abe
y Oukr pin
82 des

You might also like