Sei sulla pagina 1di 38

Database Management

Systems

DONT DO RESEARCH ON ANY TOPIC


Marks Distribution
E-R Diagram & Conversion to Relational Model {1-2}
Functional Dependencies
[2-4]
Normalization
Indexing{1-2}
Physical Structure (B,B+ tree){1-2}
Query Language(RA, RC, SQL){2-3}
Transaction and Concurrency Control{2-3}

GATE-8M
NET-20M
DONT DO RESEARCH ON ANY TOPIC
DONT DO RESEARCH ON ANY TOPIC
DBMS is a software
We use approximately same Steps in database design which are in software design.
If a client comes to a company for a software, he provides some requirements and those
requirements are analyzed and documented.
After that we start software design for which we have variety of tools like data flow
diagram, class diagram, control flow graphs and E-R Diagram, where we show graphically
what the system requirements are.
Advantage of E-R Diagram is, it can easily understood by non technical person too

DONT DO RESEARCH ON ANY TOPIC


E-R Diagram & Conversion to Relational Model
Here in database design we use E-R Diagram, here we can easily identify entities and
relationship between them.
And E-R Diagram can be easily converted into relational model(table).
Sample questions:
Basic questions,
Conversion like max and min number of tables can be formed
Understand this E-R Diagram will be readily available, u need to answer multiple choice
questions there is no need to draw it
Important Topics
Strong and weak entity sets
Types of Relationships
Types of attributes
FINAL QUESTION->Can u read a E-R Diagram
DONT DO RESEARCH ON ANY TOPIC
Functional Dependency and Normalization
Tables are needed to be normalized due to redundancy and the problems associated with
redundancy.
To minimize redundancy we use normalization and the tool used to normalize is functional
dependency
Sample questions
Functional dependency valid or not
Number of candidates key
Comparison between 2 set of functional dependencies
Decomposing
Identify normal form
Functional dependency loss?
Data loss happened or not?

DONT DO RESEARCH ON ANY TOPIC


Indexing
To make the database fast we use indexing
Types of indexing:
Primary
Cluster
Secondary
Multilevel
Etc

DONT DO RESEARCH ON ANY TOPIC


Physical Structures
After indexing it generates index files which will be stored using B,B+ trees
Sample questions

Insertion
Deletion in B,B+ trees

DONT DO RESEARCH ON ANY TOPIC


Query processing
Here we need to concentrate on Relational Algebra, Relational Calculus, SQL(NESTED
QUERIES)

how to access data using queries


Sample question
Nested queries
Theory question on RA
No need to write any queries only we need to understand and choose one option

DONT DO RESEARCH ON ANY TOPIC


Transaction and concurrency control
Database maintenance during run time, mainly maintaining consistency

DONT DO RESEARCH ON ANY TOPIC


FUNCTIONAL DEPENDENCY:
Let R be the relation x, y are non empty sets of attributes over R and t1,t2 are any tuple of R

x->y { v t1, t2 C R [(t1.x=t2.x)=> (t1.y=t2.y)]}


Ex: R(A1,A2,A3,.An)
X=A1
Y=A3A4
Sets of attributes means they can be one attribute or more than one attribute
t1,t2 are the tuples(rows)
x is determinant
y is dependent
x functionally determines y if the above said function satisfies the condition

DONT DO RESEARCH ON ANY TOPIC


F:A->B
functional dependency means if I tell u the value of A we can search
for the value of B
Using the value of A iam determining B so A becomes determinant
And B is dependent on A so its called dependent.

DONT DO RESEARCH ON ANY TOPIC


We are using =>(implication),
P => Q
P q p=>q
0 0 1
0 1 1
1 0 0 p=>q is false here for p true and q false
1 1 1

Case 1:
R
t1 X1 y1

t2 x2 Y2

t1.x=x1 t2.x=x2 and t1.y =y1 t2.y=y2 p is false q is false then p=>q is true then x->y
functional dependency is valid
DONT DO RESEARCH ON ANY TOPIC
Case 2:

X1 Y1

x2 Y1

Case 3:
X1 y1

x1 Y2

Case 4:

X1 y1

X1 Y1

DONT DO RESEARCH ON ANY TOPIC


Example
Sid Sname Cid Cname
S1 A C1 C
S2 A C2 C++
S3 B C1 C
S4 B C1 C

Validate the following functional dependencies


Sid->any attribute
cid->cname
Sid->cid
Sname->cid
Sname->cname Sname->sid Cname->sname Cname->cid

DONT DO RESEARCH ON ANY TOPIC


Functional dependencies are decomposed into
Trivial
Non trivial
Trivial functional dependencies:
Trivial means always true
X Y => X->Y
Example
Cid sname->sname
Sid->sid
Sid sname->sname
Sid sname->sid sname
DONT DO RESEARCH ON ANY TOPIC
Let R be the relation
A B
AB->A OR AB->B is a valid trivial functional
1 1
Dependency
A->B is not a valid FD 2 1

B->A is not a valid FD 1 3

4 2

NON TRIVIAL FUNCTIONAL DEPENDENCY:


