RelationalDBDesign RelationalDBDesign


Diagram Conventions   «Prev  Next»

Lesson 6Diagramming types of participation
ObjectiveIdentify symbols for participation (mandatory vs optional) and read them correctly in Crow’s Foot and Chen notations.

Diagramming Types of Participation

Participation specifies the minimum number of related rows an entity must have in a relationship. It pairs with cardinality (maximum). The semantics are the same across notations; only the symbols differ.

Two common notations

Reading the diagrams

Always read the symbols at the end of the line nearest each entity.

Examples with participation

1) 1:1 relationship with participation symbols
1:1 with participation - Both ends show || (mandatory one), meaning each EMPLOYEE is paired with exactly one OFFICE and vice versa. In Chen, this appears as a double line from each entity to the relationship diamond.

2) 1:N relationship with participation symbols
1:N with participation - Next to PRODUCT you see || (mandatory one to a supplier). Next to SUPPLIER you see O< (zero or many products). Read: every product must have exactly one supplier; a supplier can have zero, one, or many products.

3) M:N relationship with participation symbols
M:N with participation - Each side shows a crow’s foot; participation adornments indicate optionality on each side. In a relational database, M:N is implemented via an associative entity (junction table) to form two 1:N relationships.

Database Modeling

Implementation patterns

1) One-to-one

Shared primary key (tight coupling):


CREATE TABLE employee (
  emp_id NUMBER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
  last_name  VARCHAR2(60) NOT NULL,
  first_name VARCHAR2(60) NOT NULL
);

CREATE TABLE office (
  emp_id   NUMBER PRIMARY KEY,             -- shared PK enforces 1:1
  room_no  VARCHAR2(20) NOT NULL,
  CONSTRAINT fk_office_emp
    FOREIGN KEY (emp_id) REFERENCES employee(emp_id)
);

Unique foreign key (looser coupling):


CREATE TABLE office_uq (
  office_id NUMBER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
  emp_id    NUMBER UNIQUE NOT NULL,        -- one office per employee
  room_no   VARCHAR2(20) NOT NULL,
  CONSTRAINT fk_office_uq_emp
    FOREIGN KEY (emp_id) REFERENCES employee(emp_id)
);

2) One-to-many


CREATE TABLE supplier (
  supplier_id   NUMBER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
  supplier_code VARCHAR2(20) UNIQUE NOT NULL,
  name          VARCHAR2(120) NOT NULL
);

CREATE TABLE product (
  product_id  NUMBER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
  supplier_id NUMBER NOT NULL,             -- mandatory one
  sku         VARCHAR2(40) UNIQUE NOT NULL,
  title       VARCHAR2(120) NOT NULL,
  CONSTRAINT fk_product_supplier
    FOREIGN KEY (supplier_id) REFERENCES supplier(supplier_id)
);

3) Many-to-many (resolved)


CREATE TABLE student (
  stud_id     NUMBER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
  student_no  VARCHAR2(20) UNIQUE NOT NULL,
  last_name   VARCHAR2(60) NOT NULL
);

CREATE TABLE class (
  class_id    NUMBER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
  class_code  VARCHAR2(20) UNIQUE NOT NULL,
  title       VARCHAR2(120) NOT NULL
);

CREATE TABLE enrollment (
  stud_id     NUMBER NOT NULL,
  class_id    NUMBER NOT NULL,
  enrolled_on DATE DEFAULT SYSDATE,
  grade       VARCHAR2(2),
  CONSTRAINT pk_enrollment PRIMARY KEY (stud_id, class_id),
  CONSTRAINT fk_enr_stud  FOREIGN KEY (stud_id)  REFERENCES student(stud_id),
  CONSTRAINT fk_enr_class FOREIGN KEY (class_id) REFERENCES class(class_id)
);

Participation vs. identifying relationships

Don’t conflate mandatory with identifying. Mandatory means the minimum is at least one; identifying means the parent’s PK participates in the child’s PK. You can have mandatory relationships that are non-identifying (child has its own PK) and optional relationships that are identifying (rare, but notation allows it).

Referential actions on delete

Standard SQL options (availability varies by RDBMS):


ALTER TABLE product
  ADD CONSTRAINT fk_product_supplier
  FOREIGN KEY (supplier_id)
  REFERENCES supplier(supplier_id)
  ON DELETE SET NULL;  -- example: product may temporarily have no supplier

Quick self-check

Given SUPPLIER O-< PRODUCT, answer:

  1. Is a product required to have a supplier? (Yes: minimum near PRODUCT is a bar, so mandatory.)
  2. Can a supplier have zero products? (Yes: the circle near SUPPLIER means optional.)

ER Diagram Participation - Exercise

Before moving on to the next lesson, click the Exercise link below to check your mastery of relationship constructs and participation symbols.
ER Diagram Participation - Exercise
The next lesson discusses the importance of meeting again with the database's eventual end users to determine if any revisions to the completed ER diagram are needed.

SEMrush Software 6 SEMrush Banner 6