Back to Projects

Immigration Management DB

Normalized relational schema for case-centric immigration operations.

SQLMySQLPostgreSQL3NFACID

Entity Relationship Diagram

persons
person_id
first_name
last_name
date_of_birth
passport_number
nationality
cases
case_id
case_number
case_type_id
status
filing_date
priority
case_persons
case_person_id
case_id
person_id
role
is_primary
relationship
documents
document_id
case_id
document_type_id
issue_date
expiration_date
status
Primary Key Foreign Key

Many-to-Many with Role Differentiation

PersonCan be in multiple cases
case_personsrole, is_primary
CaseHas multiple persons
APPLICANTDEPENDENTSPONSORATTORNEY

Common Query Patterns

Find Expiring Documents
SELECT case_number, expiration_date
FROM documents d
JOIN cases c ON d.case_id = c.case_id
WHERE expiration_date
  BETWEEN NOW() AND NOW() + 30 DAY;

Index on expiration_date enables efficient range scan

Case Details with Persons
SELECT c.case_number, p.first_name,
       cp.role, cp.is_primary
FROM cases c
JOIN case_persons cp ON c.case_id = cp.case_id
JOIN persons p ON cp.person_id = p.person_id;

Junction table enables flexible role assignment

Design Decisions

3NF with Strategic Denormalization
Keep person data normalized. Denormalize active_case_count to avoid expensive aggregates on every dashboard load.
Separate Audit History Table
case_status_history enables SQL queries on historical data, unlike JSON blobs. Essential for compliance.
ENUMs for Stable Domains
Use ENUMs for status/role (fast, schema-enforced). Use FK for case_type (extensible).
UTF-8 for International Names
utf8mb4 encoding from day one. Immigration data includes names from diverse languages.

Indexing Strategy

(case_id, person_id, role)Relationship queries
(expiration_date, status)Deadline monitoring
(last_name, first_name)Person search
(status, filing_date)Case filtering
4
Core Tables
3NF
Normalization
ACID
Compliant
UTF-8
Encoding
"For regulated domains, invest in audit infrastructure early. Retrofitting is painful."
Predictable performance & cleaner data model for immigration ops