PlantUML Chen ERD Syntax Guide

What is a Chen ERD Diagram?

A Chen ERD (Entity-Relationship Diagram), introduced by Peter Chen, is a classic visual notation used to model conceptual data structures. Unlike Crow’s Foot ERD, which focuses on table schemas and foreign keys, Chen ERD highlights business entities, their attributes, and explicit relationship diamonds connecting entities. With VPasCode, you can write clean, text-based Chen ERD scripts using @startchen block tags to generate publication-ready ER diagrams without manually drawing shapes or aligning attribute connectors on a canvas.

Core Syntax Guide: Elements and Constructs

Building a Chen ERD in VPasCode uses dedicated entity and relationship blocks written inside standard @startchen and @endchen delimiters.

1. Declaring Entities and Attributes

Define conceptual entities using the entity keyword. Attributes associated with an entity are declared directly inside curly braces { ... }:
entity CUSTOMER {
    Name
    Email
    Phone
}

entity ORDER {
    OrderDate
    TotalAmount
}

2. Defining Relationships and Relationship Attributes

In Chen ERD, relationships between entities are defined using the relationship keyword. If a relationship carries descriptive properties (like quantity or transaction date), declare those attributes directly inside the relationship block:
@startuml
class PLACES {
}

class CONTAINS {
  Quantity
}
@enduml

3. Modeling Cardinality and Entity Links

Connect entities to relationships and specify cardinality (e.g., 1, N, M) using hyphenated link syntax:
@startuml

CUSTOMER "1" -- "N" PLACES
PLACES "N" -- "1" ORDER

ORDER "1" -- "N" CONTAINS
CONTAINS "N" -- "1" PRODUCT

@enduml


Best Practices for Clean Layouts

  • Use Upper Case Identifiers: Keep entity and relationship names in upper case (e.g., CUSTOMER, ORDER, PLACES) for clarity and readability.
  • Include Relationship Attributes: Place attributes that depend on the relationship itself (such as Quantity or EnrollmentDate) inside the relationship { ... } block.
  • Explicit Cardinality Mapping: Always map explicit 1 and N or M markers on both sides of the relationship link.

Real-World PlantUML Chen ERD Examples

Copy and paste these blueprints directly into your VPasCode editor panel to see them render in real time.

Example 1: Hospital & Patient Management System

This blueprint models a conceptual data architecture for a healthcare facility including Patient, Doctor, Medical Record, and Prescription entities along with their relationships.
@startchen

entity PATIENT {
    PatientID
    FullName
    DateOfBirth
    ContactNumber
}

entity DOCTOR {
    DoctorID
    DoctorName
    Specialization
}

entity MEDICAL_RECORD {
    RecordID
    DiagnosisDate
    Notes
}

entity PRESCRIPTION {
    PrescriptionID
    IssueDate
}

relationship TREATS {
}

relationship HAS_RECORD {
}

relationship ISSUES {
    Dosage
    Duration
}

PATIENT -1- TREATS
TREATS -N- DOCTOR

PATIENT -1- HAS_RECORD
HAS_RECORD -1- MEDICAL_RECORD

DOCTOR -1- ISSUES
ISSUES -N- PRESCRIPTION

@endchen

Syntax Breakdown: Demonstrates conceptual healthcare entities with attributes declared inside curly braces, connected across 1:N (“TREATS”, “ISSUES”) and 1:1 (“HAS_RECORD”) relationship diamonds, complete with relationship-specific attributes (Dosage, Duration).

Example 2: University Course Registration System

This blueprint models a university domain with Department, Course, and Student entities.
@startchen

entity DEPARTMENT {
    DeptCode
    DeptName
}

entity COURSE {
    CourseID
    Title
    Credits
}

entity STUDENT {
    StudentID
    FullName
}

relationship OFFERS {
}

relationship ENROLLS_IN {
    Grade
    Semester
}

DEPARTMENT -1- OFFERS
OFFERS -N- COURSE

STUDENT -M- ENROLLS_IN
ENROLLS_IN -N- COURSE

@endchen

Syntax Breakdown: Shows organizational modeling using 1:N (“OFFERS”) and M:N (“ENROLLS_IN”) relationships, complete with relationship-specific attributes (Grade, Semester).
Scroll to Top