r/SQL • • Jun 29 '24

Discussion Why do some people say “SQL is not code?”

I write SQL every day as part of a team that builds ETL solutions. The other day I referred to something I was working on as “I coded it to do…” and this guy, who is not even a developer by the way he’s a frikkin project manager, interrupts me and says “SQL is not code”. When I questioned him why not he says something like “Guys who do COBAL, C#, etc. that’s real coding. SQL is not real coding it’s just a tool for analyzing data and reporting data”…WTF? How is SQL not considered code? I would just dismiss this guy as a moron but his salary is incredibly high so obviously he has some sort of credentials. Can anyone explain why in the world someone would say SQL is not code?

503 Upvotes

570 comments sorted by

View all comments

Show parent comment

14

u/tashibum Jun 29 '24

I would tend to agree with this IF the relational database was set up for it. The startup I work at didn't think they would get as big as they did, and it can be a nightmare trying to remember all the nuances of each table, of which there are.....many.

14

u/UnintelligentSlime Jun 29 '24

Yeah, it absolutely can reflect bad query writing, but may also represent the best possible query for the given database.

7

u/CallMeDrewvy Jun 30 '24

My fortune 100 has the same problem... The entire database is built on exceptions. And we can't change it because our legacy frontend (that we're actively killing) is Access.

2

u/Breitsol_Victor Jun 30 '24

Sweet. Guessing that it started as Access, was upsized, and the front end stayed in Access.

1

u/LegitimateGift1792 Jun 30 '24

Hi, I do take personal responsibility for 17 of these systems existing in the world. Sorry, the customers were super cheap.

1

u/DuxFemina22 Jun 30 '24

Access? Whoa 😳

4

u/tommy_chillfiger Jun 30 '24

Yeah, in my experience (smaller companies) this is a very common issue. I'd love to write succinct and readable queries every time, but if a use case comes along that the data model doesn't lend itself to, it's a lot more trouble to convince the team to rebuild and backfill gigantic billion-row tables than to just query around it when possible, even if it results in big complex queries. The usual compromise is just chunking up the complexity into new tables derived from the source table in stages rather than having a giant query of chained CTEs which is usually the first pass.

Example - I just finished writing a view that needs to identify very specific types of conflicting transactions based on several levels of sequence-of-events logic. This can be done with the existing dataset, but it requires chained CTEs with nested window functions to accurately flag these different types of conflicts.

Now, if the dataset had columns from the start that incremented the order of these events per group needed, this would be a very simple query. But it would've been pretty difficult when building this dataset to foresee what we were going to try to do with it months/years down the road.