X->Y is non trivial functional dependency when X not Y
Or
X->Y is non trivial functional dependency when X Y is

DONT DO RESEARCH ON ANY TOPIC


IDENTIFY ALL NON TRIVIAL FUNCTIONAL DEPENDENCIES

A B C

1 4 2

2 5 2

3 4 2

3 5 2

A->B
A->C C->A
C->B
A->BC
C->AB

AB->C
B->C BC->A
B->A AC->B

B->AC
DONT DO RESEARCH ON ANY TOPIC
Properties of Functional Dependency:
Reflexive Property:
If X Y then X->Y is a valid FD
Transitive Property:
((X->Y)&(Y->Z)) => (X->Y)
Augmentation Property:
IF (X->Y) IS A VALID FD
If we augment X->Y with Z then
XZ->YZ IS ALSO A VALID FD
UNION Property:
IF (X->Y) AND (X->Z) is an FD then (X->YZ) is also and valid FD
Splitting Property:
X->YZ => (X->Y) AND (X->Z) is also an valid FD
DONT DO RESEARCH ON ANY TOPIC
ATTRIBUTE CLOSURE (X+):
Set of attributes that are functionally determined by X.
EXAMPLE:
R(ABCD) {A->B,B->C,C->D} GIVEN
A+ = A B C D
B+ = B C D
C+ = C D
D+ = D
AB+ = ABCD
AD+ = ADBC

DONT DO RESEARCH ON ANY TOPIC


EXAMPLE GATE 2006
AB->CD
AF->D
DE->F
C->G
F->E
G->A

COMPUTE
(CF)+ = CFGEAD
(BG)+ =BGACD
(AF)+ =AFDE
(AB)+ =ABCDG

DONT DO RESEARCH ON ANY TOPIC


USING ATTRIBUTE CLOSURE TO FIND THE SUPER KEY AND CANDIDATE KEY:
If (X+ = R) (X is a super key)
Example:
R(ABCD)
{ A->B, B->C, C->D}
If A+ =ABCD= R
Then A is a super key
If B+ derives R then B is a super key

DONT DO RESEARCH ON ANY TOPIC


USING ATTRIBUTE CLOSURE TO FIND THE SUPER KEY AND CANDIDATE KEY:
Example
R(ABCDE)
{AB->C,C->D,B->E}
(AB)+=ABCDE=R
Then AB is a super key
Candidate key is the minimal of the super key
In the above example minimal of AB is either A or B or AB
Then verify whether
(A)+=R or not
(B)+=R or not
The above two are not possible so AB is the candidate key.

DONT DO RESEARCH ON ANY TOPIC


Finding Prime attribute and non Prime attribute:
R(ABCDE)
{AB->C, C->D, B->EA}
(AB)+=ABCDE=R
AB is a super key.
To find candidate key we need to check the minimal of super key
Minimal are A and B
(A)+=A
(B)+=BEACD=R
So B becomes a SUPER KEY and candidate key
But AB is a SUPER KEY but its not a candidate key

DONT DO RESEARCH ON ANY TOPIC


Finding Prime attribute and non Prime attribute:
Key or prime attribute belongs to CANDIDATE KEY ONLY
EXAMPLE:
R(ABCDEF)
{
A->BCDEF
BC->ADEF
B->F
D->E
}
A+ =ABCDEF=R
A is a super key and its minimal so it becomes candidate key
So the prime attribute becomes A.
Check for this in the above Fd:?->prime attribute
BC->ADEF is an FD where prime attribute is on RHS
Decompose BC->ADEF
DONT DO RESEARCH ON ANY TOPIC
Finding Prime attribute and non Prime attribute:
BC->A
BC->DEF
NOW CONSIDER THE FIRST FD
And now check
(BC)+=BCADEF=R
So BC becomes a SUPER KEY
Check for minimal of BC
B+=NOT R
C+= NOT R
SO BC BECOMES CANDIDATE KEY
SO B AND C BECOMES PRIME ATTRIBUTES
PA={A,B,C}
CK={A,BC}
AND D,E,F ARE NON PRIME ATTRIBUTES

DONT DO RESEARCH ON ANY TOPIC


