News for hackers. Stuff that matters.
Re:SQL Notebook by treebeard901 on Tuesday May 09, 2017 @04:30PM (#14303546)
Since SQL Server 2005, modern alternatives to the procedural components have been added to the product. Even with these features existing it does not make any sense to call SQL a procedural language. Choosing the right tool for the job is certainly important. I notice many people write off SQL almost immediately when it is mentioned here. Often they come from a different language and do not see the value in the relational model. It's unfortunate too because there is real value in being able to go between a relational mindset seamlessly to an object oriented or functional one.
Re:SQL Notebook by Pxtl on Tuesday May 09, 2017 @05:53PM (#14304121)
I use SQL Server daily and I love the relational model. The core SQL language I dislike because it's verbose, backwards, and restricts sane forms of reuse. The procedural components of MS SQL are just plain miserable.

I'm constantly frustrated that the two options in the database world appear to be "use SQL and all its anachronistic warts" or "give up on the relational model". NoSQL throws the baby out with the bath-water.

But this is a tangent. The original post came about calling T-SQL a "procedural language". Which is inaccurate... but the author was talking about adding extensions to Sqlite - SQlite is already a SQL dialect. So if you're bolting on T-SQL to Sqlite, what's the main thing it will bring to the table?

It's procedural components. So, in the context of comparing Sqlite to T-Sql, using the term "procedural language" might be a misnomer, but it makes sense here.

Re:SQL Notebook by electroly on Tuesday May 09, 2017 @06:11PM (#14304258)
Yeah, this is spot on. SQLite provides DDL and DML commands, but no support for composing programs from these commands. I leaned on T-SQL for the syntax and behavior of variables, basic control structures, procedures, error handling, and some common library functions, but that's all that it takes from T-SQL. I didn't intend to make a judgment about T-SQL, but rather to indicate which parts were implemented in SQL Notebook.
Re:SQL Notebook by ak39 on Tuesday May 09, 2017 @06:14PM (#14304284)
>The core SQL language I dislike because it's >verbose, backwards, and restricts sane forms of reuse.

I can appreciate the verbosity and "backwardness" argument you make, but can you cite some examples of its restrictions. (Serious question)

Re:SQL Notebook by Pxtl on Tuesday May 09, 2017 @06:56PM (#14304564)
No algebraic types. No good way to query a graph of objects down, only a flat resultset. Infuriating performance problems if you layer views too deep or use scalar functions, which are sane encapsulation. No higher-level concepts of code reuse like templates. If I have a common pattern like "subclass table A by creating table B with a foreign primary key to A and create view vwB that has the combined columns of A and B" there is no SQL construct to express this common pattern.
Re:SQL Notebook by ianamartin on Wednesday May 10, 2017 @03:06AM (#14306390)
You just said to use the right tool for the right job, a few comments above.

Everything you are saying here sounds like a job for something other than a relational database.

I would shit a brick and beat any database developer with it that introduced the idea of a class as a primitive. Fuck that happy horse shit.

Also, graphs? Really?

You're looking for an ORM and blaming SQL for not being that.

There is no common database pattern that creates one table as a subset of another table. RDBMS is, by nature and design, not something you modify in that way on the fly. If you want that kind of object oriented functionality, push your data into a cache layer or column store or KV.

You said it yourself. Use the right tool for the right job. Nothing you've said makes even remotely any sense as a criticism of T-SQL or SQL in general. That's not the right tool for what you're talking about.

Re:SQL Notebook by Pxtl on Wednesday May 10, 2017 @07:25AM (#14307368)
Not that a class needs to be a primitive, but that patterns like inheritance should be reusable in some way through templating or the like.

And the inability to pull down a graph as a single operation is the perfect example of sql's limitations.

Relational model is great right? Right. So why throw it out the window and give me a glorified excel spreadsheet as a result set? If I want to pull down a thing and it's related subthings in a single operation, I have to join which is wasteful in that case. This actualy hamstrings ORMs.

Re:SQL Notebook by ianamartin on Wednesday May 10, 2017 @07:55AM (#14307484)
I don't think you understand relational databases.

I wouldn't hit you with an actual brick, but if I worked with you, I'd certainly nerf dart you on a regular basis.

Re:SQL Notebook by Pxtl on Wednesday May 10, 2017 @08:23AM (#14307594)
I understand relational databases just fine. I still have no interest in the Stockholm syndrome of defending a platform where a = a can evaluate to something equivalent to False, regardless of the theoretical underpinnings of three-valued logic.

There are so many pain points in SQL that are defended because theory.

Re:SQL Notebook by ak39 on Wednesday May 10, 2017 @02:56AM (#14306363)
Have you used T-SQL's "CROSS APPLY" or "OUTER APPLY" in conjunction with encapsulated views or table-valued functions?

You might want to have a look at that as a significant enabler of code reuse on SQL Server.

(On PgSQL is LATERAL JOIN)

(Ps: you should try to replace SCALAR functions with SET-BASED logic. These can easily be ringfenced into TVF)

Re:SQL Notebook by Pxtl on Wednesday May 10, 2017 @07:28AM (#14307386)
TVFs are intensely verbose to use compared to the corresponding SVF for a single column. Cross Apply will destroy your performance. I'm venting because I've watched clean, legible code get destroyed into soup of a zillion tiny joins and endless repeated boilerplate for performance improvement by this misfeature.