layer(s): 2, 3, 4, 5, 6, 7 header file(s): z_dbsubs.h, z_dbconnection.h, z_dbbi.h, z_orthodox.h, z_orthodb_set.h synopsis.
The SQL group is a large part of the Z Directory. It contains components to access a relational database management system. The Z Directory does not contain a database - that part of computer software has been adequately handled by many others. But the Z Directory needs a database in order to be effective. Although a large part of the Z Directory is independent from databases, without a supporting database, one loses a significant part of the capabilities of the Z Directory system. Most of the sql group lays the groundwork for more powerful constructs at higher layers that eventually culminate in allowing you to create your own classes that you can readily save to a database:
* dbconnection: the [layer 2] foundation for class for accessing a database. If you are just starting to become familiar wiTH the Z Directory, this class object may be a good place to start, since with it you can do basic database operations, such as create database connections and execute simple SQL statements. * DBBI (DataBase - dataBag Interface) ("Debbie"): an important [layer 4] class that handles all interaction between your code and a database; * the orthodox object - the foundation for many higher-level classes that can save themselves to a database. You make a subclass from the orthodox class to be able to use such general-purpose functionality.classes in this group: dbconnection_o [L02], dbtable_o [L05], dbbi_o [L04], orthodox_o [L06], orthodb_set_o [L07], oid_o [L00] function groups:
layer 03 functions group
layer 05 functions group description.
As mentioned in the synopsis, the database classes and functions available in the Z Directory require an external database. Access to a database is implemented via ADO (Microsoft platforms only), or ODBC (all supported platforms). On a Microsoft OS, the Active-X Data Object system provides a very seamless, transparent database access. It is particularly well suited to SQL Server databases. For ODBC, you would need to pre-configure an ODBC connection. How to do this is external to the scope of this support section. Once configured, you need just the ODBC connection name, user account and password, passed as parameter-settings to configure objects in the sql group of the Z Directory. No special libraries are required to the link process when developing your programs when you access an external database via ADO or ODBC. On platforms where either method is available (eg Microsoft), you can dynamically switch between access methods. Generally, a Z Directory sql group object supports only one access method at any given moment. The database components of the Z Directory form a "stack" model, much like the OSI network stack:
|Z Directory SQL Object Model|
|7+||[user-defined]||application-ready, usable objects: business_o, worker_o, postal_address_o|
|6||orthodox_o||defines orthodox object protocols|
|5||dbtable_o||object to manage database tables|
|ADO, ODBC||4||dbbi_o||databag-to-database interface|
|2, 3||DB subroutines, dbconnection_o||direct database interfaces|
|N.A.||DATABASE||external systems, such as Oracle or mySQL: it provides actual disk storage|
The oid_o class is a subsidiary component that serves the orthodox object. It is a very simple object, maintaining 2 IDs (of 'countable" type, ie count_t). It manages the object's ID. This is complicated by the fact that an object can map onto rows in database tables. The ID values of the object's database image can and usually do differ from the local copy. Thus, this class maintains these 2 IDs, called the internal and external ID. This is more fully discussed in the orthodox class . examples.
You can find examples how to do simple, low-level SQL statements in the dbconnection object . On the other hand, you can find examples of how to create objects that can store and retrieve themselves into or out of a database via the orthodox object . For a rich set of objects derived from the orthodox object, visit the "people" group . Classes such as business , worker , and person are all direct subclasses of the orthodox_o class. They provide fully working examples of how the orthodox_o class is used, as well as their own functionality.