CertNote/ Commute Study Notes
Roadmap
KOEN
CLF-C02 · FoundationalCloud Practitioner - Foundational
DVA-C02 · AssociateDeveloper - Associate
SAA-C03 · AssociateSolutions Architect - Associate
SOA-C02 · AssociateCloudOps Engineer - Associate
SAP-C02 · ProfessionalSolutions Architect - Professional
DOP-C02 · ProfessionalDevOps Engineer - Professional
Linux Master 2 · 2급KAIT Linux Master - Level 2
SCS-C03 · SpecialtySecurity - Specialty
Linux Master 1 · 1급KAIT Linux Master - Level 1
MLA-C01 · AssociateMachine Learning Engineer - Associate
AIF-C01 · FoundationalAI Practitioner - Foundational
DEA-C01 · AssociateData Engineer - Associate
MLS-C01 · SpecialtyMachine Learning - Specialty
SQLD · 개발자SQL Developer (SQLD)
  • Week 1
    • 1.Data Modeling Overview
    • 2.Three-Level Schema and Modeling Stages
    • 3.Entities
    • 4.Attributes
    • 5.Relationships
  • Week 2
  • Week 3
  • Week 4
  • Week 5
  • Week 6
  • Week 7
  • Week 8

© CertNote · 주간랩스

  • About
  • Changelog
  • Contact
  • Terms
  • Privacy
← SQLD/Week 1/Day 5

Based on the SQLD exam syllabus·Report an error

SQLD· AssociateWeek 1 · Day 5~24 min read

Day 5 - Relationships

📌 Key Takeaways

  • A relationship is a logical association between instances of entities, formed through existence or action. A single individual connection is called a pairing.
  • Relationships are divided into relationships by existence (a product belongs to a category) and relationships by action (a customer places an order). An ERD does not distinguish the two, while UML distinguishes them as association and dependency.
  • The three elements of relationship notation: relationship name, cardinality (1:1, 1:M, M:N), and optionality (mandatory/optional).
  • Reading order for a relationship: base entity (each) → number of target entities → optionality (always/sometimes) → relationship name.
  • The IE notation draws relationships with crow's feet, circles, and bars; the Barker notation draws them with crow's feet and solid/dashed lines.

A Sentence Packed into a Single Line

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.

Definition

  • It is a logical association between instances of entities.
  • It refers to a state in which an association is given to each other in the form of existence or action.
  • A relationship is drawn between entities, but what is actually connected are instances. The single connection "customer C001 placed order O1001" is a pairing.
  • Instances within an entity can each form different pairings. C001 may have three orders while C002 has none. The set of these pairings is bundled together and expressed as a relationship.

Relationships by Existence and Relationships by Action

ClassificationMeaningOnline store exampleTextbook example
Relationship by existenceOne entity is connected to another entity by its very existence. The relationship holds even without any actionA product belongs to a product categoryAn employee belongs to a department
Relationship by actionThe relationship arises only when one entity performs some actionA customer places an orderA customer places an order
  • From the moment a product is registered, it belongs to some category. It is not a relationship that arose because something was done.
  • The relationship between a customer and an order arises when the customer performs the action of ordering. A customer who has only signed up and not ordered has no pairing in this relationship.

Difference Between ERD and UML

NotationExistence relationshipAction relationship
ERDNot distinguished (same relationship line)Not distinguished (same relationship line)
UML class diagramAssociation — solid lineDependency — dashed line
  • An association is a relationship in which a class references another class as a member variable, and a dependency is a relationship in which a class uses the other class only when performing an action (method).
  • In an ERD, solid and dashed lines can mean identifying/non-identifying relationships or optionality. This differs from the meaning of solid and dashed lines in UML.

The Three Elements of Relationship Notation

ElementEnglishQuestion it asks
Relationship nameMembershipWhat kind of relationship do the two entities have?
CardinalityCardinalityWith how many instances on the other side is one instance connected?
OptionalityOptionalityDoes it necessarily participate in the relationship, or optionally?

Relationship Name

  • A relationship gets two names. They are the names seen from the side where the relationship begins (The Beginning) and the side where it ends (The End).
  • The Customer → Order direction is "places," and the Order → Customer direction is "is placed by" (or "is requested by"); each perspective is named separately.
