Docsity

Database summary invovling query, Schemes and Mind Maps of Database Management Systems (DBMS)

Toggle sidebar
bg1
Scanned
with
CS
CamScanner™
Slode-
'
All
types
of
keys
Primany
key!
A
primany
key
is
a
unique
identifier
Fon
each
recornd
in
a
table.
It
must
contain
unique
valve
and
ean
not
have
NULL
values.
en:
Student-into
(Atudent_id,
stu-name,
dept-id,
dept-nomd)
Foreign
key
A
Toneign
key
is
a
column
on
set
of
columms
that
erceates
nelatunship
between
two
tables.
It
nefens
to
primany
key
of
anothen
table.
Customen
(cust-id,
eust-name);
Oridens
(onder
id,
onden,
nome,
eust-ip)
niqme
key
↑
Foreign
key
that
builds
Melatünship
between
eustomen
and
Urndens
table.
A
unique
key
connatrants
allat
ensunes
that
all
vaves
in
a
column
are
uniue,
though
it
allows
a
ningle
NULL
valve,
Name
VARCHAA
(50)
UNIQUE
means
only
one
now
ane
allowel
to
having
Null
valves
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30

Partial preview of the text

Download Database summary invovling query and more Schemes and Mind Maps Database Management Systems (DBMS) in PDF only on Docsity!

Slode-

' All types of keys

Primany key! A primany^ key^ is^ a^ unique^ identifier

Fon^ each^ recornd^ in^ a^ table.^ It^ must^ contain^ unique^ valve

and ean not have NULL^ values.

en:^ Student-into^ (Atudent_id,^ stu-name,

dept-id,^ dept-nomd)

Foreign key A Toneign^ key^ is^ a^ column^ on^ set^ of^ columms that^ erceates^ nelatunship^ between^ two^ tables.^ It^ nefens^ to primany^ key^ of^ anothen^ table.

Customen (cust-id,^ eust-name); Oridens^ (onder^ id,^ onden,^ nome,^ eust-ip)

niqme key

↑ Foreign^ key^ that^ builds

Melatünship^ between^ eustomen

and Urndens^ table.

A unique^ key^ connatrants^ allat^ ensunes^ that^ all^ vaves

in a column are uniue,^ though^ it^ allows^ a^ ningle^ NULL valve, Name VARCHAA (50) UNIQUE ane^ means allowel^ only to^ one having^ now Null valves

Spon keg A supen key Is any^ combination^ of^ columns^ that

ean^ uniquely^ identify^ each^ now^ in^ a^ table. Er^ A^ supen^ can^ have^ extna^ columns^ beyond^ the minimum nequinel to identity a necond.

Candidate key!-

A^ candidate^ key^ is^ a^ minimal^ pupen^ key.^ In^ otten

worrds,^ it's^ the^ smallest^ combination^ of^ columns^ that^ can

uninuely^ identity

а пOW.

en:^ Student^ (atu-id,^ name,^ email,^ phone)

Hene,^ possible^ nupenkey^ =^ ntu-id,^ (nhv-id,^ name),

(otusid,^ num, email)^ ete.

candidate^ key=^ stu-id^ on^ emcil^ on^ phone^ if^ all

of

these^ unisuely^ idenhty^ each^ aludent.

wod ot (^) doswollp sno CAAN 1U

Dept} এটাও একটা key হতে পারে, কিন্তু {Name, mark} key হতে^ পারেনা।^ কারণ^ অনেকের^ name,^ mark^ একই^ হতে পারে। Super key: Attribute^ or^ set^ of^ attribute^ that

uniquely^ identified^ each^ record^ of^ relation.^ এখানে

{Sid}, {Sid,^ name}^ সবাই^ supper^ key^ কারণ^ Sid^ হলো

super^ key^ তাই^ এর^ সাথে^ কোন^ attribute^ add^ করলে^ সেগুলোও

super key^ হয়ে^ যাবে।^ Total^ super^ key^ possible=^ 2"-

নিচের Table টি দেখেন^ এখানে^ কি^ কি^ super^ key^ সম্ভব? উত্তরঃ

A^ B C D

(^1 ) 2 1 7 1 3 1 7 1

5 2 5 1 6 2 5 2

