?? fastdb.htm
字號:
<HTML><HEAD><TITLE>FastDB Main Memory Database Management System</TITLE><UL><LI> <A HREF = "#introduction">Introduction</A><LI> <A HREF = "#sql">Query language</A> <UL> <LI> <A HREF = "#structure">Structures</A> <LI> <A HREF = "#array">Arrays</A> <LI> <A HREF = "#string">Strings</A> <LI> <A HREF = "#reference">References</A> <LI> <A HREF = "#rectangle">Rectangle</A> <LI> <A HREF = "#function">Functions</A> </UL><LI> <A HREF = "#cpp">C++ interface</A> <UL> <LI> <A HREF = "#table">Table</A> <LI> <A HREF = "#query">Query</A> <LI> <A HREF = "#cursor">Cursor</A> <LI> <A HREF = "#database">Database</A> </UL><LI> <A HREF = "#cli">CLI - call level interface</A> <UL> <LI> <A HREF = "#cli_errors">CLI error codes</A> <LI> <A HREF = "#cli_types">CLI supported types</A> <LI> <A HREF = "#cli_open">cli_open</A> <LI> <A HREF = "#cli_close">cli_close</A> <LI> <A HREF = "#cli_statement">cli_statement</A> <LI> <A HREF = "#cli_parameter">cli_parameter</A> <LI> <A HREF = "#cli_column">cli_colunm</A> <LI> <A HREF = "#cli_array_column">cli_array_column</A> <LI> <A HREF = "#cli_fetch">cli_fetch</A> <LI> <A HREF = "#cli_insert">cli_insert</A> <LI> <A HREF = "#cli_get_first">cli_get_first</A> <LI> <A HREF = "#cli_get_last">cli_get_last</A> <LI> <A HREF = "#cli_get_next">cli_get_next</A> <LI> <A HREF = "#cli_get_prev">cli_get_prev</A> <LI> <A HREF = "#cli_get_oid">cli_get_oid</A> <LI> <A HREF = "#cli_update">cli_update</A> <LI> <A HREF = "#cli_remove">cli_remove</A> <LI> <A HREF = "#cli_free">cli_free</A> <LI> <A HREF = "#cli_commit">cli_commit</A> <LI> <A HREF = "#cli_abort">cli_abort</A> <LI> <A HREF = "#cli_show_tables">cli_show_tables</A> <LI> <A HREF = "#cli_describe">cli_describe</A> <LI> <A HREF = "#cli_create_table">cli_create_table</A> <LI> <A HREF = "#cli_alter_table">cli_alter_table</A> <LI> <A HREF = "#cli_drop_table">cli_drop_table</A> <LI> <A HREF = "#cli_alter_index">cli_alter_index</A> <LI> <A HREF = "#cli_freeze">cli_freeze</A> <LI> <A HREF = "#cli_unfreeze">cli_unfreeze</A> <LI> <A HREF = "#cli_seek">cli_seek</A> <LI> <A HREF = "#cli_skip">cli_skip</A> </UL><LI> <A HREF = "#localcli">Local implementation of CLI</A> <UL> <LI> <A HREF = "#cli_create">cli_create</A> <LI> <A HREF = "#cli_create_replication_node">cli_create_replication_node</A> <LI> <A HREF = "#cli_attach">cli_attach</A> <LI> <A HREF = "#cli_detach">cli_detach</A> <LI> <A HREF = "#cli_get_database_state">cli_get_database_state</A> <LI> <A HREF = "#cli_prepare_query">cli_prepare_query</A> <LI> <A HREF = "#cli_execute_query">cli_execute_query</A> <LI> <A HREF = "#cli_insert_struct">cli_insert_struct</A> </UL><LI> <A HREF = "jnicli/docs/index.html">Native interface to Java language</A><LI> <A HREF = "#advanced">Delayed transactions and online backup scheduler</A><LI> <A HREF = "#replication">Fault tolerant support</A><LI> <A HREF = "#optimization">Query optimization</A> <UL> <LI> <A HREF = "#indices">Using indices in queries</A> <LI> <A HREF = "#inverse">Inverse references</A> <LI> <A HREF = "#realtime">Realtime issues</A> <LI> <A HREF = "#par">Parallel query execution</A> </UL><LI> <A HREF = "#gist">Generalized search tree</A><LI> <A HREF = "#implementation">FastDB implementation issues</A> <UL> <LI> <A HREF = "#memory">Memory allocation</A> <LI> <A HREF = "#transaction">Transactions</A> <LI> <A HREF = "#recovery">Recovery</A> <LI> <A HREF = "#hashtable">Hash table</A> <LI> <A HREF = "#ttree">T-tree</A> </UL><LI> <A HREF = "#subsql">Interactive SQL</A><LI> <A HREF = "#www">API for development Web applications</A><LI> <A HREF = "#examples">Examples of FastDB applications</A> <UL> <LI> <A HREF = "#guess">Example: game "Guess an animal"</A> <LI> <A HREF = "#testdb">Example: various types of queries</A> <LI> <A HREF = "#testperf">Performance test</A> <LI> <A HREF = "#bugdb">Bug tracking database</A> <LI> <A HREF = "#clidb">Clients-Managers database</A> </UL><LI> <A HREF = "#quick">Quick start</A><LI> <A HREF = "#dbsize">Reducing initial size of the database file</A><LI> <A HREF = "#diskless">Diskless configuration</A><LI> <A HREF = "#sharing">Sharing of classes between different databases</A><LI> <A HREF = "docs/html/index.html">Documentation generated by Doxygen</A><LI> <A HREF = "#distribution">Distribution terms</A></UL><BODY><HR><H2><A NAME = "introduction">Introduction</A></H2>FastDB is a highly efficient main memory database system with realtime capabilities and convenient C++ interface.FastDB doesn't support a client-server architecture and all applicationsusing a FastDB database should run at the same host. FastDB is optimized for applications with dominated read access pattern. High speed of query execution is provided by the elimination of data transfer overhead anda very effective locking implementation. The Database file is mapped to the virtualmemory space of each application working with the database. So the query is executed inthe context of the application, requiring no context switching and data transfer.Synchronization of concurrent database access is implemented in FastDB by means of atomic instructions, adding almost no overhead to query processing. FastDB assumes that the whole database is present in RAM and optimizes the search algorithms and structures according to thisassumption. Moreover, FastDB has no overhead caused by database buffer managementand needs no data transfer between a database file and buffer pool. That is why FastDB will work significantly faster than a traditional database with all data cached in buffers pool.<P>FastDB supports transactions, online backup and automatic recovery after system crash. The transaction commit protocol is based ona shadow root pages algorithm, performing atomic update of the database.Recovery can be done very fast, providing high availability for critical applications. Moreover, the eliminationof transaction logs improves the total system performance and leads to a more effective usage of system resources.<P>FastDB is an application-oriented database. Database tables are constructed usinginformation about application classes. FastDB supports automatic scheme evaluation, allowing you to do changes only in one place - in yourapplication classes. FastDB provides a flexible and convenient interfacefor retrieving data from the database. A SQL-like query language is usedto specify queries. Such post-relational capabilities as non-atomicfields, nested arrays, user-defined types and methods, direct interobject references simplifies the design of database applications and makes them moreefficient.<P>Although FastDB is optimized in the assumption that database as a whole fitsinto the physical memory of the computer, it is also possible to use it with databases,the size of which exceeds the size of the physical memory in the system. In the last case, standard operating system swapping mechanisms will work. But all FastDB search algorithms and structures are optimized under the assumption ofresidence of all data in memory, so the efficiency for swapped out data will not be very high.<P> <H2><A NAME = "sql">Query language</A></H2>FastDB supports a query language with SQL-like syntax. FastDB uses a notation morepopular for object-oriented programming then for a relational database. Table rows are considered as object instances, the table is the class of theseobjects. Unlike SQL, FastDB is oriented on work with objects instead of SQLtuples. 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:<P><OL><LI> There are no joins of several tables and nested subqueries. The query alwaysreturns a set of objects from one table. <LI> Standard C types are used for atomic table columns.<LI> 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. <LI> Structures and arrays can be used as record components. A special <B>exists</B> quantor is provided for locating elements in arrays. <LI> Parameterless user methods can be defined for table records (objects) as well asfor record components.<LI> User functions with (only) one single string or numeric argument can be defined bythe application. <LI> References between objects are supported including automatic supportfor inverse references. <LI>Construction of <code>start from follow by</code> performs a recursive recordstraversal using references.<LI> Because the query language is deeply integrated into C++ classes, a casesensitive mode is used for language identifiers as well as for keywords. <LI> No implicit conversion of integer and floating types to stringrepresentation is done. If such conversion is needed, it must be done explicitly. </OL><P>The following rules in BNF-like notation specify the grammar of theFastDB query language search predicates:<P><TABLE BORDER ALIGN="center"><CAPTION>Grammar conventions</CAPTION><TR><TH>Example</TH><TH>Meaning</TH></TR><TR><TD><I>expression</I></TD><TD>non-terminals</TD></TR><TR><TD><B>not</B></TD><TD>terminals</TD></TR><TR><TD ALIGN="center">|</TD><TD>disjoint alternatives</TD></TR><TR><TD>(<B>not</B>)</TD><TD>optional part</TD></TR><TR><TD>{<B>1</B>..<B>9</B>}</TD><TD>repeat zero or more times</TD></TR></TABLE><P><PRE><I>select-condition</I> ::= ( <I>expression</I> ) ( <I>traverse</I> ) ( <I>order</I> )<I>expression</I> ::= <I>disjunction</I><I>disjunction</I> ::= <I>conjunction</I> | <I>conjunction</I> <B>or</B> <I>disjunction</I><I>conjunction</I> ::= <I>comparison</I> | <I>comparison</I> <B>and</B> <I>conjunction</I><I>comparison</I> ::= <I>operand</I> <B>=</B> <I>operand</I> | <I>operand</I> <B>!=</B> <I>operand</I> | <I>operand</I> <B><></B> <I>operand</I> | <I>operand</I> <B><</B> <I>operand</I> | <I>operand</I> <B><=</B> <I>operand</I> | <I>operand</I> <B>></B> <I>operand</I> | <I>operand</I> <B>>=</B> <I>operand</I> | <I>operand</I> (<B>not</B>) <B>like</B> <I>operand</I> | <I>operand</I> (<B>not</B>) <B>like</B> <I>operand</I> <B>escape</B> <I>string</I> | <I>operand</I> (<B>not</B>) <B>match</B> <I>operand</I> | <I>operand</I> (<B>not</B>) <B>in</B> <I>operand</I> | <I>operand</I> (<B>not</B>) <B>in</B> <I>expressions-list</I> | <I>operand</I> (<B>not</B>) <B>between</B> <I>operand</I> <B>and</B> <I>operand</I> | <I>operand</I> <B>is</B> (<B>not</B>) <B>null</B><I>operand</I> ::= <I>addition</I><I>additions</I> ::= <I>multiplication</I> | <I>addition</I> <B>+</B> <I>multiplication</I> | <I>addition</I> <B>||</B> <I>multiplication</I> | <I>addition</I> <B>-</B> <I>multiplication</I><I>multiplication</I> ::= <I>power</I> | <I>multiplication</I> <B>*</B> <I>power</I> | <I>multiplication</I> <B>/</B> <I>power</I><I>power</I> ::= <I>term</I> | <I>term</I> <B>^</B> <I>power</I><I>term</I> ::= <I>identifier</I> | <I>number</I> | <I>string</I> | <B>true</B> | <B>false</B> | <B>null</B> | <B>current</B> | <B>first</B> | <B>last</B> | <B>(</B> expression <B>)</B> | <B>not</B> <I>comparison</I> | <B>-</B> term | <I>term</I> <B>[</B> expression <B>]</B> | <I>identifier</I> <B>.</B> <I>term</I> | <I>function</I> <I>term</I> | <B>exists</B> <I>identifier</I> <B>:</B> <I>term</I><I>function</I> ::= <B>abs</B> | <B>length</B> | <B>lower</B> | <B>upper</B> | <B>integer</B> | <B>real</B> | <B>string</B> | <I>user-function</I><I>string</I> ::= <B>'</B> { { <I>any-character-except-quote</I> } (<B>''</B>) } <B>'</B><I>expressions-list</I> ::= <B>(</B> <I>expression</I> { <B>,</B> <I>expression</I> } <B>)</B><I>order</I> ::= <B>order by</B> <I>sort-list</I><I>sort-list</I> ::= <I>field-order</I> { <B>,</B> <I>field-order</I> }<I>field-order</I> ::= [<B>length</B>] <I>field</I> (<B>asc</B> | <B>desc</B>)<I>field</I> ::= <I>identifier</I> { <B>.</B> <I>identifier</I> }<I>traverse</I> ::= <B>start from</B> <I>field</I> ( <B>follow by</B> <I>fields-list</I> )<I>fields-list</I> ::= <I>field</I> { <B>,</B> <I>field</I> }<I>user-function</I> ::= <I>identifier</I></PRE><P>Identifiers are case sensitive, begin with a a-z, A-Z, '_' or '$' character, contain only a-z, A-Z, 0-9, '_' or '$' characters, anddo not duplicate a SQL reserved word.<P><TABLE WIDTH=100%><CAPTION>List of reserved words</CAPTION><TR><TD>abs</TD><TD>and</TD><TD>asc</TD><TD>between</TD><TD>by</TD></TR><TR><TD>current</TD><TD>desc</TD><TD>escape</TD><TD>exists</TD><TD>false</TD></TR><TR><TD>first</TD><TD>follow</TD><TD>from</TD><TD>in</TD><TD>integer</TD></TR><TR><TD>is</TD><TD>length</TD><TD>like</TD><TD>last</TD><TD>lower</TD></TR><TR><TD>match</TD><TD>not</TD><TD>null</TD><TD>or</TD><TD>real</TD></TR><TR><TD>rectangle</TD><TD>start</TD><TD>string</TD><TD>true</TD><TD>upper</TD></TR></TABLE><P>ANSI-standard comments may also be used. All characters after a double-hyphen up tothe end of the line are ignored.<P>FastDB extends ANSI standard SQL operations by supporting bit manipulation operations. Operators <code>and</code>/<code>or</code> can be applied not only to boolean operands but also to operands of integer type. The result of applying the<code>and</code>/<code>or</code> operator to integer operands is an integervalue with bits set by the bit-AND/bit-OR operation. Bit operations can be usedfor efficient implementation of small sets. Also the rasing to a poweroperation (x<B>^</B>y) is supported by FastDB for integer and floating pointtypes.<P> <H3><A NAME = "structure">Structures</A></H3>FastDB accepts structures as components of records. Fields of the structurecan be accessed using the standard dot notation: <code>company.address.city</code><P>Structure fields can be indexed and used in an <code>order by</code>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -