fastdb——查询语言

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)。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值