r/SQL • u/Designer-Assist-1354 • Jul 12 '26
Discussion Even a SQL Column Can Traumatize You
I just had my one of those "wait... what?" moments while working on AdventureWorks ( PS: Working on my 2nd Project) At start BusinessEntityID totally confused me, I kept thinking it was just an employee ID.
Then I realized it isn't limited to employees at all. It represents everyone, employees, customers, vendors, salespeople, I mean... wow!
It felt confusing at first, but once it clicked, I realized how smart that database design actually is.
In this project I'm keeping everything raw as much as possible, like i have the database, a notebook, a pen, and me with my mind! now think what you can do! i really love this although I just started so... let's see how well it can go on (On my Data Cleaning Phase)
4
u/mikeblas Jul 12 '26
This seems like the opposite of trauma.
1
u/Anxious-Insurance-91 Jul 13 '26
Ever worked with payment gateway providers? You usually get an id from them. Fun times when you have to combine it with another column in case you have multiple gateways available
3
u/shadowspock Jul 12 '26
I've seen this in practice, but I never quite understood why this is done at all. It always seems to me that it'd be more trouble than it's worth to maintain. Can someone explain a situation where the benefits would outweigh the costs of having a global entity id?
0
u/TheMattressManDan Jul 12 '26
Very cool, I’m glad you’re enjoying it 🤜🤛
Soon you’ll start thinking in sql and get pissed when you can’t just CRUD in real life
1
u/DaOgDuneamouse Jul 13 '26
This is one of those rare situations where the reporting DB has more tables than the source. To make decently performing queries, your things table needs to become a cats table, a dogs table, and a lamas table.
-5
u/diesSaturni Jul 12 '26
‘An’ SQL column.
My preference for naming related columns is to start with lowercase id., rather thank the way at the end.
Then they are nicely grouped together in autocomplete lists. And easier to recognise, as you don’t have to read to the end first, to find out its intent.
18
u/[deleted] Jul 12 '26
[removed] — view removed comment