1Creating ER Diagrams
▶
An Entity-Relationship (ER) diagram is a visual blueprint of a database. It captures the things a system needs to track, the properties that describe those things, and the associations between them — all before a single table is created or a line of SQL is written. Mastering ER diagrams is foundational to database design because a well-constructed diagram translates directly into a correct, efficient relational schema, while a poorly constructed one leads to redundancy, anomalies, and maintenance nightmares. This topic walks through every major element of ER diagramming: the notation and symbols used, how to identify what belongs in the diagram, how to annotate it with constraints, and how to translate a real-world problem description into a finished diagram.
Understanding ER Diagram Notation and Symbols
ER diagrams use a small, consistent vocabulary of shapes. Each shape carries a precise meaning, and learning to read and draw them fluently is the first step toward becoming proficient in database design.
- Rectangles represent entities. An entity is any distinct object, person, place, or concept about which the system must store information. The entity's name — always a singular noun — appears inside the rectangle. For example, a university database would contain rectangles labeled Student, Course, and Instructor. Every rectangle signals: "there will be a table for this concept."
- Ellipses (ovals) represent attributes. An attribute is a property or characteristic of an entity. Each ellipse is connected by a line to the rectangle of the entity it describes. For instance, the Student entity might have ellipses labeled StudentID, Name, and DateOfBirth. Different styles of ellipse convey different kinds of attributes, as described in the attributes section below.
- Diamonds represent relationships. A diamond sits between two (or more) entity rectangles and is connected to each by a line. The label inside the diamond is a descriptive verb or verb phrase — for example, Enrolls In between Student and Course, or Teaches between Instructor and Course. The diamond makes explicit the business rule that connects those entities.
- Lines complete the diagram structure. Plain lines connect entities to their attribute ellipses, and also connect entities to the relationship diamonds they participate in. The style of the line (single or double) carries additional meaning about participation constraints, covered later.
Together, these four symbols — rectangle, ellipse, diamond, line — form a grammar that can describe virtually any data model at the conceptual level.
Identifying Entities from a Problem Domain
Reading a problem description and identifying the right entities is more of a skill than a formula. The following guidelines provide a reliable starting point.
- Entities are typically nouns in the problem statement. When you read a requirements document, highlight every noun. People (Customer, Employee), places (Branch, Warehouse), things (Product, Invoice), and concepts (Account, Policy) are all strong candidates. Not every noun becomes an entity — some turn out to be attributes — but scanning for nouns is the right first move.
- Each entity must be distinct and have multiple instances. An entity type represents a class of things, not a single specific item. Student is an entity type because there are many students; John Smith is an instance of that type, not a separate entity. If you cannot imagine many real-world examples of something, it probably should not be its own entity.
- Weak entities depend on a strong entity for their existence. Some entities cannot be uniquely identified by their own attributes alone — they require a relationship with another entity. These are called weak entities and are drawn with a double rectangle. The strong entity they depend on is called the owner entity, and the relationship between them is drawn with a double diamond. A classic example is Dependent (a family member of an employee) in an HR database: a dependent has no meaningful existence in the system apart from the Employee it belongs to. The partial key of a weak entity — the attribute that distinguishes instances within the same owner — is shown with a dashed underline rather than a solid one.
Consider a library system. The problem statement might say: "The library lends books to members. Each book belongs to a genre. Members can place holds on books that are currently checked out." From this, candidate entities are Book, Member, and Genre. Hold might be a relationship with attributes, or possibly its own entity if it carries significant data.
Defining and Placing Attributes
Once entities are identified, each one must be equipped with the attributes that describe it. Attributes come in several varieties, each drawn differently.
- Key attributes uniquely identify each instance of an entity. In the ellipse, the attribute name is underlined. For the Student entity, StudentID would typically be the key attribute. A key must be unique across all instances and must never be null. Choosing a good key is critical: natural keys (like a Social Security Number) exist in the real world, while surrogate keys (like an auto-incremented integer) are invented purely for database purposes.
- Multivalued attributes can hold more than one value for a single entity instance. They are drawn with a double ellipse. An example is PhoneNumber on a Person entity: one person can have a mobile number, a home number, and a work number simultaneously. In the eventual relational schema, multivalued attributes typically become a separate table.
- Derived attributes have values that can be computed from other stored data. They are shown with a dashed ellipse. For example, Age can be derived from DateOfBirth and the current date. Derived attributes are shown in the diagram to communicate the business rule, but they are usually not stored in the database — they are calculated at query time.
- Composite attributes are attributes that can be broken down into smaller, meaningful sub-parts. They are drawn in a tree structure: the composite attribute ellipse connects to sub-attribute ellipses via lines. FullName is composite — it decomposes into FirstName, MiddleName, and LastName. Similarly, Address might decompose into Street, City, State, and ZipCode. Composite attributes are useful when individual components must be queried or sorted independently.
- Simple (atomic) attributes cannot be further subdivided and hold a single value. DateOfBirth and GPA are typical simple attributes. These are the most common type and require no special notation beyond a plain ellipse.
The table below summarises the visual conventions for each attribute type:
| Attribute Type | Visual Notation | Example |
|---|---|---|
| Simple (atomic) | Plain ellipse | GPA, DateOfBirth |
| Key | Plain ellipse with underlined name | StudentID, ISBN |
| Multivalued | Double ellipse | PhoneNumber, EmailAddress |
| Derived | Dashed ellipse | Age, TotalOrderValue |
| Composite | Ellipse with child ellipses | FullName → {FirstName, LastName} |
| Partial key (weak entity) | Ellipse with dashed underline | DependentName |
Drawing Relationships Between Entities
Relationships are the connective tissue of an ER diagram. They represent meaningful associations between entities and encode the business rules of the domain.
- Relationship labels should be descriptive verb phrases. Instead of a vague label like Has, prefer something that reads naturally: Enrolls In, Manages, Supplies. A well-labeled diamond makes the diagram self-documenting. It should be possible to read a relationship as a sentence: "A Student Enrolls In a Course."
- Binary relationships involve exactly two entity types and are by far the most common. The diamond connects to one entity on each side. Examples: Employee — Works For — Department; Author — Writes — Book.
- Ternary relationships involve three entity types simultaneously, all connected to a single diamond. They arise when the association is genuinely three-way and cannot be decomposed into binary relationships without losing information. A textbook example is a Supplier supplying a Part to a Project — the supply relationship only makes sense when all three participants are known together. Ternary relationships require careful thought: sometimes what appears three-way can actually be modeled as two binary relationships; other times, forcing it into binaries introduces semantic errors.
- Relationship attributes are attributes that describe the relationship itself, not any single participating entity. They are shown as ellipses attached to the relationship diamond. Consider the Enrolls In relationship between Student and Course: the attribute Grade belongs to the enrollment event, not to the student alone or the course alone — a student has different grades in different courses. Therefore Grade is a relationship attribute attached to the Enrolls In diamond. Similarly, HireDate on an Employee–Works For–Department relationship records when an employee joined that department, which is logically a property of the assignment rather than the employee or department.
Expressing Cardinality and Participation Constraints
Constraints are what give an ER diagram its real power. They encode business rules directly in the diagram, reducing ambiguity about how the data behaves.
- Cardinality ratios describe how many instances of one entity can be associated with how many instances of another through a given relationship. There are three fundamental ratios:
| Ratio | Notation on Diagram | Meaning | Example |
|---|---|---|---|
| One-to-One (1:1) | "1" on both lines | Each instance on either side relates to at most one instance on the other | Employee manages one Department; Department has one Manager |
| One-to-Many (1:N) | "1" on one side, "N" on the other | One instance on the "1" side relates to many on the "N" side | One Department employs many Employees |
| Many-to-Many (M:N) | "M" and "N" on the lines | Many instances on each side can relate to many on the other | Students enroll in many Courses; Courses have many Students |
- Total participation (also called existence dependency) means that every instance of an entity must participate in the relationship — there are no exceptions. It is shown with a double line connecting the entity to the relationship diamond. For example, every Order must be placed by a Customer — an order without a customer is meaningless in most business systems. Total participation often signals a NOT NULL foreign key constraint in the resulting schema.
- Partial participation means that some instances of the entity may not participate in the relationship at all. It is shown with a single line. For example, not every Employee manages a Department — most employees are non-managers. The line from Employee to the Manages diamond would be a single line.
Reading constraints together gives precise statements like: "Every Order (total, double line) must be placed by exactly one Customer (1:N cardinality), but a Customer may exist without placing any Orders (partial, single line)." This level of precision directly informs referential integrity rules in the schema.
Some notations (particularly crow's foot notation, widely used in industry tools) express both cardinality and participation simultaneously using symbols at the ends of lines: a straight perpendicular bar for "exactly one," a circle for "zero," and a crow's foot (three prongs) for "many." While the classic Chen notation described here uses separate labels and line styles, crow's foot notation conveys the same information more compactly and is worth recognising when reading diagrams produced by tools like Lucidchart, draw.io, or MySQL Workbench.
Translating a Problem Description into an ER Diagram
The process of going from a written problem statement to a finished ER diagram follows a systematic sequence of steps.
- Step 1 — Read and annotate the problem statement. Read the full description at least twice. On the second pass, underline or highlight nouns (candidate entities and attributes) and circle verbs (candidate relationships). Look for numerical words like "each," "every," "one," "many," or "multiple" — these hint at cardinality. For example: "Each student can enroll in many courses, and each course can have many students enrolled. A course is taught by exactly one instructor, but an instructor may teach several courses."
- Step 2 — Draft a candidate list. From your annotations, make a preliminary list of entities, relationships, and attributes. At this stage, don't worry about being perfect — just capture everything. You might list: Entities: Student, Course, Instructor. Relationships: Enrolls In (Student–Course), Teaches (Instructor–Course). Attributes: Student has StudentID, Name, Major; Course has CourseID, Title, Credits; Instructor has InstructorID, Name, Office.
- Step 3 — Sketch a rough layout. Place entity rectangles as nodes on paper or a whiteboard. Connect entities involved in the same relationship with a diamond between them. Don't attach attributes yet — focus on getting the skeleton of entities and relationships right first. This rough sketch lets you spot missing relationships or entities quickly without the clutter of attributes.
- Step 4 — Add attributes. For each entity, attach its attribute ellipses. Identify which attribute is the key and underline it. Identify any multivalued, derived, or composite attributes and apply the correct notation. Attach any relationship attributes to their diamonds.
- Step 5 — Mark cardinality and participation constraints. Return to the problem description and extract the numeric rules. Mark the cardinality ratios (1:1, 1:N, M:N) on the lines. Add double lines for total participation. Every constraint you mark should be traceable to a sentence in the requirements.
- Step 6 — Validate against the problem statement. Read each business rule in the problem description and confirm there is a corresponding structure in the diagram. If the problem says "a loan must be associated with a branch," check that Loan has total participation in its relationship with Branch. If something is not represented, the diagram is incomplete.
- Step 7 — Iterate and refine. Remove any redundancies — if two relationships express the same association, collapse them into one. Rename anything that is vague. Restructure the layout to reduce line crossings. The diagram should be readable by someone who was not involved in drawing it.
As a worked illustration, consider this short problem: "A hospital tracks patients and the rooms they are admitted to. Each patient is admitted to exactly one room at a time. A room can hold multiple patients. Nurses are assigned to care for patients; each patient has multiple nurses and each nurse cares for multiple patients. Each nurse works in exactly one ward."
From this: Entities are Patient, Room, Nurse, Ward. Relationships are Admitted To (Patient–Room, many patients to one room; total participation for Patient), Cares For (Nurse–Patient, M:N), and Works In (Nurse–Ward, many nurses to one ward; total participation for Nurse). Key attributes: PatientID, RoomNumber, NurseID, WardID.
Best Practices for Clear and Accurate ER Diagrams
Technical correctness is necessary but not sufficient — a diagram that cannot be read quickly and without ambiguity will cause errors downstream. The following best practices keep diagrams professional and useful.
- Use consistent, descriptive naming conventions. Entity names should be singular nouns (Customer, not Customers). Relationship labels should be active verb phrases (Places, Assigns, Belongs To). Attribute names should be self-explanatory (DateOfBirth rather than DOB or d). Consistency means a reader does not need to ask "what does this label mean?"
- Minimise line crossings. Crossed lines are visually confusing and make it difficult to trace which entity connects to which relationship. Arrange entities so that the most heavily connected ones are central, with less connected entities on the periphery. Try multiple arrangements before settling on a layout.
- Stay at the conceptual level. An ER diagram is a conceptual model. Do not include data types (VARCHAR(50)), indexes, or storage details. Do not indicate primary keys using PK notation from physical design tools — use the underlined ellipse convention. Implementation details belong in the logical and physical design phases that follow.
- Include a legend for non-standard notation. If you are using mixed notation styles — for example, combining Chen symbols with crow's foot cardinality markers — include a small legend in a corner of the diagram explaining each symbol. Different teams and tools use different conventions, and a legend prevents misinterpretation.
- Avoid over-engineering. Not every nuance of the domain needs to be in the ER diagram. If a distinction is not needed to correctly store and retrieve data, it is complexity without benefit. The goal is the simplest diagram that correctly captures all the business rules.
- Have a domain expert review the diagram. The ultimate test of an ER diagram is whether the people who understand the business recognise their rules and processes in it. A technical review catches notation errors; a domain review catches semantic errors — and semantic errors are far more costly to fix once a schema is built.
ER diagramming is an iterative, collaborative craft. The first draft is almost never the final one, and that is expected. Each revision cycle — drawing, validating, correcting — deepens your understanding of both the notation and the problem domain, producing a diagram that serves as a reliable contract between analysts, developers, and database administrators for the entire lifecycle of the system.