Based on the SQLD exam syllabusReport an error
In an ERD, a single line is drawn between Customer and Order. That line carries three pieces of information at once: "a customer places orders," "one customer can place many orders," and "there are customers who have not placed any order." Reading a relationship means pulling that information out of the shape of the line.
| Classification | Meaning | Online store example | Textbook example |
|---|---|---|---|
| Relationship by existence | One entity is connected to another entity by its very existence. The relationship holds even without any action | A product belongs to a product category | An employee belongs to a department |
| Relationship by action | The relationship arises only when one entity performs some action | A customer places an order | A customer places an order |
| Notation | Existence relationship | Action relationship |
|---|---|---|
| ERD | Not distinguished (same relationship line) | Not distinguished (same relationship line) |
| UML class diagram | Association — solid line | Dependency — dashed line |
| Element | English | Question it asks |
|---|---|---|
| Relationship name | Membership | What kind of relationship do the two entities have? |
| Cardinality | Cardinality | With how many instances on the other side is one instance connected? |
| Optionality | Optionality | Does it necessarily participate in the relationship, or optionally? |
| Naming rule | Good example | Bad example |
|---|---|---|
| Avoid vague verbs | places, contains, belongs to | is related to, has to do with, is, does |
| Use the present tense | places | placed, will place |
| Cardinality | Meaning | Online store example |
|---|---|---|
| 1:1 | One instance is connected to only one instance on the other side | Order - Payment (if the business allows only one payment per order) |
| 1:M | One instance is connected to many instances on the other side | Customer - Order |
| M:N | Both sides are connected to many instances on the other side | Order - Product |
Leaving M:N as is Resolved with an intersection entity
┌───────┐ M N ┌─────────┐ ┌───────┐ 1 M ┌────────────┐ M 1 ┌─────────┐
│ Order │ ──────── │ Product │ │ Order │ ───── │ Order Item │ ───── │ Product │
└───────┘ └─────────┘ └───────┘ └────────────┘ └─────────┘
Order No. (FK)
Product No. (FK)
Order Quantity| Specification | Meaning | Online store example |
|---|---|---|
| Mandatory participation | Every instance necessarily participates in the relationship | Every order necessarily has a customer who placed it |
| Optional participation | There may be instances that do not participate in the relationship | There may be customers who have never placed an order |
A relationship is read in a fixed order.
| Order | What you read | Expression |
|---|---|---|
| 1 | Base entity | "Each ~" or "One ~" |
| 2 | Number of target entities (cardinality) | "one," "one or more (many)" |
| 3 | Optionality | "always" if mandatory, "sometimes" if optional |
| 4 | Relationship name | "places," "belongs to" |
Reading the Customer - Order relationship (Customer side optional, Order side mandatory, 1:M) from both sides gives the following.
Each Customer sometimes places many orders.
(base entity) (optional) (rel. name) (number)
Each Order is always placed by one customer.
(base entity) (mandatory) (rel. name) (number)The business sentence "a customer puts a product in the cart" has the verb "puts." It serves as grounds for considering a relationship between Customer and Product (or an intersection entity called Cart).
Both notations show cardinality and optionality through the shape of the line ends. The direction in which the symbols are read differs, which makes them easy to confuse.
| Item | IE (Information Engineering) | Barker |
|---|---|---|
| Many (M) | Crow's foot at the line end | Crow's foot at the line end |
| One (1) | Short bar at the line end, no crow's foot | No crow's foot |
| Mandatory | Short bar | Solid line |
| Optional | Circle O | Dashed line |
| Entity shape | Rectangle (top compartment identifier, bottom compartment regular attributes) | Rectangle with rounded corners |
| Attribute marking | Separated by compartments | # identifier, * mandatory, o optional |
IE notation (Customer 1 — Order 0..M)
┌──────────┐ ┌───────┐
│ Customer │ ┼────────────O< │ Order │
└──────────┘ └───────┘
┼ : Customer as seen from the Order side = one, mandatory
O< : Order as seen from the Customer side = many, optional
Barker notation (same relationship)
╭──────────╮ ╭───────╮
│ Customer │ - - - -───────< │ Order │
╰──────────╯ ╰───────╯
Customer-side half dashed : Customer is optional participation
Order-side half solid : Order is mandatory participation
Crow's foot on Order side : One customer, many ordersO at the Order end means "a customer may have no orders."⚠️ The positions of the optionality symbols look reversed between the two notations. IE's
Ois drawn at the target entity's end, and Barker's dashed line is drawn on the base entity's half. For diagram questions, first check which end the symbol is on.
Next week we move on to identifiers and normalization to see how to refine a model.
#, *, and o.Click a choice to reveal the answer and explanation.
Question 1
Which is the LEAST appropriate statement about relationships?
Question 2
Which of the following is the LEAST related to the concepts used when notating a relationship?
Question 3
In an online store, one order can contain multiple products, and one product can be included in multiple orders. Which is the most appropriate way to implement this in a relational database?
Question 4
In the relationship between Customer and Order, the Customer side is optional participation, the Order side is mandatory participation, and the cardinality is 1:M. Which correctly reads the relationship from the Order's perspective?
Question 5
Which is the most appropriate principle for naming a relationship?