我一直在研究正确的关系代数,来自 Christopher Date 的书深度数据库:面向从业者的关系理论。在整本书中,他使用他和休·达尔文提出的语言来传达理论 - 教程D。总的来说,我认为教程 D 是一种非常可行的查询语言,比 SQL 灵活得多,所以我(只是为了好玩)热衷于尝试编写一个基于教程 D 的小型 RDBMS(毫无疑问,性能很差),而不是SQL。
意识到即使只是做一些基本的事情也是一项艰巨的任务,我想知道是否有可用的现有存储系统不代表 SQL 意义上的表,而是代表关系意义上的关系并且不假设任何特定查询语言用于访问数据,而只是提供低级函数,例如 product
、join
、intersect
、union、project
等(在C 级别,而不是查询语言级别)。
我说得有道理吗? :) 基本上我想采用类似的方法并在其前面添加一个Tutorial D(或类似的)查询界面。
在内存中完成所有操作确实很容易,但是以一种稍微高效的方式在磁盘上表示数据结构是相当棘手的,并且可能在没有经过认真研究的情况下超出了我的理解范围。
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.
发布评论
评论(3)
一般基于 SQL 的 RDBMS 使用 SQL 作为用户和数据库引擎之间结构化输入的接口,使用所谓的 查询优化器,它接受查询表达式并生成一组执行计划。
然后在数据库上执行最优的执行计划;这就是生成结果集的原因。
因此,如果您采用开源 RDBMS 实现并希望对其进行修改以接受不同的查询语言,您所要做的就是将您选择的查询语言转换为执行计划。
这并不是说您要做的事情很容易。只是这应该是可能的,而不必编写自己的 RDBMS。您需要为您的查询语言编写一个词法分析器和解释器,然后弄清楚如何将解释后的查询表达式传输到数据库引擎的优化器,以便它可以生成执行计划,并执行其中最有效的计划。
看看 SQLite 作为一个紧凑的开源关系数据库引擎。
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.
Dave Voorhis 的 Rel 已经实现了您似乎想要构建的功能。
http://dbappbuilder.sourceforge.net/Rel.php
当然,除非这是您明确的目的尝试为自己构建......
Dave Voorhis' Rel already does what you seem to want to build.
http://dbappbuilder.sourceforge.net/Rel.php
Unless of course it is your express purpose to try and build for yourself ...
请注意,教程 D 的前端不会与查询语言无关;)
我也投票给 Rel。
Hugh Darwen 维护着与 TTM 相关的项目列表( D 语言的规范(Tutorial D 是其中的一个实现),我确信他会很乐意听到你的努力,如果它们有所成果的话。
Note that a front end for Tutorial D would not be query-language agnostic ;)
My vote also goes for Rel.
Hugh Darwen maintains a list of projects related to TTM (the spec for a D language of which Tutorial D is an implementation), I'm sure he would love to hear of your efforts if they come to anything.