fastdb——查询语言

FastDB采用了一种类SQL的查询语言,支持面向对象编程,提供了丰富的查询功能,如对象引用、递归遍历等。它与标准SQL的区别在于不支持表连接和子查询,而是专注于对象操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Query language

FastDB supports a query language with SQL-like syntax. FastDB uses a notation more popular for object-oriented programming then for a relational database. Table rows are considered as object instances, the table is the class of these objects. Unlike SQL, FastDB is oriented on work with objects instead of SQL tuples. So the result of each query execution is a set of objects of one class. The main differences of the FastDB query language from standard SQL are:

1. There are no joins of several tables and nested subqueries. The query always returns a set of objects from one table.

2. Standard C types are used for atomic table columns.

3. There are no NULL values, except null references. I completely agree with C.J. Date's criticism of three-value logic and his proposal to use default values instead.

4. Structures and arrays can be used as record components. A special exists quantor is provided for locating elements in arrays.

5. Parameterless user methods can be defined for table records (objects) as well as for record components.

6. User functions with (only) one single string or numeric argument can be defined by the application.

7. References between objects are supported including automatic support for inverse references.

8. Construction of start from follow by performs a recursive records traversal using references.

9. Because the query language is deeply integrated into C++ classes, a case sensitive mode is used for language identifiers as well as for keywords.

20. No implicit conversion of integer and floating types to string representation is done. If such conversion is needed, it must be done explicitly.

FastDB支持一种类SQL语法的查询语言。FastDB使用的符号更加流行于面向对象的编程中,而非面向关系型数据库的编程中。表的每行记录被视为一个对象实例,表就是这些对象的类。SQL 不同,FastDB是面向对象的,而并不跟SQL一样是工作在一张二维表上的。所以每一个查询的执行结果就是一个类的一组对象。FastDB 查询语言和标准的SQL 的主要区别如下:

1、 在多张表之间没有连接,也没有嵌套的子查询。通常,查询是从一张表中返回一个对象集。 

2、 表的最小的列单元是标准的C 类型。

3 FastDB只有空指针,而没有NULL值。我完全同意C.J Date关于三值逻辑的评论,也赞同他使用默认值的建议。

4、 结构和数组可以用作记录成员。提供了一个特定的exists引用来定位数组中的元素 

5、 无参用户方法可以定义成为表记录(对象)的成员。

6、 应用程序可以定义仅带一个简单字符型或数值型参数的用户函数。 

7、 支持对象之间的指针,并且自动支持反向指针。

8 start from follow by 的构造函数,实现了指针在递归记录之间的移动。 

9、 由于查询语言和C++类结合得比较紧密,关键字和语言的标识符都区分大小写。

10、 不能进行整型和符点类型到字符串类型的隐式转换。如果需要进行这种转换的话,必须显式地进行。

 

 

The following rules in BNF-like notation specify the grammar of the FastDB query language search predicates:

下面的和BNF类似的符号规则规定了FastDB 查询语言的语法,显示如下:

Grammar conventions
ExampleMeaning
expressionnon-terminals
notterminals
|disjoint alternatives
(not)optional part
{1..9}repeat zero or more times

 

select-condition ::= ( expression ) ( traverse ) ( order )
expression ::= disjunction
disjunction ::= conjunction 
        | conjunction or disjunction
conjunction ::= comparison 
        | comparison and conjunction
comparison ::= operand = operand 
        | operand != operand 
        | operand <> operand 
        | operand < operand 
        | operand <= operand 
        | operand > operand 
        | operand >= operand 
        | operand (not) like operand 
        | operand (not) like operand escape string
        | operand (not) match operand
        | operand (not) in operand
        | operand (not) in expressions-list
        | operand (not) between operand and operand
	| operand is (not) null
operand ::= addition
additions ::= multiplication 
        | addition +  multiplication
        | addition || multiplication
        | addition -  multiplication
multiplication ::= power 
        | multiplication * power
        | multiplication / power
power ::= term
        | term ^ power