Cloud^ IT^ Online^ Batch এখানে super key = {A}, {AB},{AC} {AD} {ABC} {ACD} {ABD} {ABCD} = 8 super key. কিন্তু identified {BCD} না। =super তাই তাদের key subset হবে না গুলো কারণ super^ তারা key^ niquely হবে না। বাস্তবে super key হলো theoretical concepts. Candidate Key: not a^ Condition super key^ 1:^ Super^ key^ whose^ proper^ subset^ is Proper^ Condition Subset:^ 2: Set^ Minimal A is considered^ Super^ key. to be a proper subset of set B if set B contains at least one element B={12,24,36}, that is A={12,24} not present Here in A set is the A. proper Here subset of B because 36 is not preset in set A. See the following table:

So. [বিঃ sup Pri nul

  1. WI 2.^ 23] WI Da A 1 B^ C^ ם^ N 2 11 12 Datab: 3 2 1 that^ a 4 2 2 way^ th Here, are^ m Set= এখন দেখেন {A}, কীভাবে {AB}, এগুলো {AC}, থেকে {ABC}, Super key{BC} আর Candidate^ that^ e Key বানাই।^ key initiall^ in Set Super key

Candidate key

মন্তব্য second {ABC}^ yes^ No ABC এর proper^ (3NF) subset AB, AC, A, B, C যাতে A নিজেই Super condition key. 1 অনুযায়ী তাই এটা candidate key

introd Codd these depen norma {AC}^ yes^ No^ AC এর proper^ later subset A, C যাতে A নিজেই তাই condition Super key. 1 অনুযায়ী এটা candidate key না।

norma forms

{A}^ yes^ yes A এর proper subset {}._তাই^ condition^2 Candidate^ অনুযায়ী^ এটি key. {BC}^ yes^ yes BC এর proper subset B, C যা super keyCandidate না। তাই key BC

Points to remember:

  • Super key: Any set of attributes that uniquely identifies a row.
  • Candidate key: A minimal super key. If you remove any attribute, it no longer uniquely identifies the row.
  • Primary key: One candidate key selected as the primary key.
  • Alternate key: Candidate key’s not selected as the primary key.
  • Composite key: A key containing 2 or more attributes.
  • Foreign key: Attribute(s) referring to a key of another relation.

 Any superset of candidate key is a super key.  All candidate keys are super keys.  All super keys are not candidate keys.  For n attributes relations, maximum super key possible: 2 𝑛^ − 1

Functional Dependency (FD): A functional dependency is written as: 𝑋 − −> 𝑌 It means, if two rows have the same value of X, they must have the same value of Y. Here, X is called determinant, and Y is called dependent attribute. Attribute closure: The closure of an attribute set X is written as 𝑋+, means, all attributes that can be determined from X using the given functional dependencies.

Q. Let’s say, R(A, B, C, D, E) and FD’s:

  • A → B
  • B → C
  • D → E Find super keys, candidate keys. Answer: Step 1: Find the candidate key’s  First, identify attributes that cannot be obtained from the RHS of any FD.  Here, RHS attributes are: {B, C, E}  So, A, D never appears on RHS  Therefore, A and D must be present in every candidate key.  Try 𝐴𝐷+ Start: {A, D} Using A→B: {A, B, D} Using B→C: {A, B, C, D} Using D→E: {A, B, C, D, E}

Step 3: Find primary key and alternate key  Primary key = {A}  Alternate key = {}

Q3: Given R(A, B, C, D, E) And FD’s:

  • A → B
  • B → A
  • C → D
  • D → C
  • A → E Find out super key, candidate key.

