Database Design Roast: Claude Opus

2 min read

๐Ÿ”ฅ CLQMS Database Schema: A Professional Roast ๐Ÿ”ฅ

"I've seen spaghetti code before, but this is spaghetti architecture."

1. ๐Ÿ—‘๏ธ The ValueSet Anti-Pattern

What's Happening: Every single enum in the entire system is crammed into ONE giant table.

  • Zero Type Safety โ€” You can accidentally set Gender = 'Hospital'
  • The Join Apocalypse โ€” 7 joins to the same table for ONE patient query
  • No Easy Identification โ€” "Male" is VID 47 or 174?

2. ๐Ÿช† Organization: The Matryoshka Nightmare

Account โ†’ Site โ†’ Department โ†’ Discipline, all self-referencing. You need a graph database to query what should be a simple org chart.

3. ๐Ÿ“ Location + LocationAddress: The Pointless Split

LocationAddress uses LocationID as both Primary Key AND Foreign Key. You always have to save both tables in a transaction. If data is always created, updated, and deleted together โ€” IT BELONGS IN THE SAME TABLE.

4. ๐Ÿ‘จโ€โš•๏ธ Contact vs Doctor: The Identity Crisis

Contact has Specialty/SubSpecialty (doctor-specific) but also has OccupationID via ContactDetail. A Contact is Maybe-A-Doctorโ„ข. Zero validation that contacts are actually doctors.

5. ๐Ÿฅ Patient Data: The Table Explosion

  • patcom โ€” ONE comment per patient (why a whole table?)
  • patatt โ€” Stores Address as a single string (duplicate of patient table)
  • CSV in database โ€” LinkTo = '1,5,23,47' โ€” Use a junction table!

6. ๐Ÿคฎ Patient Admission (ADT): Event Sourcing Gone Wrong

Every Admission/Discharge/Transfer creates a new row. To get current status: MAX subquery with JOIN. Every single query.

7. ๐Ÿงช Test Definitions: The Abbreviation Cemetery

testdefsite, testdefgrp, testdefcal, testdeftech, testmap, refnum, reftxt, refvset, refthold โ€” 9 tables for test definitions!


๐Ÿ† The Final Scorecard

Category Score
Normalization 2/10
Consistency 1/10
Performance 3/10
Maintainability 1/10
Type Safety 0/10
Naming 2/10
Scalability 2/10

Overall: 1.5/10 โ€” "At least the tables exist"


Document prepared with ๐Ÿ”ฅ and โ˜•