Entity Relationship Diagrams
Entity–Relationship Diagrams and Database Design
What an ERD Represents
An Entity–Relationship Diagram (ERD) is a visual representation of the logical design of a database. It shows:
The kinds of things the database needs to keep track of.
The properties, or attributes, of those things.
The relationships between them.
How many instances of one thing can be associated with instances of another.
An ERD helps turn information requirements into a structured database design. It can also reveal whether the design supports the situations that users will encounter.
From Information Requirements to Entities
Consider a database that records which people own which pets. Its requirements might include keeping track of:
The owners’ names.
The pets’ names and photos.
The addresses where pets live.
The type of animal each pet is, such as a dog, cat, or hamster.
These requirements describe the information the database must support.
Identifying candidate concepts
A useful first step is to identify the nouns in the requirements. Nouns can suggest entities or attributes that the database may need to represent. The initial candidates might include:
People
Owners
Pets
Animals
Names
Photos
Types
Addresses
These candidates then need to be refined:
Convert plural terms to singular terms, such as changing “People” to “Person.”
Remove redundant terms. An owner is a person, so “Owner” need not be a separate concept if the requirements do not distinguish owners from other people.
Remove terms already covered by more specific terms. If the animals in scope are pets, “Animal” may be redundant.
Replace vague terms with precise ones. “Type” should become Pet Type if it means the kind of animal a pet is.
This produces the initial set of concepts: Person, Pet, Name, Photo, Pet Type, and Address.
Identifying nouns is a starting technique, not a rule that every noun must become an entity. A candidate may turn out to be an attribute rather than an entity, as happens with Name in this example.
Entities, Attributes, and Relationships
An entity is a kind of thing the database needs to represent, such as a person, pet, photo, or address. An attribute is a characteristic or property of an entity, such as a name or upload date. A relationship expresses how entities are associated.
For example, a pet database might need to represent these relationships:
A Person owns a Pet.
A Person has a Name.
A Pet has a Name.
A Photo depicts a Pet.
A Pet has a Pet Type.
A Pet resides at an Address.
These relationships matter independently of the entities themselves. For example, recording that Tricia Anderson and two pets exist is not enough if the database must also record that Tricia owns those particular pets.
A preliminary list of entities and relationships is useful, but it is not a complete design until the cardinality of each relationship has been decided.
Cardinality: How Many Things Can Be Related?
Cardinality describes how many instances of one entity can be associated with how many instances of another entity. It answers questions such as:
Can a pet have more than one owner?
Can a pet have no owner?
Can several pets have the same name?
Can an address have no pets, or several?
A relationship’s cardinality includes both:
Maximum cardinality: the greatest number of related instances allowed.
Minimum cardinality: the smallest number of related instances allowed.
Cardinality choices should match the requirements and have plausible justifications. If a design incorrectly restricts valid data—for example, by requiring every pet name to be unique when multiple pets may share a name—users may be unable to enter information the system is supposed to support.
Cardinalities in the pet example
The following decisions define the example database’s requirements:
Person and Pet: Each person owns zero or more pets; each pet is owned by zero or more people. A pet can therefore have no owners, one owner, or multiple owners.
Person and Name: Each person has exactly one name; each name may belong to zero or more people.
Pet and Name: Each pet has exactly one name; each name may belong to zero or more pets. Different pets may share a name.
Photo and Pet: Each photo depicts exactly one pet; each pet may be depicted in zero or more photos.
Pet Type and Pet: Each pet has exactly one pet type; each pet type may apply to zero or more pets.
Pet and Address: Each pet resides at zero or one address; each address may have zero or more pets living in it.
These decisions define permitted data, not merely visual details. Choosing the wrong cardinality can lead to a database that rejects valid information or permits information that should not be valid.
Chen Notation
Chen notation is one way to draw an ERD. It uses different shapes to distinguish entities, relationships, and attributes.
Entities and relationships
Each entity is drawn as a rectangle.
Each relationship is drawn as a diamond.
Lines connect a relationship diamond to the entities that participate in it.
For instance, Person and Pet appear as entity rectangles, while the relationship “owns” appears as a diamond connected to both.
Showing cardinality and participation
Chen notation can show maximum cardinalities at the ends of relationship lines. Values such as 1 and N indicate limits:
A maximum of 1 means no more than one related instance.
N means an unrestricted number of related instances.
For a mother–daughter example, a daughter has a maximum of one biological mother, while a mother may have a maximum of N daughters. The letters used at opposite ends need not be the same: using N and M avoids suggesting that the two maxima are necessarily equal.
Chen notation can also show whether participation is mandatory:
A double line indicates mandatory participation: the minimum number of related instances is at least one.
A single line indicates optional participation: the minimum may be zero.
In the mother–daughter example, a daughter must have a biological mother, so the daughter’s participation is mandatory. A mother need not have any daughters, so the mother’s participation is optional.
In the pet example, double lines indicate the relationships that every instance must participate in:
Every Pet must have a Name.
Every Person must have a Name.
Every Pet must have a Pet Type.
The Person–Pet ownership relationship is optional at both ends because a person may own no pets and a pet may have no owners.
Attributes and unique identifiers
Chen notation can also represent attributes:
An attribute is drawn as an oval connected to its entity.
A unique identifier can be emphasized by underlining the identifying attribute.
For example, a Photo might have the attributes Image Filename and Date Uploaded. If the system assigns each photo a unique Image Filename, that attribute uniquely identifies each Photo and is underlined.
An entity may instead be identified by a combination of attributes. For a Geographical Location, Latitude and Longitude together might uniquely identify a location. In that case, both attributes are underlined.
Weak entities
Sometimes an entity’s identity depends partly on the identity of a related entity. Such an entity is called a weak entity.
For example, an Order may contain multiple Order Lines, such as line 1, line 2, and so on:
Order is identified by Order Number.
Order Line is identified by Order Number together with Line Sequence Number.
The Order Line’s sequence number is not enough to identify the line globally; the line is identified within its parent Order. In Chen notation, a weak entity is shown with a double-bordered rectangle, and its identifying relationship to the parent is shown with a double-bordered diamond. The double borders indicate that the Order Line derives part of its identity from Order.
When a concept should be an attribute
A concept initially identified as a possible entity may be better represented as an attribute. In the pet example, every Person and every Pet has exactly one Name. It may be more natural to treat Name as an attribute of Person and an attribute of Pet rather than as a separate entity. The final modeling choice should reflect the requirements and how the information needs to be managed.
Chen notation has additional conventions, but the central elements are entities, relationships, cardinalities, participation, attributes, and identifiers.
Crow’s Foot Notation
Crow’s foot notation is another common way to represent ERDs. Unlike Chen notation, it does not use diamond shapes for relationships. A line between two entities indicates a relationship, and symbols at each end show its cardinality.
At each end of a relationship line, two symbols are used:
The first represents the minimum number of related instances.
The second represents the maximum number of related instances.
The available symbols are:
Circle: zero.
Vertical line: one.
Crow’s foot: many.
For example, a mother–daughter relationship can show that each mother has zero or more daughters, while each daughter has exactly one mother. The mother end uses a zero minimum and a many maximum; the daughter end uses a one minimum and a one maximum.
The three basic relationship types
The maximum cardinalities reveal three basic relationship types:
Many-to-many: A crow’s foot appears at both ends. For example, a person may own multiple pets, and a pet may have multiple owners.
One-to-many: A crow’s foot appears at one end, and a one appears at the other. For example, a pet type can apply to many pets, while each pet has one pet type. Read in the opposite direction, this is a many-to-one relationship.
One-to-one: A one appears at both ends, with no crow’s feet. For example, each employee has one employee ID card, and each employee ID card belongs to one employee.
Minimum cardinalities add further detail. A relationship may be optional, with a minimum of zero, or mandatory, with a minimum of one.
Applying crow’s foot notation to the pet database
The example relationships can be read as follows:
Person–Pet: Each person owns zero or more pets, and each pet is owned by zero or more people. This is many-to-many.
Pet–Photo: Each pet may have zero or more photos, while each photo depicts one pet. This is one-to-many from Pet to Photo.
Pet Type–Pet: A pet type may apply to zero or more pets, while each pet has one pet type. This is one-to-many from Pet Type to Pet.
Address–Pet: An address may have zero or more pets, while each pet resides at zero or one address. This is one-to-many from Address to Pet, with optional address assignment for a pet.
An ERD may also include attributes. It is often useful to show at least the attributes that uniquely identify each entity, along with other important attributes, without necessarily listing every attribute that the eventual database will contain.
Primary Keys, Foreign Keys, and Relational Tables
An ERD can be translated into the outline of a relational database:
Each entity becomes a table.
Each entity attribute becomes a column in that table.
A unique identifier becomes a primary key (PK), which identifies a row in its table.
A foreign key (FK) is an attribute that refers to a primary key in another table.
In an ERD, PK and FK labels can identify these roles. A foreign key allows the database to represent a relationship by storing a reference to the related row.
Implementing one-to-one and one-to-many relationships
A one-to-many relationship can generally be represented by placing a foreign key on the “many” side. For example, if many pets can have the same pet type, a Pet table can contain a foreign key referring to the Pet Type table.
One-to-one relationships can also be represented with foreign keys, subject to constraints that enforce the intended one-to-one cardinality. In both cases, foreign key constraints help ensure that references point to valid rows.
Resolving Many-to-Many Relationships
A many-to-many relationship cannot be represented directly by a single ordinary foreign key constraint. It is therefore transformed into two one-to-many relationships by introducing an associative entity, also called a junction entity or linking entity.
For the many-to-many relationship between Person and Pet, an entity called Pet Ownership can be introduced:
Person has a one-to-many relationship with Pet Ownership.
Pet has a one-to-many relationship with Pet Ownership.
Each Pet Ownership record refers to one person and one pet.
Each ownership pairing becomes a separate Pet Ownership record. If Jenny and Bill both own Rover, there are two records: one pairing Jenny with Rover, and one pairing Bill with Rover. If Martin owns both Skipper and Claude, there are two more records: one pairing Martin with Skipper, and one pairing Martin with Claude.
Pet Ownership becomes a table in the relational database. Its references to Person and Pet can be implemented as ordinary foreign keys. In this way, a many-to-many relationship is represented through two relationships that relational databases can enforce with foreign key constraints.

Ask anything
We've read this whole study set, so questions about it get the best answers.