[[Property:title|EiffelStore Implementation Layer]]
[[Property:weight|1]]
[[Property:uuid|80cd0938-6837-3c17-8515-b4ac60a51d09]]
Each interface class has an implementation counterpart that implements specific DBMS handling. The class prefix indicates clearly its layer, for instance:
* [[ref:/libraries/store/reference/db_selection_flatshort|DB_SELECTION]]  is the interface to perform a database selection query.
* [[ref:/libraries/store/reference/database_selection_flatshort|DATABASE_SELECTION]]  [ [[ref:/libraries/store/reference/database_flatshort|DATABASE]] ] is its implementation. 

The abstract [[ref:/libraries/store/reference/database_flatshort|DATABASE]]  class represents a DBMS, i.e. it is the Eiffel-side database call interface. It is inherited for instance by the instantiable <eiffel>ORACLE</eiffel> and <eiffel>ODBC</eiffel> classes.

EiffelStore enables to link common interface objects with database-specific implementation objects using a '''handle'''. This handle also enables to switch between different databases. 

Let us see in 4 steps how EiffelStore implements this handle system: 

==The active database handle==

The <eiffel>HANDLE_USE </eiffel>class provides access to the unique <eiffel>HANDLE</eiffel> instance. This object stores all the information about the active database, mainly:
* Database login information:
<code>
    login: LOGIN [DATABASE]
            -- Session login
</code>

* Database status information:
<code>
    status: DB_STATUS
            -- Status of active database
</code>


==Association between interface and implementation==

The association between an interface object and its implementation counterpart is done at the interface object creation.

Every interface class inherits from the <eiffel>HANDLE_USE</eiffel> class and can access the active database handle. This handle contains a <eiffel>DB</eiffel> [<eiffel>DATABASE</eiffel>] object that provides implementation objects corresponding to every interface objects.

The creation procedure for a <eiffel>DB_CHANGE</eiffel> object is for instance:
<code>
    make
            -- Create an interface object to change active base.
        do
            implementation := handle.database.db_change
            create ht.make (name_table_size)
            implementation.set_ht (ht)
        end
</code>

==Access to the DBMS call interface==

Every implementation class can access the active database call interface by inheriting from the <eiffel>HANDLE_SPEC</eiffel> [<eiffel>DATABASE</eiffel>] class. This class provides access to the <eiffel>DATABASE</eiffel> object, i.e. an instance of class ORACLE or ODBC.

<eiffel>DATABASE </eiffel>descendants are actually wrappers for the DBMS call interfaces written in C. More precisely, call interfaces as delivered by the DBMS companies are called in an EiffelStore C library. The C libraries are then wrapped into Eiffel classes, <eiffel>DATABASE</eiffel> descendants.

==Active database selection==

As seen in the [[Database Connection|interface connection]]  part, active database selection is performed by the {<eiffel>DATABASE_APPL</eiffel>}.<eiffel>set_base</eiffel> feature: when a <eiffel>DATABASE_APPL</eiffel> object calls set_base, database represented by this object is activated. 

Let us give some details about the set_base feature:
* Database call interface global reference is updated through {<eiffel>HANDLE_SPEC</eiffel>}.<eiffel>update_handle</eiffel>.
* All information about the database is set to the handle, mainly: 
** Login information.
** Status information. 

{{note|When database is inactive, its information is stored in the <eiffel>DATABASE_APPL</eiffel> object. }}


The corresponding code looks like:
<code>
    session_status: DB_STATUS
            -- A session management object reference.

                ...

            set_base
                ...
            update_handle
            if session_status = Void then
                create session_status.make
            end
            handle.set_status (session_status)
		...
</code>

{{seealso|<br/>
[[EiffelStore Interface Layer|The interface layer]]  <br/>
}}





