News for hackers. Stuff that matters.
Re:Against SQL by pjmlp on Saturday July 10, 2021 @03:35AM (#27791811)
> Why did SQL have to add it to the language spec?

Most likely because there isn't cargo for SQL, everyone has to make do with a default install offers, and most big boys databases offer FFI to Java, .NET and C.

> This works for data modelling (although it's still clunky because you must try joins against each of the tables at every use site rather than just ask the value which table it refers to)

Only if one never learned what views are for, and the various flavours they come in.

> By far the most common case for joins is following foreign keys. SQL has no special syntax for this:

    select foo.id, quux."value" 
    from foo
    inner join bar on foo.bar_id = bar.id
    inner join quux on bar.quux_id = quux.id

Really, how much time was spent learning SQL before complaining?
Re:Against SQL by bokwoon on Saturday July 10, 2021 @03:48AM (#27791869)
Given that the author also wrote https://scattered-thoughts.net/writing/select-wat-from-sql/, I don't think he knows nothing about inner joins. I think he was just using that equivalent form to compare it with the terser `foo.bar.quux`. It is pretty strange to compare it with `fk_join(foo, 'bar_id', bar, 'quux_id', quux)` though, because SQL already has the equivalent `foo JOIN bar USING bar_id JOIN quux USING quux_id`.
Re:Against SQL by pjmlp on Saturday July 10, 2021 @03:51AM (#27791879)
Yeah, it reads like going down the path to write some SQL like parser without actually having used SQL in anger.
Re:Against SQL by mickael-kerjean on Saturday July 10, 2021 @07:08AM (#27792579)
After years of doing that same technique, in my new job, people would write:

   SELECT foo.id, quux.value
   FROM foo, quux, bar
   WHERE foo.bar_id = bar.id AND bar.quux_id = quux.id
I couldn't find anyone telling me the difference between those 2 ways to write a query, do someone know more about this?
Re:Against SQL by kthejoker2 on Saturday July 10, 2021 @11:08AM (#27793834)
There's no performance difference in the engine.

The way you have written it (ANSI-89)used to be the only way joins could be written.

The second one (ANSI-92) was introduced to allow for composability since the entities being joined and the join condition are next to each other in the code and multiple joins can be generated one after the other.

IMO it also enhances developmemt quality of life since you can understand a new-to-you query faster (especially complex ones), you can just comment out a join in one line when testing replacement, cut and paste between queries easier, etc.

An SO question on the topic

https://stackoverflow.com/questions/334201/why-isnt-sql-ansi...