Example:
R(ABCDEF)
{ AB->C, C->D, D->E, E->F, F->A }
(AB)+=ABCDEF=R
So AB becomes SUPER KEY
Now check the minimal of AB to find the CANDIDATE KEY
(A)+=A
(B)+=B
AB becomes CANDIDATE KEY also
CK={AB,FB,EB,DB,CB
PA={A,B,F,E,B,D,C}
Now check for FD WHERE FD:?->PA
F->A is an FD which satisfies the above criteria
Replace the A from CANDIDATE KEY AB with F so it becomes FB
(FB)+=R
Now check the minimal of FB to find the CANDIDATE KEY

DONT DO RESEARCH ON ANY TOPIC


(F)+ doesnot derive R
(B)+doesnot derive R
So (FB)+ is minimal it will become candidate key.
Now check for FD WHERE FD:?->PA
E->F is an FD which satisfies the above criteria
Replace FB with EB
Now see (EB)+=R

EB is a super key, Check the minimal of (EB)+


(B)+ doesnot derive R
(E)+ doesnot derive R
So EB becomes Candidate Key
Now check for FD WHERE FD:?->PA
D->E is an FD which satisfies the above criteria
Replace EB with DB
AND PROCESS CONTINUES
NON PRIME ATTRIBUTES ARE = {}
DONT DO RESEARCH ON ANY TOPIC
EXAMPLE:
R(ABCDE)
TRIVIAL FUNCTIONAL DEPENDENCY
R->R
ABCDE->ABCDE
(ABCDE)+
=R
CK={ABCDE}
PA={A,B,C,D,E}
NPA={}

DONT DO RESEARCH ON ANY TOPIC


R(ABCDE)
{A->B, B->C,C->D,D->A}
A+=ABCD
Here E is missing in all the FDs
So what we do to derive R is we augment E
(AE)+=AEBCD=R
AE is already minimal
CK={AE,DE,CE,BE}
PA={A,E,D,C,B}
Check the FDs with PA on Right hand side
D->A
AE becomes DE
(DE)+=AEBCD=R
DE is already minimal

DONT DO RESEARCH ON ANY TOPIC


Check the FDs with PA on Right hand side
C->D
DE becomes CE
(CE)+=R
CE is already minimal
Check the FDs with PA on Right hand side
B->C
CE becomes BE
(BE)+=R
BE is already minimal

DONT DO RESEARCH ON ANY TOPIC


DETERMINE CANDIDATE KEYS?
1)
R(ABCDE)
{AB->C, C->D, D->E, A->B, C->A}
CANDIDATE KEY{A,C}
PRIME ATTRIBUTES{A,C}
NON PRIME ATTRIBUTES ARE {B,D,E}
2)
R(ABCDE)
{A->D, AB->C, B->E, D->C, E->A }
CANDIDATE KEY{ B}
PRIME ATTRIBUTES{B }
NON PRIME ATTRIBUTES ARE {A,C,D,E }

DONT DO RESEARCH ON ANY TOPIC


DETERMINE CANDIDATE KEYS?
3)
R(ABCDEF)
{A->C, B->D,C->E,D->E,E->A,F->B}
CANDIDATE KEY{ F}
PRIME ATTRIBUTES{F }
NON PRIME ATTRIBUTES ARE {A,B,C,D,E }
4)
R(ABCDE)
{AB->C, C->D, D->E,E->A,D->B}
CANDIDATE KEY{ AB, EB, D, C}
PRIME ATTRIBUTES{A,B,E,D,C }
NON PRIME ATTRIBUTES ARE { }
5)R(ABCDEF)
{AB->C,C->DE,E->F,F->A}
CK{AB,FB,EB,CB} PA{A,B,F,E,C}

DONT DO RESEARCH ON ANY TOPIC


6)
R(ABCDEFGH)
{AB->CD,D->EG,F->H,C->EF,H->A,G->B,A->B}
CK{A,H,F,C}
PA(A,H,F,C}
NPA{B,D,E,G}

DONT DO RESEARCH ON ANY TOPIC


GATE 2005
R(ABCDEH)
A->B BC->D E->C D->A
What are the candidate keys?
a) AE,BE
b) AE,BE,DE
c) AEH,BEH,DEH CORRECT
d) AEH,BEH,BCH
NOTE:CHECK FOR COMMON ATTRIBUTES IN ALL THE OPTIONS(AUGMENT PROPERTY )
R(VWXYZ)
{VY->W, WX->Z,ZY->V}
R(ABCD)
{AB->C, C->D, CE->F,F->G}
REMOVE INVALIDE FDs

DONT DO RESEARCH ON ANY TOPIC


FUNCTIONAL DEPENDENCY CLOSURE(F+)
Set of trivial, non trivial FDs derived from given FD set F
Example
R(ABC)
F={A->B,B->C}
F+ =?

DONT DO RESEARCH ON ANY TOPIC


MEMBERSHIP TEST:
To check whether X->Y(fd) IS MEMBER OF FD set F or not
If we can derive X->Y from the fd set F then we can say that X->Y is a member of F other wise its not a member of F.
Example
{A->B, B->C} can we derive A->C
A+=ABC
RHS WE HAVE 3 ATTRIBUTES SO WE CAN DERIVE 23 FDs
A->B,A->C,A->A,A->AB,A->BC,A->AC,A->ABC,A->
EX:
{X->Y,YZ}=X->Z FIND X+
{XY->Z,Y->W}=WX->Z
{XY->Z,Z->X}=Z->Y
{X->Y,Y->Z}=X->YZ
{XY->Z,Z->W}=X->W

DONT DO RESEARCH ON ANY TOPIC


SCHEMA REFINEMENT:
Redundancy: it means duplicate copies of the same data
Normalization is used to eliminate/reduce redundancy
Three types of redundancy
File level
Entire record level
Few attribute have redundancy

DONT DO RESEARCH ON ANY TOPIC

Potrebbero piacerti anche