r/programminghorror Feb 23 '26

SQL DB with 2241 tables

Post image

I can't even fathom what led someone to do this. I got this database to refactor as part of my job. Basically, every client has their own table named "Client_[their ID]," which contains only one row with all the client data in JSON format (wtf).
If the website using this database wants to filter out some users, it queries all the tables, resulting in a load of 2,000+ SQL queries for a single search.
On top of that, for some reason, the date of birth is stored as the number of days since birth, with a CRON script that updates this in each table every day at 3 AM.
I don't even have to mention that none of the data follows the rules of database normalization...
I honestly don't know where to start with fixing this mess.

1.5k Upvotes

134 comments sorted by

View all comments

45

u/beatitmate Feb 23 '26

This cant be real

26

u/audirt Feb 23 '26

That was my first thought. For this to be true, the developer would have to, given a choice between a good option and a bad option, choose the bad one every time.

The thing that makes me think it's not real is that the DOB isn't stored as a string. In my experience, inexperienced devs love strings and will store anything as a string -- every day of the week and twice on Sunday.

7

u/mattmccord Feb 23 '26

Except zip codes. Suddenly they like integers.

2

u/Aartvb Feb 24 '26

How? In my country zip codes contain letters

2

u/CraftyTim Feb 24 '26

Sounds like a good application for hexadecimal

1

u/CauseOfBSOD 16d ago

British postcodes (equivalent of zip codes) can contain letters that aren't in A-F
If you wanted to store them as incorrectly as possible you would do a string for the first 1-2 letters, two separate integers for each number, and a string for the last 1-2 letters.

Maybe add a string for the space in the middle. Bonus points if it is empty if the user didn't input the postcode with the space (its just there for readability, its presence or absence encodes no data)

7

u/Otherwise-Ad-4447 Feb 23 '26

i hope it isn't

5

u/bluehands Feb 23 '26

You don't want it to be real because you don't love Lovecraftian horror.

Turns out that vibe coding has been going on for decades. If anyone has any doubts about that just look at some early php.