5panda.11ty/src/projects/clqms01/review/004-db-roast-zai.md
mahdahar 6ed4dc1fa4 refactor: restructure CLQMS documentation under projects directory
This commit reorganizes the CLQMS documentation structure and removes redundant review content:

### Architecture Changes
- Added `projects` collection to Eleventy config combining blog posts and CLQMS-tagged content
- Renamed `??` nullish coalescing operator in collection sorting for consistency
- Simplified navigation in `base.njk` - replaced individual post links with single CLQMS overview link
- Removed deprecated `/blog/clqms01/` overview link from `clqms-post.njk` sidebar

### Content Reorganization
Moved CLQMS documentation from `src/blog/` to `src/projects/clqms01/`:
- `clqms-update-v1.md` → `001-architecture.md`
- `clqms-module-auth.md` → `002-auth-module.md`
- `clqms-frontend-stack.md` → `003-frontend-stack.md`
- Added new documentation: `004-wst-concept.md`, `005-wst-database.md`, `006-test-api-examples.md`
- Added review documents in `review/` subdirectory

### Content Cleanup
Deleted redundant/obsolete review documents:
- `clqms-review-Opus.md` (374 lines - database schema review)
- `clqms-review-Sonnet.md` (1305 lines - comprehensive schema assessment)
- `clqms-roast-Opus.md`
- `clqms-roast-zai.md`
- `clqms-wst-concept.md` (consolidated into projects directory)
- `clqms-wst-database.md` (consolidated into projects directory)
- `clqms01.md` (consolidated into projects directory)

### New Project Files
- `.claude/settings.json` - Claude Code environment configuration
- `CLAUDE.md` - Project documentation for AI assistants

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-08 16:44:37 +07:00

1.9 KiB

layout, tags, title, date, order
layout tags title date order
clqms-post.njk clqms Database Design Roast: Zai 2025-12-09 9

The Database Design from Hell: A Comprehensive Roast

Or: Why your current project makes you want to quit.

1. The "Value Set" Disaster (The God Table)

Storing every enumeration in one giant generic table.

  • No Identity: Can't change "M" to "Male" without breaking FKs
  • Performance Killer: Scans 10,000 rows for simple dropdowns
  • Zero Integrity: Can delete values used for Critical Status

2. The "Organization" Nightmare

Building a database for a Laboratory, not the United Nations. Mixing external business logic (Sales) with internal operational logic (Lab Science).

3. The "Location" & "LocationAddress" Split

Forcing a JOIN for every label. For mobile locations (Home Care), address is vital. For static locations (Bed 1), address is meaningless. Pointless normalization.

4. The "Doctor" vs "Contact" Loop

To get a Doctor's name, do you query Doctor or Contact? If Dr. Smith retires, do you delete the Doctor record? Then you lose his Contact info. This design doesn't separate Role from Entity.

5. Patient Data: The Actual Hell

  • Blood Bags are not Humans: Patient table has DOB (Required) and BloodType (Required). Blood Bag has NULL DOB. Created a "Sparse Table."
  • The "Link/Unlink" Suicide Pact: Database loses history of why patients were unlinked

6. Test Data: The Maze of Redundancy

testdef, testdefsite, testdeftech, testgrp, refnum, reftxt, fixpanel.

  • Glucose defined in 50 different places
  • Profile, Functional Procedure, Superset all stored as "Tests in a Group"
  • refnum vs reftxt split doubles JOINs for no reason

Summary

This document is a "Jack of All Trades, Master of None." CRM + ERP + Billing + Lab System in one poorly normalized schema. Data Hell.


Do not build this "as is." You will spend 5 years writing SQL Scripts to patch the holes.