Solution: Step 1: Find the Candidate key  In RHS, every attributes are present. Then how we will do this one?  Look at the dependency groups.  A → B, B → A; means A and B can determine each other.  C → D, D → C; means C and D can determine each other.  To get all five attributes, we need one attribute from {A, B}, and one attribute from {C, D}  So, possible combination: {AC, AD, BC, BD}  𝐴𝐶+^ = {A, C, B, D, E} = R  𝐴𝐷+^ = {A, D, B, C, E} = R  𝐵𝐶+^ = {B, C, A, D, E} = R  𝐵𝐷+^ = {B, D, A, C, E} = R  All 4 are superkey.  Check minimality by removing A, B, C, D one by one, and check if anyone leads to R.  No one is doing so. (You can verify by finding 𝐴+, 𝐵+, …  Hence, candidate key = {AC, AD, BC, BD}

Step 2: Find the super key  Any super set of candidate key is super key.

Nonmalize^ the^ given^ database^ to

N 3NF. Outline

the^ neqwirements.

Customen^ (eust-id,^ cust-name,

dob,^ zip,^ stmeet,^ eity,

stute,

Onden-id,^ onden-items,^ onden

amt, contact-no,^ email)

INe:^ (i)^ Ensune^ there^ is^ a^ primang^ key

(?) atomicity^ of^ the^ table^ is^ I.

Leach^ cell^ can^ centain

only^ I^ valve-

sepanaletf^ multiple

vilve^ attrubule

let,^ contact-no,,^ wndesitems^ aAe^ be^ m email^ ane^ multivalved^ attributes.

eaunto^ Contaet eust-id contaet-no emal

Customen cust-id,^ eust-name,^ dob,^ zip,^ Atmeet, city^ ,ntate,^ onden-id,^ onden-ilems, Onden-amt

32NF

(1)^ Remove^ Parctial^ T^ dependency.

If^ thene^ is^ a^ composile^ key

(combination^4 tero^ Pk),

nepanate^ erch^ pk^ wilh^ nelevant^ altnibutes.

um

customes^ table^ has^ composite^ krey^ (eust-id,^ ondenid) This^ creates^ pantial^ dependency.

Contaet

cust_id^ Customen^ Onden cuntact-no

emal

ewst_id^ orden-id Cust-name dob onden-id 2iP stneet city, stale

onden-ilems onden-amt id

3NF (1) Remove^ any^ fransihivel ال^ kependeng a^ non-prime^ attribute^ depends

on anothen^ non^ -prine^ attribute.

Here,^ street,^ cils,^ ntale^ of^ Customen^ table^ depends^ on ZIP unly.

Customer Location Oaden Contaet (^) ust-id cust-id eontact-no email

eust-name dob 2IP Qadesid

Zip ptneet eily Stale PER

Ondenid Onden-items Onden-amt o eust-id estP

Гине^ 24-

emp-id^ e-hume^ e-zip eonke^ e-us^ e-dismict

to

Detenmine-

(i) Supen key (ii) Candidale key (l1)^ Non-prime^ attribule

Is^ the^ table^ in^ 3Ne?

If^ nut,^ make^ the^ table

compавiblы

with 3NF. Suln (i)^ Supen^ key:^ Remp-id,^ (emp-id,

e-zip),

(emp-id,^ e-name),^ (e-it,^ e_nane,

ezir)^ ete

Now

(il)^ Candidate^ key?^ emp-id (111)^ Non-prime^ attribute^ e-name,^ e-zip, e-distinet.^ e^ -^ atale,^ e-uy,

INF:^ Atomicity^ of^ the

table^ is^ I.^ So,the^ table

is^ in^ INf.

2NE:^ No^ partial^ dependeney.

because^ emp-id^ unisuely

can^ identily^ all^ non-prime^ attribute So,^ the^ table^ is^ in^ 2NF.

3NF=^ (i)^ Thene^ arne^ transiive^ dapen^ darcy.

Non-prime^ atteilbute^ estate,^ e-city,^ e^ district^ dep on^ another^ non-prime^ attreibute^ e-zip^ and

e-zip

depends^ on^ emp-id.^ So,^ let's^ bireah^ the^ tasle^ as^ below

Employee^ Locahion emp-id^ e-2ip e_name^ e-state e-ey e-zip e-distmict

Now,^ the^ table^ is^ in^ 3NF

I?

Types of attributes-

. Simple^ attrubute

An^ attribute^ that

cannot^ be^ funthen

nubdivided

into^ components.

ex:^ Roll^ num^ of^ a^ student.

2.^ Composite^ attribute: that^ can^ be^ aplit^ into^ components.

ex:^ name^ (7-rare,^ I_-name)

addness^ (eity,^ state,^ stmeet)

3.^ Single-valued- tates only a single vale^ tun^ each^ entity.

en:^ age

4.^ Mulli-valued!

Stoned

takes^ mone^ than

a^ ningle^ valve.

en:^ Phone^ (a^ penson

ean^ have^ mulhiple^ phone

no)

S^ doesn't^ neqwire^ any

update^ once^ stoned en DOB

Dertived Can be derrived trum^ othen^ attnibules

en:^ auy^ mants^ of^ Alvdent,

age^ of^ penson

key- uniquely^ identify^ the^ entity en.^ RolLno

Null

Can^ take^ NULL^ mlue^ when

an^ entity^ does^ not^ have value. Deseruphive

ffive^ intformation

Stant

Mage

abuut^ the^ relahionship^ net

4

hene^ stant^ is^ the^ deseroiptive^ attribute^ of^ manages^ relatioshrip.

Ar. Complex attibule:

fonmed^ by^ nesting^ of^ composite^ and^ mulhi-valved

attributes.

en: addness^ contain^ composite^ value^ (omeet,^ 22p^ coe)

also^ one^ penson^ ean^ have^ mulhiple^ house^ adaness.