Library ER Diagram (Chen Notation)

This sample models a small lending library in Chen notation: authors write books, the library owns physical copies of each book, and members borrow copies. Chen diagrams show entities as rectangles, relationships as diamonds and attributes as ovals.

It also shows a weak entity (COPY), which cannot be identified without its owning BOOK.


1. The Diagram

Library: Chen ER Diagram M N 1 N N M AUTHOR WRITES BOOK HAS COPY BORROWS MEMBER author_id name isbn title pub_year num_copies copy_no condition borrow_date due_date member_id name phone Rectangle = entity, double rectangle = weak entity, diamond = relationship, double diamond = identifying relationship, oval = attribute, double line = total participation.

Read the diagram from left to right, then down from BOOK.

  1. AUTHOR and BOOK are strong entities (single rectangles), each with an underlined key attribute: author_id and isbn.
  2. The WRITES diamond joins them with M and N on the lines: an author writes many books and a book can have many co-authors.
  3. COPY is a weak entity (double rectangle). Copy number 3 means nothing on its own; it is copy 3 of a given book. Its partial key copy_no has a dashed underline.
  4. HAS is the identifying relationship (double diamond) that lends COPY the book's key. The double line from HAS to COPY is total participation: every copy must belong to a book.
  5. BORROWS links MEMBER and COPY many-to-many over time. borrow_date and due_date hang off the diamond because they describe the loan, not the member or the copy.
  6. phone is multivalued (double oval: a member may list several numbers) and num_copies is derived (dashed oval: computed, not stored).

2. How to Read It

Chen Notation Symbols Entity strong entity Weak weak entity Rel relationship IdRel identifying relationship partial participation total (double line) id key attribute copy_no partial key (weak) phone multivalued age derived 1, N, M on lines = cardinality ratio

Chen notation, introduced by Peter Chen in 1976, draws relationships and attributes as shapes of their own. Cardinality ratios (1, N, M) are written on the lines, and a double line means every instance of that entity must take part. Some texts use (min,max) pairs on the lines instead of 1/N.

3. Variant: Mapping to Tables

Mapping the Weak Entity to Tables book PK isbn CHAR(13) title VARCHAR pub_year SMALLINT copy PK,FK isbn CHAR(13) PK copy_no SMALLINT condition VARCHAR loan PK,FK isbn CHAR(13) PK,FK copy_no SMALLINT PK,FK member_id BIGINT PK borrow_date DATE due_date DATE Weak entity: its key = owner key (isbn) + partial key (copy_no). M:N relationship BORROWS becomes table loan; its attributes become columns. num_copies is derived (COUNT of copy rows), so it gets no column.

Turning the Chen model into tables follows mechanical rules. The weak entity copy takes the owner's key plus its partial key as a composite primary key. The many-to-many relationship BORROWS becomes its own table, loan, whose key includes borrow_date so the same member can borrow the same copy again later. The multivalued phone would become a separate member_phone table.

4. Pros, Cons, and When to Use

Pros

Cons

When to use

When not to use

5. As Diagrams-as-Code

PlantUML has a Chen mode, @startchen:

@startchen
entity AUTHOR { author_id <<key>>
  name }
entity BOOK { isbn <<key>>
  title
  pub_year
  num_copies <<derived>> }
entity COPY <<weak>> { copy_no <<partial key>>
  condition }
entity MEMBER { member_id <<key>>
  name
  phone <<multi>> }
relationship WRITES {}
relationship HAS <<identifying>> {}
relationship BORROWS { borrow_date
  due_date }
AUTHOR -M- WRITES
WRITES -N- BOOK
BOOK -1- HAS
HAS =N= COPY
COPY -N- BORROWS
BORROWS -M- MEMBER
@endchen

The = connector draws total participation as a double line.