Lectern

Search

Search IconIcon to open search

Entity-relationship model

Last updated Nov 1, 2022

A database visualisation model that describes interrelated things of interest in a specific domain of knowledge. Provides a detailed and logical representation of the data in a database.

# Terminologies

TermDefinition
Simple/Atomic attributeAn attribute that cannot be further divided into smaller attributes
Composite attributeAn attribute that is made up of multiple components, each with an independent existence
Single-valued attributeAn attribute that holds only a single value for a single entity (e.g., name, gender, ID)
Multi-valued attributeAn attribute that holds multiple values for a single entity (e.g., phone numbers, qualifications)
Derived attributeAn attribute that represents a value derivable from the value of related attributes

# Symbols

SymbolRepresentation
RectangleEntity (singular)
Concentric rectangleWeak entity (singular)
OvalSimple/Composite single-valued attribute; underlined attributes represent primary keys
Concentric ovalSingle/Composite multi-valued attribute
Dotted ovalDerived attribute
DiamondRelationship (verb)
LineRepresentation
Single linePartial/Optional participation
Double lineTotal/Mandatory participation
Line with horseshoeSubtype declaration

# Relationships

# Degrees of relationships

Relationships can have different degrees to show in an ER model. Common degrees include the:

# Unary relationships

Represents the relationship between instances of a single entity. Also known as a recursive relationship.

# Binary relationships

Represents the relationship between instances of two entities. Is the most common type of relationship encountered in data modelling.

# Ternary relationships

Represents the relationship among instances of three entities.

# Relationship constraints

Relationships can be constrained such that only certain cases are valid in a database. This helps to plan out a database in greater detail.

# Cardinality ratio

Refers to the number of instances of an entity that can be associated with an instance of another entity. The three most commonly-used cardinality ratios used in databases include:

# Participation

Specifies whether the existence of an entity depends upon it being another entity through the relationship. Shown in the ER diagram as different strokes of lines connecting entities and relationships.

Generally has two participation constraints:

# Types

There are two types of entities that can be drawn in an ER model. These are akin to base and derived classes in object-oriented programming:

The process of defiing a set of subtypes of an entity is known as specialisation.

The reverse process of abstraction, which involves:

is known as generalisation.

# Constraints

Similar to relationship constraints, there are constraints when it comes to specialisation and abstraction.

# Disjointment

An entity must only have one subtype or can have many subtypes according to the context of the situation. This is referred to as the disjoint constraint, in which an additional symbol (a circle with a character below) is added to denote the case.

When a specialisation consists of only one subtype, there is no need to show the disjoint constraint.

# Participation

Specifies whether the existence of an entity depends upon it being another entity through the relationship. Shown in the ER diagram as different strokes of lines connecting entities and relationships.

Generally has two participation constraints:

# Rough outline of steps

  1. Identify the main entities in the user’s view of the enterprise.
  2. Identify the important relationships existing between the identified entities.
  3. Associate attributes with an appropriate entity or relationship.
  4. Identify the candidate keys for each entity before settling on a primary key.
  5. Identify supertypes and subtypes where appropriate.
  6. Draw the ER model for the database.
  7. Review the ER model.
  8. Reiterate where required.