About Lukas Eder

Lukas is a Java and SQL enthusiast developer. He created the Data Geekery GmbH. He is the creator of jOOQ, a comprehensive SQL library for Java, and he is blogging mostly about these three topics: Java, SQL and jOOQ.

A Better Query Language than SQL

Leland Richardson, Founder of Tech.Pro has recently published a very interesting article about BQL, his visions of a better query language (than SQL). The deciding feat of his new language proposal is the fact that it is really a superset of SQL itself.

SQL is a very rich and expressive language to query relational databases. But it is awkward in many aspects, and a lot of people perceive it to be evolving only slowly – even if that is not true, considering the pace of SQL standards. But the standard is one thing, the implementations another – especially in the enterprise. When we blog about SQL, we’re constantly surprised ourselves, how awesome the PostgreSQL dialect is. But often, PostgreSQL actually just implements the standard. So there is hope that we’re getting somewhere.

Nonetheless, in Leland’s article, there are a couple of ideas worth picking up. From our point of view, these are mainly:

Flexibility in ordering the SELECT clause and the table expression

In SQL, SELECT is always the first keyword. It must be expressed before the table expression. We’ve shown in a previous article that this is quite confusing for many SQL users. While the existing syntax should continue to exist, it would be good to be able to inverse the SELECT clause and the table expression.

FROM table
WHERE predicate
GROUP BY columns
SELECT columns

Remember, the table expression contains FROM, WHERE, GROUP BY clauses, as well as vendor-specific CONNECT BY clauses and others:

<query specification> ::=
  SELECT [ <set quantifier> ] 
    <select list> <table expression>

This language feature is already available in LINQ, by the way.

Implicit KEY JOINs

This feature is also available in jOOQ, using the ON KEY clause. Note that Sybase also supports ON KEY joins:

from post 
key join user
key join comment
select *

Named projections

This is one of the features we really wish that the SQL language had. However, we wouldn’t count on specifying projections in a dedicated syntax. We had rather use an extension to the table expression syntax, allowing for a table to produce “side-tables” as such:

from dbo.users
with projection as (
  firstName, lastName, phoneNumber, email
)
select projection.*

In the above example, projection is really nothing else than another table expression that is derived from the users table. From a SQL syntax semantics, this would be extremely powerful, because such projections would inherit all syntactic features of a regular table. We’ve blogged about this before, when we called that feature “common column expressions”.

Conclusion

Leland has lots of other ideas. He’s just at the beginning of a project that will still need a lot of refinement. The feedback he got on reddit, however, is rather good. Clearly, there is a lot of potential in creating “BQL” for SQL what

Let’s see where this endeavour leads. We’ll certainly be keeping an eye out for BQL’s next steps.

Reference: A Better Query Language than SQL from our JCG partner Lukas Eder at the JAVA, SQL, AND JOOQ blog.

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

JPA Mini Book

Learn how to leverage the power of JPA in order to create robust and flexible Java applications. With this Mini Book, you will get introduced to JPA and smoothly transition to more advanced concepts.

JVM Troubleshooting Guide

The Java virtual machine is really the foundation of any Java EE platform. Learn how to master it with this advanced guide!

Given email address is already subscribed, thank you!
Oops. Something went wrong. Please try again later.
Please provide a valid email address.
Thank you, your sign-up request was successful! Please check your e-mail inbox.
Please complete the CAPTCHA.
Please fill in the required fields.

Leave a Reply


9 − = five



Java Code Geeks and all content copyright © 2010-2014, Exelixis Media Ltd | Terms of Use | Privacy Policy
All trademarks and registered trademarks appearing on Java Code Geeks are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries.
Java Code Geeks is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.
Do you want to know how to develop your skillset and become a ...
Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

Get ready to Rock!
You can download the complementary eBooks using the links below:
Close