# EPMS Entity Relationship Diagram

## Entities & Attributes

| Entity | Attributes | Primary Key |
|--------|------------|-------------|
| **Department** | departmentCode, departmentName | departmentCode |
| **Employee** | employeeNumber, firstName, lastName, address, position, telephone, gender, hiredDate | employeeNumber |
| **Salary** | grossSalary, totalDeduction, netSalary, monthOfPayment | salaryId (surrogate) |
| **User** | username, password | userId |

## Relationships & Cardinalities

```
Department (1) ────────< (M) Employee
Employee   (1) ────────< (M) Salary
```

| Relationship | Cardinality | FK Location |
|--------------|-------------|-------------|
| Department employs Employee | 1:N | Employee.departmentCode → Department.departmentCode |
| Employee receives Salary | 1:N | Salary.employeeNumber → Employee.employeeNumber |

## Crow's Foot Notation (for draw.io / Lucidchart)

1. **Department** — one side (|), **Employee** — many side (crow's foot)
2. **Employee** — one side (|), **Salary** — many side (crow's foot)

## Mermaid Diagram (import into draw.io or view in GitHub)

```mermaid
erDiagram
    DEPARTMENT ||--o{ EMPLOYEE : employs
    EMPLOYEE ||--o{ SALARY : receives

    DEPARTMENT {
        varchar departmentCode PK
        varchar departmentName
    }

    EMPLOYEE {
        varchar employeeNumber PK
        varchar firstName
        varchar lastName
        varchar address
        varchar position
        varchar telephone
        enum gender
        date hiredDate
        varchar departmentCode FK
    }

    SALARY {
        int salaryId PK
        decimal grossSalary
        decimal totalDeduction
        decimal netSalary
        varchar monthOfPayment
        varchar employeeNumber FK
        datetime createdAt
    }

    USER {
        int userId PK
        varchar username UK
        varchar passwordHash
    }
```

## Notes for Paper ERD

- Draw **Department** at top, **Employee** in middle, **Salary** at bottom.
- Use solid lines for identifying relationships; label "employs" and "receives".
- Mark PK with underline; FK with (FK) annotation.
- Optional: minimum cardinality 0 on Employee→Department if employees can exist without department (schema allows NULL FK).