term ::= identifier | number | string 
        | true | false | null 
	| current | first | last
	| ( expression ) 
        | not comparison
	| - term
	| term [ expression ] 
	| identifier . term 
	| function term
        | exists identifier : term
function ::= abs | length | lower | upper
        | integer | real | string | user-function
string ::= ' { { any-character-except-quote } ('') } '
expressions-list ::= ( expression { , expression } )
order ::= order by sort-list
sort-list ::= field-order { , field-order }
field-order ::= [length] field (asc | desc)
field ::= identifier { . identifier }
traverse ::= start from field ( follow by fields-list )
fields-list ::=  field { , field }
user-function ::= identifier

Identifiers are case sensitive, begin with a a-z, A-Z, '_' or '$' character, contain only a-z, A-Z, 0-9, '_' or '$' characters, and do not duplicate a SQL reserved word.

List of reserved words
absandascbetweenby
currentdescescapeexistsfalse
firstfollowfromininteger
islengthlikelastlower
matchnotnullorreal
rectanglestartstringtrueupper

ANSI-standard comments may also be used. All characters after a double-hyphen up to the end of the line are ignored.

 

FastDB extends ANSI standard SQL operations by supporting bit manipulation operations. Operators and/or can be applied not only to boolean operands but also to operands of integer type. The result of applying the and/or operator to integer operands is an integer value with bits set by the bit-AND/bit-OR operation. Bit operations can be used for efficient implementation of small sets. Also the rasing to a power operation (x^y) is supported by FastDB for integer and floating point types.

FastDB扩展了ANSI 标准的SQL操作符,支持位操作。操作符andor 不仅能够应用于布尔类型的操作数,而且能够应用于整型操作数。and or 操作符应用于整型操作数的计算结果是一个整型值,该值的每一位都是由andor 位操作得出的结果。位操作可以用来高效率地设置数据的每一位。同样,FastDB也支持整形和浮点型的幂操作(x^y)。

 

概述FastDB是一个高效率的内存数据库系统,具有实时性能和方便的C++接口。 FastDB并不支持客户端/服务器结构,所有使用FastDB数据库的应用程序都必须运行在同一台主机上。FastDB为具有主导读取访问模式的应用程序作了优化。通过消除数据传输的开销和使用高性能的锁工具实现了查询执行的高速度。数据库文件和使用该数据库的每一个应用程序占用的虚拟内存空间相映射。所以查询在应用程序的任务中执行,不需要进行任务切换和数据传输。在FastDB中,通过原子指令来实现对数据库并发访问的同步,对查询处理几乎不增加任何开销。FastDB假设整个数据库都在当前内存中,并且在这个假设的基础上优化查询算法和结构。另外,数据库缓存管理几乎不会给FastDB增加任何开销,同时FastDB也不需要在数据库文件和缓冲池中进行数据传送。这就是为什么FastDB比将所有数据放在缓冲池中的传统数据库明显速度快的原因。   FastDB支持事务、在线备份和系统崩溃之后的自动恢复。事务提交协议基于一个影子根页算法,对数据库执行原子更新操作。恢复操作执行起来非常快,给关键应用程序提供了高效率。另外,它还取消了事务日志,提高了系统的整体性能,并且能够更加有效地使用系统资源。   FastDB是面向应用程序的数据库,使用应用程序的类信息来构建数据库的表。FastDB支持自动系统赋值,只允许你在一个地方——你的应用程序的类中,改变它们的值。FastDB为从数据库中提取数据提供了一个灵活而方便的接口。使用类似于SQL语言来书写查询语句。这些非原子字段、嵌套数组、用户自定义类型和方法、直接指向对象内部的指针等后关系性能,简化了数据库应用程序的设计,并且使得它们更加高效。   虽然FastDB的优化是基于整个数据库都存放在机器的物理内存的这个假设上的,我们依然可以将FastDB使用在那些大小超过系统物理内存的数据库上。最后,标准操作系统的交换机制将会起作用。但是所有的FastDB的算法和结构的优化都是基于数据存放在内存中这个假设上的,所以数据交换的效率不会很高。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值