I’ve been studying proper relational algebra, from Christopher Date’s book Database in Depth: Relational Theory for Practitioners. Throughout the book he uses the language he and Hugh Darwen came up with in order to convey the theory — Tutorial D. In general I think Tutorial D is a very workable query language, much more flexible than SQL and so I (just for fun) was keen to take a stab at writing a (poor performing, undoubtedly) little RDBMS based on Tutorial D, rather than SQL.
Realizing this is a mammoth of a task even just to make something basic, I wonder if there are existing storage systems available that don’t represent tables in the SQL sense, but represent relations in the relational sense and don’t assume any particular query language is used to access the data, but rather just provide low-level functions like product, join, intersect, union, project etc (at the C-level, not at a query language level).
Am I making sense? 🙂 Basically I’d like to take something like this and stick a Tutorial D (or similar) query interface in front of it.
It’s really easy to do everything in memory, but representing the data structures on disk in a fashion that is even mildly efficient is pretty tricky and probably over my head without some serious research.
General SQL-based RDBMS that use SQL as an interface for structured input between the user and the database engine use what is called a Query Optimizer which takes the query expression and generates a set of Execution Plans.
The most optimal execution plan is then executed on the database; that’s what generates result sets.
So, if you took an open source RDBMS implementation and wanted to modify it to accept a different query language, all you would have to do would be to translate the query language of your choice into an execution plan.
That’s not to say that what you’re trying to do is easy. Just that it should be possible, without having to write your own RDBMS. You would need to write a lexer and interpreter for your query language and then figure out how to transfer your interpreted query expression to the database engine’s optimizer so that it can generate the execution plans, and execute the most efficient of them.
Take a look a SQLite as a compact open source relational database engine.