advertisement

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.

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 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.

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 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

[

]: or

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,

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 ).

a1 a1 a2

b1 b2 b2

c1 c1 c2

d1 d2 d2 a2 b3 c2 d3 a3 b3 c2 d4

A

C ; AB

D, etc....

X

Y ; if Y is subset of X ( Y

X )

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 ]

(inference rules ) ( O'Neil p335):

3

1. Inclusion rule

2. Transitivity

3. Augmentation

(Y

X) Y is subset of X

X

Y and Y

Z

X

Y

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 -------------------------------->

**+**

Sound : do not generate any incorrect FD.

: ( 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

**+**

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