name: erd-generator
version: 1.0.0
description: Generate ERD dan database schema (SWEBOK Design, 3NF).
๐ฏ Goal
Buat Entity Relationship Diagram dan normalized schema.
๐ ๏ธ Instructions
- Identifikasi entities dari requirements
- Tentukan relationships (1:1, 1:N, M:N)
- Normalisasi ke 3NF minimum
- Generate Mermaid ERD diagram
- Buat migration scripts
๐ ERD Mermaid Template
erDiagram
USER ||--o{ ORDER : places
ORDER ||--|{ ORDER_ITEM : contains
PRODUCT ||--o{ ORDER_ITEM : "ordered in"
USER {
uuid id PK
string email UK
string password_hash
string name
timestamp created_at
}
ORDER {
uuid id PK
uuid user_id FK
decimal total_amount
string status
timestamp created_at
}
PRODUCT {
uuid id PK
string name
text description
decimal price
int stock
}
ORDER_ITEM {
uuid id PK
uuid order_id FK
uuid product_id FK
int quantity
decimal unit_price
}
๐ Relationship Types
| Type |
Notation |
Example |
| One-to-One |
||--|| |
User - Profile |
| One-to-Many |
||--o{ |
User - Orders |
| Many-to-Many |
}o--o{ |
Product - Category (via junction) |
๐ Normalization Checklist
| Form |
Rule |
Check |
| 1NF |
No repeating groups, atomic values |
โ |
| 2NF |
All non-key attributes depend on full key |
โ |
| 3NF |
No transitive dependencies |
โ |
๐ซ Constraints
- WAJIB normalisasi ke 3NF
- WAJIB index semua foreign keys
- NEVER use VARCHAR(255) untuk semua fields โ pilih tipe data yang tepat
- WAJIB use UUID atau prefixed ID untuk primary keys