The main idea of DALE is very simple: to allow the access to relational databases as simple and flexible as possible. In fact there are objectives in the design of our cluster. First objective of the class design is the seamless transition between the "object world" of Eiffel and the "table world" of RDBMS (relational databases). This allows the design of very readable and maintainable systems without big effort.
Second, it should be possible to access the Database in a flexible but not necessary object-oriented way. This gives users the same possibilities as in other languages - but not more. In each case the starting point of all applications written with DALE is the database, i.e. if you want to make a new design, design the database at first and let the wizards help you in writing your classes. This approach was chosen for some different reasons:
These are three basic principles of DALE:
Power and flexibility. Being object-oriented presentation of ODBC, DALE acquired all the power and flexibility of ODBC. On the other hand, DALE is not only the Eiffel interface of ODBC API; it also extends functional possibilities of ODBC, hiding as many extra code from application developer as possible. Besides, it is possible in DALE to use native functionality of a data source that is not supported by ODBC.
Simplicity. It means not only the simplicity of code solving a given task, but also the easyness for application developers to find out how to write that code. Although DALE allows to solve every task that ODBC can, you're free of learning an extra feature. The common rule is: the ordinary a problem, the simplier a solution. For example, you can fulfill such sequence of operations as creating and sending of a query and recieving results in four different ways in depend on what do you have and what do you want. In accordance with the rule above, you can know only the simplest one and use it until you realize that you need something more.
Open architecture. It is possible to not only create finished applications on the basic of DALE. For advanced applications and groups of applications it would be worth while to define some intermediate abstractions for database objects that are in use and DALE allows it. For example, DALE contains such classes as DB_TABLE and RECORD presenting a notion of the database table and table's record respectively. You can define two new problem-oriented abstractions for them, for example, PEOPLE and PERSON adding new features, for example, the validation of record integrity into PERSON, etc.
Following the good traditions it seems worth finishing the brief acquaintance with DALE by something like the "Hello, world!" sample. Let us have the database WORLD containing in particular the COUNTRY table. Each country is primarily described by its name. Our purpose is to display names of all countries in the world:
database: DATABASE -- the WORLD database table : DB_TABLE -- the COUNTRY table of the WORLD database cursor : RS_CURSOR -- cursor to traverse COUNTRY's records ... -- establish a connection to the WORLD database with user name -- "admin" and password "sim-sim": !!database.connect ("WORLD", "admin", "sim-sim") -- obtain table COUNTRY and open it: table := database.table ("COUNTRY") -- travel through all records in the table: from cursor := table.cursor -- obtain cursor for the table until cursor.is_finished -- for all the records loop -- display the "name" field: display_string (table.field (cursor, "name").to_string) -- go to the next record: cursor.forth end table.close -- disconnect from the data source: database.disconnect