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
- A relationship is a statement about two entities
- A 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
Type Instance Entity Passenger Attribute BookingCode Relationship Passenger-Holds-Booking
Database Design
- Complex databases are developed in three phases:
- Conceptual design
- develops an entity-relationship model, capturing data requirements while ignoring implementation details
- can be omitted for simple databases
- Logical design
- converts the entity-relationship model into tables, columns, and keys for a particular database system
- Physical design
- adds indexes and specifies how tables are organized on storage media
- Conceptual design
Conceptual Design Steps
- Discover entities, relationships, and attributes
- Determine cardinality
- Distinguish strong and weak entities
- Create supertype and subtype entities
Logical Design Steps
- Implement entities
- Implement relationships
- Implement attributes
- Apply normal form