| Lesson 6 | Diagramming types of participation |
| Objective | Identify symbols for participation (mandatory vs optional) and read them correctly in Crow’s Foot and Chen notations. |
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.
| = at least one (mandatory), O = zero allowed (optional).| = one, < = many.Start with one instance of an entity and read the symbols at the opposite end to count its related instances. The markers next to PRODUCT count products for one supplier; the markers next to SUPPLIER count suppliers for one product.
|| next to an entity means “exactly one” (mandatory one).O| means “zero or one”.O< means “zero or many”.|< means “one or many”.
EMPLOYEE require each office to have exactly one employee. The circle and bar beside OFFICE allow each employee to have zero or one office. In Chen notation, OFFICE has total participation in this relationship and EMPLOYEE has partial participation.
SUPPLIER you see || (exactly one supplier per product). Next to PRODUCT you see O< (zero or many products per supplier). Read: every product must have exactly one supplier; a supplier can have zero, one, or many products.
STUDENT CLASS. Each junction row references exactly one student and one class. A student or class may have zero or many junction rows, forming two one-to-many relationships.
The following examples use Oracle SQL syntax and are illustrative; they have not been executed against a live Oracle database in this revision.
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)
);
Both one-to-one patterns allow an employee to have no office while requiring every office row to reference exactly one employee. They implement the optional-office rule shown in the first diagram. A different rule requiring every employee to have an office would need additional enforcement.
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)
);
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)
);
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. A child with its own primary key can have a mandatory, non-identifying foreign key. If the parent key is part of the child primary key, that child cannot omit the parent because primary-key columns cannot be NULL. The parent may still have zero children; always state which direction is optional.
Referential actions differ by database. Oracle supports ON DELETE CASCADE and ON DELETE SET NULL; omitting ON DELETE prevents deletion of a referenced parent. The list below describes common SQL choices across products:
-- Alternative business rule: a product may temporarily have no supplier.
ALTER TABLE product DROP CONSTRAINT fk_product_supplier;
ALTER TABLE product MODIFY (supplier_id NULL);
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
This alternative deliberately changes product participation from mandatory to optional. Dropping the original constraint and allowing NULL are necessary before replacing the foreign key with ON DELETE SET NULL.
Given SUPPLIER ||-----O< PRODUCT, answer: