Вы находитесь на странице: 1из 28

RELATIONAL DATABASE

MANAGEMENT SYSTEM
Department of Computer Science
St Thomas College Thrissur

Session 1:

Introduction To DBMS
Keys
Functional Dependency
Candidate Key
Decomposition
Normalization
Check The Normal Form
Convert To Normal Form

Session 2:
Transaction Processing
Serializability
SQL Commands

SESSION 1

DBMS

Collection of programs that enable users to create and maintain


database
Characteristics (Self describing, sharing of data, insulation of data &
program multiple usage and users)
Advantages (redundancy control, restricted unauthorized users, back up
and recovery, multiple users interface , complex relationship
representation, integrity control)
Deductive database capability of defining rules for interfacing new
information
3 tier architecture (external, conceptual and internal )

Data independence (logical change conceptual and physical change


internal scheme)
DBMS language DDL and DML
Design techniques ( top down approach (ER model ) and bottom up
(normalization))
Entity objects of real world
Simple composite single valued multi valued stored derived null complex
attributes

Keys

Composite key
Super key
Candidate key
Prime key attribute
Primary key
Foreign key

Constraints
cardinality ratio (max no of relationship instances in a binary relation
participation constraint existence of an entity depends on another
Total
Partial

Specialization and generalization

Relational schema
Table of records
Cardinality (tuples)
Degree (attributes)
Granularity (size of data item)
Relational constraints

Domain constraint
Key constraint
entity integrity
Referential
Semantic integrity

Select

salary > 2000

Project operation (specifies a column from the relation) name,


salary( employee)
Join operation
Theta join
Natural join
inner join
Outer join

KEYS
uniquely identify tuple
primary key
Candidate key : unique & irreducibility
Super key : uniqueness
Foreign key

FUNCTIONAL DEPENDENCY
X

XY
XYZ
XZY

XY iff YC X
XY XZYZ
XY, YZ then XZ
If XY, XZ then XYZ
If YX, ZX union is not
possible
If XYZ then XY and XZ
Suppose a scheme R(A,B,C)
F={AB,BC)
then A+ (closure) =A.B.C
B+ = BC
C+ = C

CANDIDATE KEY
Find A+
If all attribute come in A+ then a is candidate key

Superkeys identify the attributes but is reducible.

Steps:
1. Find the attributes that are neither on the left and right side
2. Find attributes that are only on the right side
3. Find attributes that are only on the left side
4. Combine the attributes on step 1 and 3
5. Test if the closures of attributes on step 4 are all the attributes if the
closure does not include all the attributes, we should find the relation
exterior.
6. Find the relation exteriors, that is the attributes not included in step 4 and
step 2. 7. Now test the closures of attributes on step 4 + one attribute in
step 6 one at a time.. This will yield candidate keys.

PRIME ATTRIBUTES AND NON PRIME


ATTRIBUTES
Attribute is an attribute of candidate key prime key else non prime attribute

F CLOSURE
Maximum number of dependencies
Compute all possible closure combinations.
2 to the power (Number of elements) gives the number of dependencies of that
group
Summation of dependencies of each closure gives required result
Note: for all relations is considred

MEMBERSHIP
To check if a dependency defined in a relation write closure of the lhs of the
dependency. If the rhs is present in the closure then its a member.

DECOMPOSITION
Splitting of tables.
Should satisfy
lossless join ( decompose table when we natural join them we find no spurious
tuples its lossless join)
Dependency preservation( the decomposed tables should satisfy all functional
dependencies of parent)

LOSELY AND LOOSELESS DECOMPOSITION


One row for each relation in the decomposition
One column for each attribute of the relation
For each row, we place the value a with the column subscript in any column whose
heading represents an attribute in that relation, and the value b with the usual row and
column subscript in the column for any attribute not in that relation.
for each FD X Y in F
for all rows in S that have the same symbols in the columns corresponding to the
attributes of X, make the symbols for the columns that represent attributes of Y equal
by the following rule:
if any row has an a value, a(j), then set the value of that column in all the other rows equal to
a(j)
if no row has an a value, then pick any one of the b values, say b(i,j), and set all the other
rows equal to b(i,j)

4. if, after all possible changes have been made to S, a row is made up entirely of a
symbols, a(1), a(2), ... , a(n), then the join is lossless. If there is no such row, the join is
lossy.

DEPENDENCY PRESERVING
Closure of FD
Write decomposition separately
Write all the possible fd from the closure
Project all fd to the other
If all fd are in the decomposition then dependency is preserved

NORMALISATION
Property of the relation that indicates the degree of redundancy normal form
Procedure applied on a relation to reduce redundancy normalization
INF values are atomic
2NF INF + no partial dependency( set of non prime key attributes depends on
the part of primary key)
3NF 2NF + no transitive dependency
BCNF every determinant is a candidate or superkey
4NF BCNF+ No multivalued dependency

Find the normal form:


Find candidate key
check the FD
Skip all FD with have a candidate key on LHS.
Of the remaining check for transitive dependency no means 3NF
If for no candidate key there exists a relation such that a part of it
determines a non prime key attribute it is in 2NF.
If explicitly specified to be in atomic values, it is in 1NF
Not normalized.
Notes:
Only 1 attribute in candidate key no partial dependency
No non-prime key attribute no transitive dependency +partial dependency + is in
atomic value

Situation where transitive dependency may exsits:


Subsetnonprime
Nonprime nonprime
subset+nonprimenonprime

MINIMAL COVER

END SESSION 1

SESSION 2

TRANSACTION MANAGEMENT

SERIALIZABILITY

RELATIONAL ALGEBRA

SQL COMMANDS

Вам также может понравиться