# Entity Relationship Diagram (ERD)
## Sales Record Management System (SRMS)
**Student:** SANGANO INEZA DAVINA  
**Exam:** National Practical Exam 2025-2026 — ICT & Multimedia, Software Development

---

## Entities and Attributes

| Entity   | Attributes |
|----------|------------|
| Customer | customerNumber (PK), firstName, lastName, telephone, address |
| Product  | productCode (PK), productName, quantitySold, unitPrice |
| Sale     | invoiceNumber (PK), salesDate, paymentMethod, totalAmountPaid, customerNumber (FK), productCode (FK) |

---

## Relationships and Cardinalities

```
┌─────────────────┐         places          ┌─────────────────┐
│    CUSTOMER     │◄────────────────────────│      SALE       │
│─────────────────│      1        N         │─────────────────│
│ customerNumber* │                         │ invoiceNumber*  │
│ firstName       │                         │ salesDate       │
│ lastName        │                         │ paymentMethod   │
│ telephone       │                         │ totalAmountPaid │
│ address         │                         │ customerNumber  │
└─────────────────┘                         │ productCode     │
                                            └────────┬────────┘
                                                     │
                                            includes │ N
                                                     │ 1
                                            ┌────────▼────────┐
                                            │    PRODUCT      │
                                            │─────────────────│
                                            │ productCode*    │
                                            │ productName     │
                                            │ quantitySold    │
                                            │ unitPrice       │
                                            └─────────────────┘
```

### Relationship Details

1. **Customer — Sale** (One-to-Many)
   - One customer can place many sales.
   - Each sale belongs to exactly one customer.
   - FK: `sale.customerNumber` → `customer.customerNumber`

2. **Product — Sale** (One-to-Many)
   - One product can appear in many sales.
   - Each sale includes exactly one product.
   - FK: `sale.productCode` → `product.productCode`

---

## Mermaid ERD (for draw.io / Lucidchart reference)

```mermaid
erDiagram
    CUSTOMER ||--o{ SALE : places
    PRODUCT ||--o{ SALE : includes

    CUSTOMER {
        varchar customerNumber PK
        varchar firstName
        varchar lastName
        varchar telephone
        varchar address
    }

    PRODUCT {
        varchar productCode PK
        varchar productName
        int quantitySold
        decimal unitPrice
    }

    SALE {
        varchar invoiceNumber PK
        date salesDate
        varchar paymentMethod
        decimal totalAmountPaid
        varchar customerNumber FK
        varchar productCode FK
    }
```

---

## Primary Keys (PK) and Foreign Keys (FK)

| Table    | Primary Key     | Foreign Keys |
|----------|-----------------|--------------|
| customer | customerNumber  | —            |
| product  | productCode     | —            |
| sale     | invoiceNumber   | customerNumber, productCode |
