Banner showing base of Eiffel tower

Github

Download version 1.4.8: Windows or Linux

Persistency Library: Eiffel CHAIN Orientated Binary Database

Classes

ECF: chain-db.ecf

Directory source listing

Overview

The Chain-DB library enables the development of container objects conforming to the base class CHAIN that have many of the properties of relational database tables. Some of the most important enabling classes for Chain-DB are to be found in the cluster Eiffel-Loop/base/data_structure.

PERSISTENCE

Of course this is the fundamental property of any database. Chain-DB offers 2 kinds of persistence:

1. CHAIN level persistence

This type of persistence involves storing the entire chain to a file in one operation. This is useful for data that is more or less static, like for example the localization table EL_TRANSLATION_ITEMS_LIST.

See class EL_STORABLE_CHAIN.

2. item level persistence

Item level, or "incremental persistence" is where the effects of any of the basic CHAIN operations (extend/replace/delete**) are recorded as they happen in a separate editions file. When the chain is loaded during object initialization, a chain level store is loaded first, and then the stored editions are applied to bring the chain to it's final state.

See class EL_RECOVERABLE_STORABLE_CHAIN for more details.

JOINING TABLES

Being able to join*** tables via a common field is the essence of a relational database. Chain-DB offers a number of features that support the joining of chains.

1. Field Indexing

For large number of chain items, performing joins can be slow without the use of field indices. Writing code to create and maintain fields manually is very time consuming, but fortunately Chain-DB offers an easy way to maintain field indices via the implementing class EL_STORABLE_LIST and it's reflective descendant: EL_REFLECTIVELY_STORABLE_LIST. See the class documentation for more details.

2. Primary Keys

Being able to assign a unique identifier to each item in a chain is essential to creating many kinds of data-joins. Chain-DB offers a convenient way to both generate primary keys and maintain an index for it. This is achieved with the auxilary class EL_PRIMARY_KEY_INDEXABLE when used in conjunction with either EL_STORABLE_LIST or it's reflective descendant: EL_REFLECTIVELY_STORABLE_LIST.

QUERY LANGUAGE

Of course the Eiffel language itself can be used to query any CHAIN list, but sometimes the meaning of the query is obscured in implementation details. What is needed is a slightly more abstract way of expressing queries that makes the meaning more apparent. This is provided by the class EL_QUERYABLE_CHAIN and it's helper EL_QUERY_CONDITION_FACTORY. The implementing class EL_STORABLE_LIST inherits EL_QUERYABLE_CHAIN.

Conditions can be combined using the logical operators: and, or and not. Queries are not parsed strings but actual Eiffel expressions. Some example of the expressiveness of this query language can be found in the following list of classes from the example project Eiffel-Loop/example/manage-mp3:

(Search page for routine do_query)

Foot Notes

** delete is a routine from EL_STORABLE_CHAIN and not from CHAIN.

*** We are using the term join somewhat loosely and mean only that if you have two chains CHAIN [A] and CHAIN [B], you can produce a subchain of CHAIN [B] where each B item has a matching field value with an item from CHAIN [A].

Directory: library/persistency/database/chain-db

[ . ]

. /encryptable

[ . ]

EL_MULTI_TYPE_FILE_READER_WRITER

Object that can store types conforming to type G

EL_RECOVERABLE_STORABLE_CHAIN

This class combines the functionality of classes EL_STORABLE_CHAIN and EL_STORABLE_CHAIN_EDITIONS. The former class can store and load the complete state of all chain items, while the latter immediately stores any of the following chain editions: extend, replace, remove, delete.

When doing a file retrieval, the last complete state is loaded from file_path and then all the recent editions are loaded and applied from a separate file: editions_file_path. The routine safe_store stores the complete chain in a temporary file and then does a quick check on the integrity of the save by checking all the item headers. Only then is the stored file substituted for the previously stored file.

Further Information

Click on class link to see instructions.

EL_STORABLE_CHAIN

Chain of storable items which can be saved to and read from a file. The chain has the following features:

Further Information

Click on class link to see notes and client examples.

EL_STORABLE_CHAIN_EDITIONS

Stores any of the following chain editions in an editions file:

  1. extend
  2. replace
  3. delete

The editions file path is derived from the deferred file_path name by changing the extension to editions.dat

EL_CHAIN_EDITIONS_FILE

EL_FILE_READER_WRITER

Click on class link to see client examples.

encryptable

EL_ENCRYPTABLE_CHAIN_EDITIONS_FILE

EL_ENCRYPTABLE_FILE_READER_WRITER

EL_ENCRYPTABLE_MULTI_TYPE_FILE_READER_WRITER