Banner showing base of Eiffel tower

Github

Download version 1.4.8: Windows or Linux

Persistency Library: Eco-DB (Eiffel CHAIN Orientated Database)

The Eco-DB (Eiffel CHAIN Orientated Database) library has 14 classes.

ECF: Eco-DB.ecf

Source code: directory list

Eco-DB is an acronym for Eiffel CHAIN Orientated Database, and enables the development of container objects conforming to the base class CHAIN to have many of the properties of relational database tables.

PERSISTENCE

Of course this is the fundamental property of any database. Eco-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 ECD_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 ECD_RECOVERABLE_CHAIN for more details.

JOINING TABLES

Being able to join*** tables via a common field is the essence of a relational database. Eco-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 Eco-DB offers an easy way to maintain field indices via the implementing class ECD_ARRAYED_LIST and it's reflective descendant: ECD_REFLECTIVE_ARRAYED_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. Eco-DB offers a convenient way to both generate primary keys and maintain an index for it. This is achieved with the auxilary class ECD_PRIMARY_KEY_INDEXABLE when used in conjunction with either ECD_ARRAYED_LIST or it's reflective descendant: ECD_REFLECTIVE_ARRAYED_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 ECD_ARRAYED_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 ECD_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/eco-db

[ . ]

. /editions

. /index

. /reader-writer

[ . ]

ECD_ARRAYED_LIST

Provides the following features when used in conjunction with the classes ECD_CHAIN or ECD_RECOVERABLE_CHAIN from the Eco-DB library:

Further Information

Click on class link to see instructions.

ECD_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.

ECD_RECOVERABLE_CHAIN

This class combines the functionality of classes ECD_CHAIN and ECD_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.

ECD_REFLECTIVE_ARRAYED_LIST

A list conforming to ECD_ARRAYED_LIST with items conforming to EL_REFLECTIVELY_SETTABLE_STORABLE.

Adds ability to do reflective CSV exports to list of type ECD_ARRAYED_LIST By 'reflective' is meant that the exported CSV field names match the fields name of the class implementing EL_REFLECTIVELY_SETTABLE_STORABLE.

editions

ECD_CHAIN_EDITIONS

Stores any of the following Eco-DB 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

ECD_EDITIONS_FILE

Eco-DB chain editions file

ECD_ENCRYPTABLE_EDITIONS_FILE

Eco-DB encryptable chain editions file

index

ECD_KEY_INDEX

Supporting class for class ECD_PRIMARY_KEY_INDEXABLE

ECD_LIST_INDEX

Eco-DB storable arrayed list index

ECD_PRIMARY_KEY_INDEXABLE

Assigns values to storable items conforming to EL_KEY_IDENTIFIABLE_STORABLE, and augments classes ECD_ARRAYED_LIST and ECD_REFLECTIVE_ARRAYED_LIST with a primary key index.

Further Information

Click on class link to see instructions.

reader-writer

ECD_ENCRYPTABLE_MULTI_TYPE_READER_WRITER

Eco-DB encryptable multi type file reader writer

ECD_ENCRYPTABLE_READER_WRITER

Eco-DB encryptable file reader writer

ECD_MULTI_TYPE_READER_WRITER

Eco-DB file reader/writer for storing types conforming to types EL_STORABLE

ECD_READER_WRITER

Eco-DB file reader writer

Further Information

Click on class link to see descendants.