0

Disclaimer: I'm not very knowledgeable when it comes to SQL or RDBMS in general.

I've encountered this interesting answer about SQL as a language: https://stackoverflow.com/a/1643440/414063

This also talks about stored procedures, but stored procedures are still related to SQL (I think).

Are there viable candidates/alternatives/API to replace SQL as a language, while keeping/saving the existing and underlying infrastructure of an existing RDBMS?

Are there XML or language bindings (C, C++, java, C#, etc) that would allow one to directly tap into a RDBMS, without having to write any SQL at all? Would it be possible, for example, to adapt sqlite3's code? Or is the ecosystem of RDBMS too closely tied to the SQL language?

4
  • Object Relational Mappers (ORM) let you manipulate databases without having to write SQL. The ORM writes the SQL for you. It’s not really what you’re asking, but it might help?
    – Rik D
    CommentedJun 7, 2020 at 14:32
  • yes it seems that's what I'm looking for. there's an ORM for sqlite, it seems
    – jokoon
    CommentedJun 7, 2020 at 14:39
  • @jokoon, in my view ORMs do not allow you to work with databases without knowing SQL, if you are the person who is tasked with actually writing the ORM layer (rather than merely consuming a layer that someone else in your team crafts for you). If writing the ORM layer is your responsibility, then not only will you require a proficient knowledge of SQL, but also a proficient knowledge of the ORM technology too (which is never simple). The purpose of ORMs is to achieve a division of labour between pure OO programmers and SQL programmers, not to avoid the need for SQL programmers.
    – Steve
    CommentedJun 7, 2020 at 15:30
  • Yes it is possible now. Here is the link to the answer: softwareengineering.stackexchange.com/a/447209/433968
    – V J
    CommentedAug 23, 2023 at 20:26

2 Answers 2

4

The RDBMS are all based on the same underlying ceoncept of Codd's relational algebra. SQL provides a language that is based on these underlying concepts. So, it's a kind of natural fit. This is the reason why it is so deeply intertwined with RDMBS products, the other being that the big names of RDBMS have worked together in the standardisation committees to let SQL evolve together with their product.

When you access the RDBMS with an application programming language, every RDBMS provider will provide it's own native API. These will however look somewhat similar (e.g. SQLLite or Oracle) : you'll probably prepare some SQL statement (with or without binding to programming language variables), then you can execute a prepared statement (this prevents parsing several time the same statement), then fetch or mass-fetch the result. And all these APIs will rely on SQL to express the data definition, data management and data query needs.

If RDBMS wouldn't rely on SQL in their API, they would have to provide hundreds of proprietary API functions that would be different for every provider, and much more difficult to understand than SQL. In addition, it would be more difficult to let an SQL optimizer optimize these API calls. So getting rid of SQL would create another problem.

This is why you'll always end up with some kind of SQL in the way. Be it in the middleware (e.g. ODBC, JDBC or ADO.net), be it in an ORM, or be it in your own data access layer.

The ORM layer (e.g. EF core) is at a higher level. It may therefore hide the SQL behind ORM-specific constructs and do the mapping with SQL behind the scene. This may be interesting for your if you want to focus on your domain objects rather than to deal with the persistence yourself. If you need to do some advanced querying however, you'll quickly recognize that SQL concepts are still there.

If you're worried about performance, don't: very large scale transactional systems have demonstrated that this architecture can deal with very high volumes (and this is why you generally separate in the low level API the 'prepare' and the 'execute').

1
  • I'd like to provide an additional note that not only do most teachings of "relational algebra" consist of awkward concepts and mathematical notations that are inconsistent with how working programmers operate (not to mention the downright nonsense that is sometimes spouted), but those concepts and notations also do not generalise to fully explain all the behaviour of SQL (for example, the window functions are utterly inexplicable in terms of relational algebra). Codd's work is really interesting, but modern retellings struggle to articulate it's actual value in my view.
    – Steve
    CommentedJun 7, 2020 at 15:24
2

SQL is one of many languages that can be used to query relational databases.

There have been a lot of improvements and alternatives proposed over the last 50 years. The Third Manifesto is a well-known proposal for improving Relational Databases and the languages used to query them. In the Third Manifesto the authors specify D, which is a list of requirements and restrictions that the authors believe a language must respect in order to be a good language for relational databases. They also have language called Tutorial D which is an example of D they use in their book.

There are a couple of implementations of D, the most well-known being Rel, an implementation of Tutorial D.

Andl – A New Data Language is another language based on The Third Manifesto, and it has a SQLite backend. (Introduction here.)

Also, there is Project:M36, a "mathematically-coherent relational algebra database management system (RDBMS) written in Haskell".

There are also Relational Database Systems that go beyond the ideas of SQL, such as (NF)² – Non-First-Normal-Form, which gives up Codd's 1st normal form (Atomicity of Values), so that tables can be values.

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.