Live data from Hacker News

Learn SQL Once, Use It for 30 Years

fagnerbrack.com

61–70 of 243 posts

Re: Learn SQL Once, Use It for 30 Years

#63
I’d say the most impactful thing is not to learn SQL, but set theory.

Well-written SQL is about thinking in sets. I cannot tell you how many poorly written procedural stored procedures I’ve replaced with a single performant SQL query over the years.

This is because the most impressive part of the SQL ecosystem is the DBMS engine’s query plan. Though, yes, you have to know how to influence it.

I find ORMs also tend to keep devs thinking procedurally.

Yes learn SQL! But don’t just learn the syntax. Learn the underlying mathematical models and ways of thinking that SQL supports implementing.

Re: Learn SQL Once, Use It for 30 Years

#64
post #41
post #38

I’ve always felt that SQL is somewhat easy to grasp for basic queries, but gets complex and difficult for even moderate to higher complexity use cases. My eyes glaze over when I read long stored procedures that someone else has written. Any recommended resources to go from beginner/beginner-intermediate to advanced?

PRQL, or https://www.malloydata.dev/

Yaml?

Re: Learn SQL Once, Use It for 30 Years

#65
post #21
post #15

I've been slowly transitioning from using an ORM to just plain SQL. It's so much simpler. Less magic, more explicitness, and more control. Also, much better performance. I think the thing is to construct your model around the different queries you need to perform. In many cases, especially a CRUD-type situation, you'll end up with 10-20 different SQL queries, and that's it.

Once you break free of ORM’s I find the code so much simpler to maintain. Here’s the query(typically multiple different subqueries and return types), here’s the params, give me all the data back and something like Dapper in .net is an absolute godsend to convert it.

The code is simple to maintain until the database changes. Then you will experience the pain of SQL

Re: Learn SQL Once, Use It for 30 Years

#66

I think the pretext of this articles is ridiculous. Yes, SQL is based around relational algebra, but all programming languages are built on a theoretical foundation. And SQL is very much a "fad" language - it just somehow managed to stick around. The goal was not some sort of mathematical purity, but rather to built a natural language data interface (sounds like something currently very hyped?) and it failed spectacu…

>Yes, SQL is based around relational algebra, but all programming languages are built on a theoretical foundation.

While true on some level, I don't think this is a very useful statement. The importance of mathematical foundations lies in the extent to which they constrain the features of a programming language.

That extent is not the same for all languages. Many programming languages do not appear to be constrained by anything other than some pragmatic hunch of their designers plus the theoretical limits of computability.

SQL is a mess. The author acknowledged that. But the relational model and relational algebra are more serious attempts at creating a small but expressive theory than many of our mainstream programming languages.

Re: Learn SQL Once, Use It for 30 Years

#67

>The Only Programming Language Built on Mathematics, Not Fashion As a modern array language D4M is the natural successor for SQL [1]. D4M is based on mathematics like SQL, specifically associative array algebra but not relational unlike SQL. It's more generic since can it caters to most modern data abstractions including spreadsheets, database tables, matrices, and graphs [2]. You can achieve 100M database inserts pe…

First impressions assuming the goal is to replace the incumbent SQL. Haven't seen the language yet.

  * D4M rolls off the tongue
  * Make me buy a book to see the language.

Re: Learn SQL Once, Use It for 30 Years

#68
Having been working with computers professionally for almost 40 years now I've seen quite a lot of things come and go. I'm not convinced that LLMs will stick around for that long although they're currently doing better than "fuzzy logic", which is what it used to be called when they could run on 68HC11s ;-)

You know what has stuck around though?

Thumping great Unix boxes running SQL databases.

Yes, there's a lot wrong with the whole concept, but everything else is in some important way worse.

Re: Learn SQL Once, Use It for 30 Years

#69
post #19

Additionally learn stored procedures. Helps simplify complex SQL queries and no need to waste network traffic on data that client side is never going to use, and waste CPU cycles processing it. Yes, what about database portability? I am on my 50s and it only mattered on a single project, which was anyway a middleware for application servers.

I moved from stored procedures to dbt. I find it easier to maintain and it helps me with version control, testing, and docs. Plus, since I deal with data pipelines a lot it get other goodies like lineage and auto DDL.

Re: Learn SQL Once, Use It for 30 Years

#70
post #30

> If you are a junior developer, “learn SQL properly” is the most valuable 40 hours you can spend. Not a tutorial. Not an ORM. Actual SQL: joins, subqueries, window functions, query plans. That investment pays you back at every job, in every stack, for decades This is the power of low-level reasoning. Today, even for a junior developers, even if they have AI that solves syntax problems, SQL teaches you to reason and…

The whys will vary, but letters of alphabets do change indeed.
Post reply on HN