iwantcoding.com
🔥 Daily 👥 Rooms 🏆 Top Log in Sign up

Entity-Relationship Diagram

The Entity-Relationship Diagram (ERD) shows your database tables, their attributes, and how they relate. Required as a figure in Chapter III.

Entity-Relationship Diagram

What this section does

A figure showing the database tables (entities), their attributes, and the relationships between them. Required as a key figure in Chapter III.

Sample ERD (Sample Bakery Shop)

CUSTOMER id (PK) name phone email created_at ORDER id (PK) customer_id (FK) status total placed_at ready_at ORDER_ITEM id (PK) order_id (FK) product_id (FK) qty unit_price PRODUCT id (PK) name category price stock USER id (PK) role username password_hash created_at INVENTORY_LOG id (PK) product_id (FK) change_qty user_id (FK) at 1 N 1 N N 1 1 N N..1 Figure 3.4 - Entity-Relationship Diagram. PK = primary key. FK = foreign key. Cardinality: 1 = one, N = many. Read as 'one CUSTOMER has N ORDERs.'

Drawing rules

RuleWhy
Use crow's-foot notationStandard, panel-recognised
Mark PK and FKQuick read of which fields link tables
Show cardinalityAvoids debate at defense
Resolve N..N with join tableORDER_ITEM is the example
Match the live databaseInconsistency = panel question

Tools

ToolNotes
draw.ioFree, ERD shape set built in
DBDiagram.ioGenerates from a text spec
MySQL WorkbenchReverse-engineers from live DB
LucidchartCollaborative, paid

Caption + prose

Figure 3.4 shows the entity-relationship diagram of the proposed database. The CUSTOMER entity has a one-to-many relationship with ORDER. Each order has multiple ORDER_ITEMs, each of which references a PRODUCT. The USER and INVENTORY_LOG entities track who changed inventory, when, and why - supporting the audit feature described in Chapter IV.

Panel defense checklist

  • [ ] All entities the system reads or writes are present.
  • [ ] Primary and foreign keys are marked.
  • [ ] Cardinality is shown for every relationship.
  • [ ] No N..N relationships without a join table.
  • [ ] Every entity has at least one attribute besides id.
  • [ ] Diagram references the database in your live system.
  • [ ] Caption: 'Figure 3.4. Entity-Relationship Diagram.'
Mentor’s tip: Crow-foot notation. Mark PKs and FKs. Resolve N..N with join tables. The diagram must match the actual database the panel will see in Chapter IV. Caption Figure 3.4.

Discussion

Loading…