# Supply Chain Management System (SCMS) - Entity Relationship Diagram

## Entities and Attributes

| Entity | Attributes | Primary Key |
|--------|------------|-------------|
| **Supplier** | supplierCode, supplierName, telephone, address, email | supplierCode |
| **Shipment** | shipmentNumber, shipmentDate, shipmentStatus, destination, supplierCode (FK) | shipmentNumber |
| **Delivery** | deliveryCode, deliveryDate, quantityDelivered, deliveryStatus, shipmentNumber (FK) | deliveryCode |
| **User** | id, username, password | id |

## Relationships and Cardinalities

```
┌─────────────────┐         supplies (1:N)         ┌─────────────────┐
│    SUPPLIER     │───────────────────────────────>│    SHIPMENT     │
│  supplierCode PK│                                │ shipmentNumber PK│
└─────────────────┘                                │ supplierCode FK  │
                                                   └────────┬────────┘
                                                            │
                                                   contains (1:N)
                                                            │
                                                            ▼
                                                   ┌─────────────────┐
                                                   │    DELIVERY     │
                                                   │ deliveryCode PK │
                                                   │ shipmentNumber FK│
                                                   └─────────────────┘
```

### Cardinality Notation (Crow's Foot)

| Relationship | From | To | Cardinality | Description |
|--------------|------|-----|-------------|-------------|
| SUPPLIES | Supplier | Shipment | **1 : N** | One supplier can have many shipments; each shipment belongs to at most one supplier |
| CONTAINS | Shipment | Delivery | **1 : N** | One shipment can have many deliveries; each delivery belongs to one shipment |

## Foreign Keys

- `shipment.supplierCode` → `supplier.supplierCode`
- `delivery.shipmentNumber` → `shipment.shipmentNumber`

## Draw on Paper (Exam Requirement)

1. Draw rectangles for Supplier, Shipment, Delivery, User
2. Use crow's foot notation: Supplier (1) —— (N) Shipment —— (N) Delivery
3. Mark PK with underline, FK with (FK) label
4. Recreate in draw.io / Lucidchart / Edraw Max using this diagram as reference

## Mermaid ERD (for digital submission)

```mermaid
erDiagram
    SUPPLIER ||--o{ SHIPMENT : supplies
    SHIPMENT ||--o{ DELIVERY : contains
    SUPPLIER {
        varchar supplierCode PK
        varchar supplierName
        varchar telephone
        varchar address
        varchar email
    }
    SHIPMENT {
        varchar shipmentNumber PK
        date shipmentDate
        varchar shipmentStatus
        varchar destination
        varchar supplierCode FK
    }
    DELIVERY {
        varchar deliveryCode PK
        date deliveryDate
        int quantityDelivered
        varchar deliveryStatus
        varchar shipmentNumber FK
    }
    USER {
        int id PK
        varchar username
        varchar password
    }
```
