Chpater 6 View

advertisement

Week 9 Database Design

ER Modeling, Functional Dependencies

E-R Model

The E-R data model is based on a perception of the real world, which consists of a set of basic objects called entity instances and relationships among these objects.

Entity

An entity is a collection of real world distinguishable objects with common

properties.

An entity represents classes of real world objects. ex.: customers of a bank , common properties: all have accounts in a bank. ex: students: people who study in the same school, common: classes, grades,

credit hours, etc.

Entity occurrence or entity instance: a real world object. ex: John with a SSN 123-45-6789

An account in the bank

Enrollment of a course

Attributes

Attributes represent elementary properties of entities or relationships.

ex: customers ( of a bank ) : customer_id, account_no, name, balance ...

Domain: set of permitted values for the attribute.

Relationship

Represents an aggregation of two or more entities. enrollment

Students ----------------- Class_offer shipment

Suppliers --------------- Parts deptno

Students ---------------- departments

Number of participants : degree of relationship

Binary: # of participants = 2 ; most of the relationships

Ternary: # of participants = 3 ; ex : S, P, J ; J : project , suppliers supply parts

for some projects.

Cardinality of a relationship ( for binary relationship )

The number of the entity instances to which another

1

entity instance can map under that relationship.

(1) one to one

Department Department Head

(2) One to many and many to one

Manager Employee

(3) many to many

Player Skills

E-R diagram

Rectangles

Ellipses

Diamonds represent represent represent entities attributes relationships

Lines represent link ( entity-attribute)

(entity-relation-entity)

6. Application of E – R model ( Mapping rules 1 through 4 on the text book )

Mapping a real world system to a RDBMS

Identify the entities, relationships, attributes in your system.

Entities --> tables

Attributes of each entity --> columns.

Relationships --> tables , like SP ( S#, P#, QTY );

QTY descriptive attribute of relationship

or ---> extend the current table, adding a new attribute.

2

Functional Dependency

[ Functional Dependency ]: or FD

X, Y : subset of the set of attributes of relation R

Y is functional dependent on X if every possible value of X uniquely determines the value of Y .

Notation: X

Y

We simply say: Y is dependent on X or

X determines Y .

Definition ( formal ):

Given any two rows r

1

and r

2

in relation R , and X, Y are attributes of R,

if r

1

(X) = r

2

(X) then r

1

(Y) = r

2

(Y).

(if r

1

and r

2

agree in value for X, then they agree in value for Y ).

Assume there will be no change in the table,

A B .... x1 x2 x5 x3 x2 x4 y1 y4 y1 y2 y4 y3

A

B

Which FDs are satisfied in the following table (content of the table will never change ).

A a1 a1 a2

B b1 b2 b2

C c1 c1 c2

D d1 d2 d2 a2 b3 c2 d3 a3 b3 c2 d4

A  C ; AB  D, etc....

Trivial dependencies

X

Y ; if Y is subset of X ( Y

X )

Full Functional Dependency

Y is fully functional dependent on X if (1) X

Y

(2) Y is not FD on any proper subset z of x. [ No z

Y , z

X ]

Armstrong’s Axioms

(inference rules ) ( O'Neil p335):

3

1. Inclusion rule

2. Transitivity

3. Augmentation

if

(Y

X) Y is subset of X

X

Y and Y

Z

X

Y

then

X

Y

X

Z

XZ

YZ

Note trivial

YZ means Y

Z

These rules are: ( F: a set of FD on R ) using inference rules one can get

Complete : for a given F of FDs --------------------------------> F +

Sound : do not generate any incorrect FD.

Derived rules : ( O'Neil P 336) if then

4. Union

5. Decomposition

6. Pseudo transitivity

X

Y and X

Z

X

YZ

X

Y, YZ

W

X

YZ

X

Y and X

Z

XZ

W

Closure of Set of Dependencies

Closure of F : F +

Definition of F + : the closure of F, to be the set of ALL FDs (functional dependencies)

that are logically implied by F.

i.e. F

+

= { X

Y | F |= X

Y } sample:

R = ABC F = { A

B, B

C }

F

+

consists of all implied dependencies ( list of some of the members of F

+

)

ABC

AB,

AB

BC,

A

C

BC

B,

C  C,

C  

,

  

.

4

Download