Michael Erdmann
January 16, 2000 - 15:49
Status: Incomplete
This document describes the organization of the ACDE data base. The Database is based upon the MySQL product. This document describes the tables in detail and the access methods used for these tables.
The ACDE is based upon the data bases product MySQL. This is realtional data base with an SQL like query language. For support of this environement the following package are available:
Database interface |
|
SQL helper package |
DB/sql.ads |
Databse base class |
DB/dbelement.ads |
For each object to managed in the ACDE a component does exist which hides the interface to the SQL database. The priciple is quite simple. An abstract base class for all data base related objects has been defined which requieres the implementation of the store/delete and get code. Key values are supplied to the implementation by means of attribute functions. The object may be loaded/stores or deleted by applying a procedure from the base class. This mehthod hopefully ensures an implementation independant from the data base system.
In order to seperate the ACDE implementation from the data base part, a base class for all database objects has been defined. Towards the application it provides an interface, which does not depend on the underlying data base. In direxction of the data base system three procedues (store/delete/get) are required by the implementation of an data base object. These procedures do depend on the implementation of the underlying database system.
The class provides the following interface:
Element Name |
Comment | ||
---|---|---|---|
Class Name |
DbElement |
DbElement.Object DbElement.Handle | |
Attributes |
Data_Base::DB.Object |
public |
The Database object identifies the associated data base. |
Is_Valid::Boolean |
public |
Indicates, that the object contains valid data. | |
Set_Modified this : in out Object |
public |
The instance will be marked as modified | |
Methods |
Initialize this : in out Object'Class |
public |
Initialite the object and set the debugging support object. |
Finalize this : in out Object'Class |
public |
The object will be finalized. | |
this : in out Object'Class |
public |
Update the object in the data base and inform all depending objects. | |
Load this : in out Object'Class |
public |
load the object from a data base an inform all depending objects (see Watch ) | |
Delete this : in out Object'Class |
public |
Delete the object in the data base | |
this : in out Object'Class |
public |
Add a update handler to the object. Upon execution of the Update method the data is stored and the list of all update handlers is called to inform other db-objects about the change. | |
Load_Query this : in Object |
abstract |
This method has to implement the sql query to load all data of the object based upon the key values set via the implementations attribute functions. | |
Store_Query this : in Object |
abstract |
This method has to implement the sql query to store all data of the object based upon the key values set via the implementations attribute functions. It is assumed, if the tuple is not peresent in the data base it will be created. | |
Delete_Query this : in Object |
abstract |
This method has to implement the sql query to delete all data of the object based upon the key values set via the implementations attribute functions. |
The life cycle of a typical data base object will most likely look as below:
Step 1. Create an instance
Step 2. Add the object to a database
Step 3. load the instance from the database
Step 4. Use the data / update
Step 5. Update the data in the database
.. go back to 4
Step 6. If desired the object is deleted by deleting it.
Instance creation of an data base object may be done by exp. specifying the data base object or simply leaving is empty.
item : User.Object( dbase ); ... Initialize( item, debug ); -- This step is done only if during instanciation, the dabase has not been referenced. Data_Base( Item, dbase );
Loading instance data from data base is done by first setting the requiered key attributes of the object and then issuing the Load method. In order to verify that the object has been loaded completly, the status of the object has to be verified by means of the Is_valid attribute,
Name( item, "erdmann" ); .... Load( item ); if not Is_Valid( item ) then ... error handling .. end if;
After the object has been manipulated, the data in the database may be updated/delete by means of the Update method.
Update( item ); or Delete( item ); ... Finalize( item );
A help full mechanism to keep dependent information upto date is the Watch feature. If an instance is updated, a list of procedures is processed which has been added to the object by means of the watch method. Each procedure is called with the following arguments:
procedure( source : in Object'Class; target : in Handle );
Where source is the changed object and target is the handle of the object which may depend on this object. The prcoedure may access the data of the source object by attribute functions to interrogate the changed data.
The userlist table contains all users of the ACDE environement and their basic properties. There are no consitency rules to other tables known.
Domain |
Datatype |
Descriptiom |
---|---|---|
username |
NAME |
login name of the user |
password |
char(20) |
password of the user |
first_name |
NAME |
first part of the name |
last_name |
NAME |
last part of the name |
org_unit |
NAME |
org. Unit |
phone |
PHONE_NUMBER |
Phone number |
location |
NAME |
location |
|
EMAIL_ADDRESS |
email Address |
transaction |
Integer |
transaction identifier for this user. This domain is set by the CGI base process and should not be set by an application. |
This section contains the table of all files and there purpose which are related to the databse of the ACDE. The path is taken relative to the ACDE source root directory:
Name |
Description |
Path |
---|---|---|
common.sql |
Contains the man data types used for the implementation of tables. This is an m4 preprocessor file. |
./DB |
T_userlist.sql |
Defintion file for the user list table |
./DB |
userlist.ads |
Defintion of userlist table for Ada95 applications |
./DB |
T_project.sql |
Defintion of the project table |
./DB |
projectlist.ads |
Ada 95 interface for the project table |
./DB |
T_role.sql |
Role table |
./DB |
rolelist.ads |
Ada 95 interface for T_role |
./DB |
T_role_names.sql |
Table of allowed role names |
./DB |
role_names.ads |
Ada 95 interface to role_names |
./DB |
dbelement.ads |
Database object base class |
./DB |
user.adb |
User data base object |
./DB |
project.adb |
Project data base object |
./DB |
db_config.def |
Database configuration part |
./DB |
Makefile.db |
Makefile |
./DB |
The database of test system may always deleted and rebuild by using the following make file commands in ./DB:
make cleandb make newdb
The target cleandb deletes the whole ACDE database. Currently no tables are saved! After building newdb check always the contents of the *.log files for all tables.
The configuration file db_config.def contains a data base section.
[db] serverUser=ACDE_USER server=SERVER ....
Constants are defined in the common.sql file.
Parameter |
Constant in Common.sql |
Description |
---|---|---|
serverUser |
ACDE_USER |
The user name which is used to connect to the MySQL server |
server |
SERVER |
Name of the data base server. |