SQL is a DSL
October 27th, 2008 | Published in oracle | 9 Comments
Sometimes it seems like programmers will do everything to avoid SQL. At the same time DSLs (Domain Specific Languages) are very popular. If DSLs are so great, why are you trying to avoid SQL? Or procedural extensions to SQL? SQL is a DSL for dealing with relational data.
SQL was invented to deal with relational data, there aren’t many better, easier and faster ways to deal with large amounts of data stored in a relational database. Seriously, databases are made to handle large amounts of data. To sort it, to filter it, etc. Trying to do that in another language, or even worse, in another layer, makes no sense. It’s really expensive to move the data from the database into your middleware layer, and Java (or any other middleware language) isn’t really a good language to sort and filter large amount of data.
Procedural extensions to SQL, like for example Oracle’s pl/SQL, are even worse off. It seems like middleware programmers will do everything not to have to use a procedural language in the database. But fact is that pl/sql is a very good tool to write data heavy business logic in. There is no faster way to handle large amounts of data, then right there in the database. And there is no easier way to write data heavy procedural code than using a procedural extension to SQL. That is what pl/sql is: a DSL for writing data centric logic.
Added bonus: anything in the database is extremely reusable. Almost every language has a library which allows you to make use of relational databases. So, if you put it in the database, no matter what middleware or frontend language you’re going to use in the future, your data centric logic can be reused.
October 27th, 2008 at 8:56 pm (#)
I absolutely agree with you. For some reason SQL got a bad rap among Java developers. Apparently it’s not object-oriented enough.
Existing frameworks promise to shield Java developers from SQL which is a shame and produces some monstrously inefficient applications.
I believe that database and SQL queries and stored procedures are the most long-lived part of the application. Business logic that uses it would change more frequently and UI has the shortest live span.
From this perspactive, I think the tools and developers that approach database design from Java side are doing it backwards.
October 30th, 2008 at 9:18 am (#)
Well said. There is hope still.
November 20th, 2008 at 10:13 am (#)
Off course you are right provided that a customer does have Oracle’s RDBMS to start of with. In a scenario where it is unclear or uncertain what the actual database platform will be – for instance for standard applications that want to provide functionality instead of just serving data – staying away for vender specific SQL (like non-standard JDBC types, and procedural extensions) is a good thing.
In cases where the database *is* Oracle’s RDBMS I don’t have a problem using Oracle’s extensions like PL/SQL as long as it is only data related.
April 6th, 2009 at 9:44 pm (#)
[...] into a middleware language is any better than locking yourself into a database language. Afterall, why not use a data oriented DSL for data related tasks? Share and [...]
April 7th, 2009 at 9:50 am (#)
[...] level (i.e. in the same physical store, with shared access control, accessible using a well-known DSL for data manipulation…). Metamodel transformation and model bridging are costly (in accuracy, maintenance, [...]
April 20th, 2009 at 5:51 pm (#)
Java, web, KiddieKoders are stupid. full stop. They write COBOL, in lower case, and are convinced they are doing something new and different. They iterate through a lump of data just as COBOL coders do through a copybook. They should be strung up by their heels and flogged.
May 1st, 2009 at 3:33 am (#)
Does anyone know if there is another language or set of commands beside SQL for talking with databases?
I’m working on a project and am doing some research thanks
May 1st, 2009 at 3:56 am (#)
You know, the thing about SQL is, that there is virtually nothing that can replace it.
Does anyone know if a substitute exists for sql? I mean besides MS SQL and Oracle and all that jazz. Thanks.
May 1st, 2009 at 6:13 am (#)
This article mentions some alternative query languages: Web and Semantic Web Query Languages: A Survey .