# Relationships Sets

- A relationship is an association among several entities.

Example:

Hayes *depositor *A-102

*customer *entity relationship set *account *entity

- A
*relationship*set is a mathematical relation among*n **2 entities, each taken from entity sets.

{(*e*1, *e*2, â€¦ *en*) | *e*1 * *E*1, *e*2 * *E*2, â€¦, *en ** *En*} where (*e*1, *e*2, â€¦, *en*) is a relationship

Â

Example:

(Hayes, A-102) * *depositor*

Â

# Degree of a relationship

*Degree *: the number of participating entities.

Degree 2: *binary*

Degree 3: *ternary*

Degree n: *n-ary*

Recursive relationship: An entity set relating to itself

gives rise to a *recursive *relationship.

Â

E.g., the relationship *prerequisite Of *is an example of a

recursive relationship on the entity *Course.*

Â

# Diagrammatic Notation for Relationships

Â

** **

** **

- Relationship - diamond shaped box
- Rectangle of each participating entity is connected by a line to this diamond. Name of the relationship is written in the box.

# Binary Relationships and Cardinality Ratio

** **

** **

** M N**

- The number of entities from
*E2*that an entity from*E1*can possibly be associated thru*R*(and vice-versa) determines the*cardinality ratio*of*R.* - Four possibilities are usually specified:

1. *one-to-one (1:1)*

2. *one-to-many (1:N)*

3. *many-to-one (N:1)*

4. *many-to-many (M:N)*

# Cardinality Ratios

** One-to-one: **An

*E1*entity may be associated with at most one

*E2*entity and similarly an

*E2*entity may be associated with at most one

*E1*entity.

** One-to-many: **An

*E1*entity may be associated with many

*E2*entities whereas an

*E2*entity may be associated with at most one

*E*1 entity.

* Many-to-one: â€¦ *( similar to above)

** Many-to-many: **Many

*E1*entities may be associated with a single

*E2*entity and a single

*E1*entity may be associated with many

*E2*entities.

A

B

C

R

E1 R E2

# Mapping Cardinalities

One to one One to many

*Many to one Many to many*Note: Some elements in A and B may not be mapped to any elements in the other set.

Â