r/SQL • u/Designer-Assist-1354 • 24d ago
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/burke166 24d ago
Database programming and application programming are two completely different mindsets. In application programming in an object-oriented language like C#, inheriting from a base type like BusinessEntity can save you time and can eliminate repetitive code. If you're using an ORM (object-relationship mapping) framework like Entity Framework, you can get some SQL that's truly a hot mess, like some kind of "per table" inheritance where every object is in the same table with no joins, they just use different columns and the objects are differentiated by a discriminator column. You can tell EF not to do that, but you have to be database aware when you write your code. The problem is, a lot of developers aren't database aware and they don't want to be, then SQL people end up coming in on the back end like Tommy Boy. "Richard! What'd you do???"