Database Standards & Schema Discipline
Database standards guarantee data integrity, predictable query performance, and strict compliance with health data privacy laws. By enforcing strict snake_case schema naming, version-controlled forward-and-rollback migrations, foreign key constraints, and field-level encryption for ePHI, our data tier remains stable, high-performing, and auditor-defensible.
Schema & Column Naming Conventions
All relational databases (PostgreSQL, MySQL) must follow strict snake_case naming conventions to ensure consistency across ORM models and ANSI SQL queries:
Table Names: Plural snake_case
user_accounts, clinical_trials, order_line_items. Avoid singular table names.
Primary Keys: Explicit UUID or ID
Use id UUID PRIMARY KEY or BIGSERIAL. Foreign keys must be named {referenced_table_singular}_id (e.g. patient_id).
Timestamps: Explicit UTC Suffix
Always include created_at TIMESTAMPTZ NOT NULL DEFAULT NOW() and updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW().
Migration Versioning & Zero-Downtime Rollbacks
Direct manual modifications to production databases are strictly prohibited. Every schema change must be codified in a version-controlled migration script containing both forward (up) and reverse (down) execution blocks:
Indexing Strategies & Query Optimization
- Foreign Keys: Every foreign key column must have an explicit B-tree index to prevent table-scan locks during JOIN operations.
- Composite Queries: Where queries filter by status and sort by date, create composite indexes:
CREATE INDEX idx_orders_status_date ON orders(status, created_at DESC). - Parameter Binding: Always use parameterized queries (e.g.
$1,?) or ORM query builders to completely eliminate SQL injection risks.
ePHI Protection & Field-Level Encryption
Under HIPAA Security Rule § 164.312(a)(2)(iv), sensitive patient identifiers (SSN, medical record number, diagnostic notes) must be encrypted before storage using authenticated column-level encryption (AES-256-GCM) with encryption keys managed externally via KMS/Vault.
Copy this prompt to evaluate database schemas for performance and compliance.
Community Discussion & Feedback
Attributed peer feedback and official Netspective architecture notes.