An ERD, or entity relationship diagram, is a graphical representation of how tables in a database connect to each other. ERDs show a database’s structure (or schema) at a high-level. ERDs are a useful tool when designing a new data model or identifying issues within an existing schema.
- Entity relationship diagrams are basically just boxes (your entities, or tables) connected with lines (the relationships between them).
- Your database software may have some built-in functionality to create ERDs, but you can also use whatever design software you like best or go the analog route and draw out your ERD on a piece of paper.
- The how is less important; what really matters is making sure that your diagram is accurate and logical, so you can design the most effective database for your specific use case.
- The four tables,
Orders
,Products
,People
, andReviews
, are our entities, and the connecting lines show the three one-to-many relationships between them.

ERD design and notation
- When sketching out an entity relationship diagram, each box should contain information like that table’s name, field, and key information (primary and foreign keys).
- You’ll notice in the example above that each table’s key information is indicated with (PK) and (FK) next to field names.
The type of line between each entity illustrates the kind of relationship each table has to another. Different organizations and industries use different conventions for ERD notation, but one of the most common is crow’s foot notation, named because the three-pronged symbol (the one that gets used for “to many”) looks a bit like the foot of a bird.
Figure 2 shows the common symbols used in crow’s foot notation and their corresponding relationship types:

Here’s an explanation of each type of crow’s foot notation and when to use it:
- To One (|)
- Notation: A straight line ending with one short perpendicular line (|).
- Usage: Used when there is exactly one relationship between entities. For example, in a one-to-one relationship, where each record in one table is associated with only one record in another table (e.g., each user has only one profile).
- Entities:
Employees
andDepartments
- Relationship: Each employee belongs to one department.
- Explanation: This represents a many-to-one relationship where each employee is linked to only one department.
- Explanation: The
Employees
table has a many-to-one relationship with theDepartments
table. This means that each employee belongs to only one department, but each department can have multiple employees. In this setup, thedepartment_id
in theEmployees
table acts as a foreign key linking each employee to a specific department. This structure ensures that every employee has a single department association, while allowing departments to manage numerous employees.
Employees ──|──── Departments
Tables: Employees
and Departments
- To Many (<)
- Notation: A line ending with a “crow’s foot” (three prongs).
- Usage: Indicates a many-to-many relationship. It’s used when multiple records in one table relate to multiple records in another table (e.g., students can enroll in multiple courses, and each course can have multiple students). This relationship often requires a junction table.
- Entities:
Products
andCategories
- Relationship: Products and categories have a many-to-many relationship through a junction table
ProductCategories
. - Explanation: Each product can belong to multiple categories, and each category can include multiple products. This is achieved through the
ProductCategories
junction table. - Tables:
Products
andCategories
, linked throughProductCategories
- Explanation: The
Products
andCategories
tables have a many-to-many relationship managed through theProductCategories
junction table. In this case, each product can be assigned to multiple categories (e.g., a product might fit under “Electronics” and “Home Appliances”), and each category can contain multiple products. TheProductCategories
table holds foreign keys from bothProducts
andCategories
, enabling flexible product categorization across the database.
Products ───< ProductCategories >───> Categories
- To One and Only One (||)
- Notation: Two parallel vertical lines at the end of the line (||).
- Usage: Used to represent a mandatory one-to-one relationship, where each record in one table must correspond to exactly one record in another table. This ensures that each entity on both sides of the relationship has a match.
- Entities:
Users
andProfiles
- Relationship: Each user has exactly one profile, and each profile belongs to exactly one user.
- Explanation: This one-to-one mandatory relationship ensures that each user has a unique profile and vice versa.
- Tables:
Users
andProfiles
- Explanation: The
Users
andProfiles
tables exhibit a one-to-one mandatory relationship. Each user must have a unique profile, and each profile corresponds to exactly one user. In this schema, theuser_id
in theProfiles
table is unique and corresponds to auser_id
in theUsers
table, ensuring that every user is linked to a single, distinct profile, and no user exists without one. - To One or Many (|<)
- Notation: A vertical line and a crow’s foot (|<).
- Usage: Used in one-to-many relationships where one record in the primary table relates to one or many records in the associated table (e.g., a single department can have many employees, but each employee belongs to only one department).
- Entities:
Projects
andTasks
- Relationship: Each project can have one or more tasks.
- Explanation: This one-to-many relationship shows that each project can have multiple tasks, but each task belongs to only one project.
- Tables:
Projects
andTasks
- Explanation: This one-to-many relationship between the
Projects
andTasks
tables allows each project to include multiple tasks, but each task is associated with only one project. Theproject_id
in theTasks
table is a foreign key that connects each task to a specific project, facilitating organized task tracking within projects while allowing projects to manage multiple related tasks. - To One or Zero (|O)
- Notation: A vertical line followed by a circle (|O).
- Usage: Used for an optional one-to-one relationship. It indicates that a record in one table may have a related record in another table, but it’s not required. For example, an employee may or may not have a company car.
- Entities:
Orders
andShippingDetails
- Relationship: Each order may optionally have a shipping detail, but each shipping detail is tied to only one order.
- Explanation: This optional one-to-one relationship allows an order to exist without a shipping detail, but if a shipping detail exists, it links to only one order.
- Tables:
Orders
andShippingDetails
- Explanation: The relationship between
Orders
andShippingDetails
is an optional one-to-one relationship. Each order may or may not have a corresponding shipping detail, but any shipping detail in theShippingDetails
table is linked to only one order. This is useful in cases where not all orders require shipping, allowing flexibility by not mandating that every order has associated shipping details.
Users ───||─── Profiles
Projects ───|<─── Tasks
Orders ───|O─── ShippingDetails
- To Zero or Many (O<)
- Notation: A circle followed by a crow’s foot (O<).
- Usage: Represents an optional many-to-many relationship, where records in one table may have multiple matching records in another table, but having a relationship isn’t mandatory. For example, a project may have many tasks, and a task may be related to multiple projects, but not all projects have tasks.
- Entities:
Customers
andCustomerOrders
- Relationship: A customer may have zero or many orders.
- Explanation: This optional one-to-many relationship shows that a customer can have multiple orders, but it’s also possible for a customer to have no orders.
- Tables:
Customers
andCustomerOrders
- Explanation: The
Customers
andCustomerOrders
tables demonstrate a one-to-many optional relationship, where a customer may place zero or multiple orders. Thecustomer_id
in theCustomerOrders
table references theCustomers
table, allowing each customer to have any number of orders or no orders at all, giving flexibility in representing customer order history within the database.
Customers ───O<─── CustomerOrders