Why Not SQL: The Origin of ScopeQL
SQL has dominated structured data processing for 50 years. However, its age reveals significant design flaws, notably non-composable and inconsistent syntax.
When developing the query language for ScopeDB, we decided to go against SQL and design a new language, ScopeQL, from scratch to fix SQL's problems. In this post, we will discuss where SQL falls short and the design principles behind ScopeQL.
TL;DR
- Both SQL and ScopeQL are based on relational algebra, a powerful, elegant, proven theory.
- SQL query is out of its semantic order; ScopeQL fixes it with a linear pipelined syntax.
- SQL has a rigid and arbitrary syntax; ScopeQL's syntax is consistent, composable, and reduced.
- SQL relies on subqueries heavily, while ScopeQL eliminates most of them.
Here is a showcase:
- SQL
- ScopeQL
SELECT
country,
MAX(salary) AS max_salary
FROM
employees
WHERE
start_date > '2025-01-01 00:00:00+00:00'::TIMESTAMPTZ
GROUP BY
country
HAVING
MAX(salary) > 100000
FROM employees
WHERE start_date > '2021-01-01 00:00:00+00:00'::timestamp
GROUP BY country AGGREGATE max(salary) AS max_salary
WHERE max_salary > 100000