Ogre provides the following functions:
For example, consider a military database with the following tables, which have been generated from an Oracle session:
|
|
||||
|
|
|
|
LOCATION FORCES ---------------- ------ peninsula red foothills blue plains blue |
It is not required that the same attribute names be used in the objects Ogre creates as were used in the relations. Ogre allows the user to rename the attributes. In some cases, renaming is necessary, as ambiguity would otherwise result. Ogre provides visual indications of those cases.
We now present the relational-to-object mapping in two steps. The first step is the mapping of a single relation to objects. The second step is a mapping of multiple relations, sharing common attributes, to objects.
Mapping a Single Table to Objects
For example, suppose our table is
Then the schema will consist of
and the corresponding set of objects
will be:
Each object also has a schema attribute which is not shown
above. The name of the schema is system-generated, although it can be
set by the Ogre user.
One or more attributes in a row of a table may have unspecified values,
formally known as NULL values. By design, Ogre does not create attribute-value
pairs for such attributes, since part of the motivation is to allow condensed
representation of data in which the tables are fairly sparse.
For example, in the Location table presented earlier,
the location of division 4 is NULL, representing unknown. If this relation
were converted to objects, only three of the objects would have a value for
attribute LOCATION. The fourth object would be created, but would not
have an attribute LOCATION.
Clearly our model is only one possible model which
could be used. For example, another model would preserve the attribute
in all objects, but create some kind of NULL value for the attribute in
the object. As part of our objective is to reduce the space required
for sparse relations (ones in which NULL's are frequent), we chose the
current model.
Mapping Multiple Tables to Objects
A degenerate form of mapping for multiple tables
would involve simply repeating
the above single-table relation mapping once for each
relation. However, this may not capture the intent of the original
relational database. Typically relational databases
distribute the description of
single objects over multiple tables (through a design process known as
"normalization"), and the attribute values of one or
more tables would then be linked. We would like to recapture those
linkages in creating objects.
As the exact nature of the linkage cannot be inferred from the tables alone,
it is up to the user to specify the linkage, using Ogre's GUI.
Suppose there are two tables R and S with a common column attribute A and
we intend that rows of R and S having the same value of A really designate
the same object. We can indicate this intention in Ogre's GUI by making
a connection between nodes representing these attributes.
In relational database terminology, this is conceptually a
join of
the two tables.
For example, consider the two tables which have a common attribute DIVISION:
Identifying the attributes DIVISION in the two tables, Ogre could create the
following more comprehensive objects:
Ogre makes it possible to link any number of relations in this way. When
the linkages describe the user's desired
interpretation of the relations as objects,
Ogre will present a query to the relational database to extract that
information. Ogre will then generate the corresponding objects.
The user also can inspect both the original relations and the resulting objects
using the GUI.
DIVISION TYPE QUANTITY
-------- ------------ ----------
1 armor 20
2 mechanized infantry 100
3 infantry 500
4 armor 30
id: ob1
division: 1
type: armor
quantity: 20
id: ob2
division: 2
type: mechanized infantry
quantity: 100
id: ob3
division: 3
type: infantry
quantity: 500
id: ob4
division: 3
type: armor
quantity: 30
Note that each object has been given an id for the system, which
uniquely identifies that object.
DIVISION LOCATION
-------- ---------
1 peninsula
2 foothills
3 plains
4
DIVISION CO
-------- --------
1 Jones
2 Smith
3 Thomas
4 Williams
DIVISION TYPE QUANTITY
-------- ------------ ----------
1 armor 20
2 mechanized infantry 100
3 infantry 500
4 armor 30
id: ob1
co: Jones
division: 1
type: armor
quantity: 20
id: ob2
co: Smith
division: 2
type: mechanized infantry
quantity: 100
id: ob3
co: Thomas
division: 3
type: infantry
quantity: 500
id: ob4
co: Williams
division: 3
type: armor
quantity: 30
Using Ogre
Currently Ogre runs on the Sparcstation jake.jpl.nasa.gov, and is configured
to access a sample
database derived as an excerpt of the ASAS database.
Currently Ogre only runs on this database, which is an excerpt of the full ASAS
database, with other test relations added.
If we then click View, we will get a window for each relation chosen. For example, the window for relation DIVISION might show as follows:
cd ~keller/ogre.os
go

If we click Load, we will get the following display:

At this point, we may choose to move the relations to suit our taste. To move an entire relation, with its attributes attached, double-click with the right mouse button to highlight the relation, then drag with the left mouse-button. Moving the CONTROLLED_BY and LOCATION relations results in the following display:

Attributes can be unlinked by clicking the left mouse button over the box. One then has a choice of:
Note that when a linkage is made, if there are other attributes with common names, these will be highlighted, since they are regarded as conflicting. In other words, attempting to create objects using this naming scheme would cause ambiguities. These ambiguities must be resolved before Ogre will allow objects to be created.
In our example, suppose we consider attribute DIVISION to be the same in the COMMANDER and DIVISION relations. We can join these two attributes. First we drag (using the middle mouse button) the DIVISION attribute of COMMANDER away from the relation to distinguish it. Then we drag (using the right button) of the DIVISION attribute of DIVISION atop the DIVISION attribute of COMMANDER. Using the right button, rather than the middle one, tells Ogre that we wish to join the two relations on that attribute. The window would now appear as follows:


Note that it is considered an error to drag with the right mouse button when no linking of attributes is intended. If the user does this, the following dialog will appear, until dismissed:

Once the relations are properly linked to suit the user, objects may be created. There will be one type of object for each connected sub-graph in the window. In the present example, there is only one sub-graph, so there will be one object type. There will be one attribute of the object for each distinct attribute showing in the window. The set of attributes of an object is referred to as the Schema. Thus the number of schemas also corresponds to the number of connected sub-graphs. By clicking the Schemas button at the top of the window, a list of current schemas and their attributes will be shown. The system will add one attribute to each schema which names the schema. (This system-generated name can be changed by the user.) For the current example, opening the Schemas window produces something like the following, where the actual schema name will depend on prior activities:

To add objects to the current Grok database, the user clicks Get Objects. If the GrokDB window is open, the objects created will appear in the window, as shown:

Addition to the Grok database is cumulative. If the user reconfigures the window, e.g. by removing some relations and bring in others, then clicks Get Objects, those objects will be added to the database.
Note that it is possible to create ambiguous schemas if two relations are
linked but have one or more pairs of attributes with the same name.
This would be tantamount to creating an object with having two attributes
of the same name, which would not be helpful.
In this event, the boxes of the identical attributes in question are
highlighted in red. These should be either joined or one attribute
renamed before proceeding. Ogre will not generate objects until the
ambiguity is resolved.
Constraining the Selection of table entries
The user may add constraints to the selections from tables used to create
objects. These are expressed graphically, but translate into SQL
selection conditions.
Examples are:
The structure of grokDB is quite simple: Each object is represented as a list of attribute-value pairs. The list is open-ended, rather than being a fixed schema, so that new pairs can be added after an object is initially created, and existing pairs can be removed.
Because of Polya's generality, the values and attributes can even be list structured themselves. While Ogre does not currently generate databases which exploit this feature, the feature might be useful for adding additional structure later on.
Type Poly is a polymorphic object, one which can be either a string, an integer, a float, or a list of Polys. A LID (logical id) is a Poly used as the identifier of an object. Every object in a grokDB has a unique LID.
Methods and Constructors for Grok Databases
 
 
Methods for Grok Objects
//
// IDL for grokDB
//
module GROK
{
// These are the supported variants of a Poly,
// the type of object from which a GrokDB is constructed
enum Polytype {Long, Double, String, List};
// This defines a Poly
union Poly
switch(Polytype)
{
case Long: long nv;
case Double: double dv;
case String: string sv;
case List: sequence<Poly> lv;
};
// This defines an object in a Grok database
struct grokObject
{
Poly id;
sequence<Poly> pairs;
};
// This defines the available transactions for a Grok database
interface grokDB
{
// Create a new object with a given id
void newObject(in Poly id);
// Create a new object with a system-generated id
void newOb();
// Add an attribute-value pair to an object
void add(in Poly id, in Poly attr, in Poly value);
// Get the value corresponding to a particular attribute
Poly get(in Poly id, in Poly attr);
// Drop the specified object from the database
void drop(in Poly id);
// Exception raised when a specified object doesn't exist
exception noSuchObject{};
};
};
The authors wish to thank Lamark Johnson for his advice on use of ObjectStore and its installation, and Dr. Bill Lincoln for his assistance with Grok and compiler installation. The advice and steering of James Hauge and Dr. Nevin Bryant were invaluable throughout the project.
If the mouse is not pointing to any item, drag to scroll the canvas.
Note: If no joining is actually done when this button is used, an error dialog will appear to warn the user that no connection was actually made.