OOFILE | Downloads | Purchasing | Press | Services | Company Information | Soapbox | References | F.A.Q. | HOME |
This document is your starting point in using OOFILE, if you know a bit about database concepts.
If you don't know much about databases, you should first read Database Concepts for an introduction to database concepts, and how they map to OOFILE
See also:
- Installation to install OOFILE, the samples and
c-tree.
- The example programs that illustrate one key
concept each.
- The feature index for a full list of the currently
available features
1) #include "oofile.h"
2) declare your database tables,
ie: DECLARE_CLASS(myTable)...
3) define a database "connection" variable, eg:
dbConnect_ctree myDatabase
4) (MUST be after 3) in your code) - define table variables, eg:
myTable aTableInTheConnection;
5) create or open a database connection, eg:
myDatabase.createConnection("a file on disk");
DECLARE_CLASS(dbPatients)
dbPatients() :
{};
};
// declaring the concrete variables
dbConnect_ctree theDatabase;
dbPatients Patients;
int main() {
}
One of the big features of an ODBMS is modelling the relationships between objects. OOFILE allows you to model relations in a pure ODBMS sense, using object identifiers, or explicitly perform runtime joins over database fields. This would be mainly used by people porting existing database structures.
EXTRA STEPS IN CREATING RELATIONSHIPS
6) Declare the classes that traverse the relationship, eg:
DECLARE_REF(dbPatients) declares a Ref which refers to just one Patient
7) Include a member in each table for the relationships, eg in Visits:
dbPatientsRef Patient;
8) *After* defining the variables for the tables (see point 4) define a dbRelationship for each relationship, that says which tables are related.
The following example extends our first effort and adds a related table with a 1-N relationship between Patients and Visits:
DECLARE_REF(dbPatients)
DECLARE_SET(dbVisits)
DECLARE_CLASS(dbPatients)
dbPatients() :
};
DECLARE_CLASS(dbVisits)
dbVisits() :
};
// declaring the concrete variables
dbConnect_ctree theDatabase;
dbPatients Patients;
dbVisits Visits;
dbRelationship(Patients.Visits, Visits.Patient);
int main() {
}
Copy the OOFTest project and try building each of the different sample programs. Vary some of the operations slightly, eg: change the search criteria in tests 1, 7 & 12 to get different records returned.
Write down a simple database schema, eg: an Address book, and try to write the OOFILE class declaration.
Once you have your database schema compiling, add some data and dump out the database to the console (see test 1).
Write a few simple search expressions for your database, using inline constants, and dump the results (see tests 1, 7, & 12).
Take your search expressions and change the constants to variables. Put your search inside a loop and display the results to the console, so you can read in different search values and see the results. (test 7 has some searches using variables, inside methods)
Add a related table to your database (if you will be using relationships) and try adding and deleting child records. (see tests 2, 6 & 9)
Look at the first version of FileAndFind. Try adding an edit field to the dialog, which is linked to a new dbChar field in the database. (Note: if you change the database schema, you are not currently able to open old databases.)
Change the FileAndFind browse window to display a different set of fields.
Mac AppMaker users:
Take the FileAndFind example AppMaker project, and add a couple of extra editing
fields, linked to the database. Try generating and running the result.
Compose a simple application yourself, with just a few editable fields. Add OOFILE declarations of the data and link the fields to the database. It will probably be easier to build a little console application like our samples, to enter and dump the test data, without the complications of debugging your GUI.
(c) Copyright A.D. Software 1994-2003 (All Rights Reserved).
Last Updated: 5th May 2003