Entities, Relationships, and Attributes


The Entity-Relationship Model

An entity-relationship model is a high-level representation of data requirements, ignoring implementation details.

  • guides implementation in a particular database system
  • includes three kinds of objects:
    • An entity is a person, place, product, concept, or activity
    • relationship is a statement about two entities
      • reflexive relationship relates an entity to itself
    • An attribute is a descriptive property of an entity
      • domain is the set rules that govern possible values for an attribute

Entity-Relationship Diagram and Glossary

An entity-relationship diagram (ER diagram) depicts entities, relationships, and attributes.

  • depicts:
    • entities as rectangles with rounded corners
    • relationships as lines connecting rectangles
    • and attributes within entity rectangles
  • always include entities and relationships
    • attributes are optional
  • full name of a relationship includes entities
    • written as ‘entity-relationship-entity’
    • always read clockwise
  • completely described by:
    • ER diagram + glossary

A glossary documents additional detail in text format.

  • aka data dictionary or repository
  • includes names, synonyms, and descriptions of entities, relationships, and attributes

Types and Instances

A type is a set.

  • entity type
    • set of things
  • relationship type
    • set of related things
  • attribute type
    • set of values
  • Entity, relationship, and attribute types become tables, foreign keys, and columns

An instance is an element of a set.

  • entity instance
    • an individual thing
  • relationship instance
    • statement about entity instances
  • attribute instance
    • individual value
  • entity, relationship, attribute instances become rows, foreign key values, and column values

Example Types and Instances

TypeInstance
EntityPassenger
AttributeBookingCode
RelationshipPassenger-Holds-Booking

Database Design

  • Complex databases are developed in three phases:
    1. Conceptual design
      • develops an entity-relationship model, capturing data requirements while ignoring implementation details
      • can be omitted for simple databases
    2. Logical design
      • converts the entity-relationship model into tables, columns, and keys for a particular database system
    3. Physical design
      • adds indexes and specifies how tables are organized on storage media

Conceptual Design Steps

  1. Discover entities, relationships, and attributes
  2. Determine cardinality
  3. Distinguish strong and weak entities
  4. Create supertype and subtype entities

Logical Design Steps

  1. Implement entities
  2. Implement relationships
  3. Implement attributes
  4. Apply normal form