Naming ruleGood exampleBad example
Avoid vague verbsplaces, contains, belongs tois related to, has to do with, is, does
Use the present tenseplacesplaced, will place

Cardinality

CardinalityMeaningOnline store example
1:1One instance is connected to only one instance on the other sideOrder - Payment (if the business allows only one payment per order)
1:MOne instance is connected to many instances on the other sideCustomer - Order
M:NBoth sides are connected to many instances on the other sideOrder - Product
  • Cardinality is determined by business rules. For an online store that allows split payments, Order - Payment becomes 1:M.
  • A relational database cannot implement M:N directly. So an intersection entity (associative entity) is placed between the two to resolve it into two 1:M relationships.
  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
  • Order Item is the transaction entity we saw on Day 3. It arises from two parents (Order and Product) and has its own attributes such as order quantity.

Optionality

SpecificationMeaningOnline store example
Mandatory participationEvery instance necessarily participates in the relationshipEvery order necessarily has a customer who placed it
Optional participationThere may be instances that do not participate in the relationshipThere may be customers who have never placed an order
  • The two sides of one relationship can have different optionality. The Customer side is optional, and the Order side is mandatory.
  • Getting optionality wrong changes the business rule. If you draw the Customer side as mandatory, it becomes the rule "you must place an order to sign up."

How to Read a Relationship

A relationship is read in a fixed order.

OrderWhat you readExpression
1Base entity"Each ~" or "One ~"
2Number of target entities (cardinality)"one," "one or more (many)"
3Optionality"always" if mandatory, "sometimes" if optional
4Relationship 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 base entity is always read as "each" one. The number is the number on the opposite side.
  • Even for the same line, the sentence differs depending on which side you read from. When a question asks "which correctly reads the following relationship," check both directions.

What to Check When Defining a Relationship

  • Is there an association rule of interest between the two entities?
  • Does a combination of information occur between the two entities?
  • Does the business description or document state a rule about connecting the relationship?
  • Does the business description or document contain a verb that makes the relationship connection possible?

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).

IE Notation and Barker Notation

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.

ItemIE (Information Engineering)Barker
Many (M)Crow's foot at the line endCrow's foot at the line end
One (1)Short bar at the line end, no crow's footNo crow's foot
MandatoryShort barSolid line
OptionalCircle ODashed line
Entity shapeRectangle (top compartment identifier, bottom compartment regular attributes)Rectangle with rounded corners
Attribute markingSeparated 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 orders
  • In IE, the optionality symbol (circle or bar) is attached to the opposite end. The O at the Order end means "a customer may have no orders."
  • In Barker, optionality is shown by the line shape of your own side's half. If the Customer-side half is dashed, the customer is an optional participant.

⚠️ The positions of the optionality symbols look reversed between the two notations. IE's O is 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.

  • Identifying and non-identifying relationships (solid and dashed lines in IE) are covered in Week 2 Day 1 on identifiers.

Next week we move on to identifiers and normalization to see how to refine a model.

📖 Glossary

  • Relationship : A logical association formed between instances of entities.
  • Pairing : A single connection of a pair of instances participating in a relationship.
  • Cardinality : With how many instances of the other entity one instance is connected. 1:1, 1:M, M:N.
  • Optionality : Whether an instance must participate in the relationship (mandatory) or may not participate (optional).
  • Intersection entity : An entity placed in between to resolve an M:N relationship into two 1:M relationships. Something like Order Item.
  • Association / dependency : The names UML uses for the relationship by existence and the relationship by action.
  • IE notation : A notation that draws relationships with crow's feet, circles, and bars.
  • Barker notation : A notation that draws relationships with crow's feet and solid/dashed lines, and prefixes attributes with #, *, and o.

📝 Practice Questions

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?

PreviousAttributesWeek 1 · Day 4Next IdentifiersWeek 2 · Day 1

Official references

  • SQLD official exam syllabus(opens in a new tab)

On this page

  • Key Takeaways
  • A Sentence Packed into a Single Line
  • Definition
  • Relationships by Existence and Relationships by Action
  • Difference Between ERD and UML
  • The Three Elements of Relationship Notation
  • Relationship Name
  • Cardinality
  • Optionality
  • How to Read a Relationship
  • What to Check When Defining a Relationship
  • IE Notation and Barker Notation
  • Glossary
  • Practice Questions