8 –Framework for an Object Database Design
8.1 Basic Object Database Framework
8.1.1 Data Requirements of Framework
The framework objects and their instances are related in a number of ways. The following is a description and figure 8.1 contains an EERM that depicts these.
Each instance of a class and structure has many attributes while an attribute must be related to only one instance of a class or a structure. Also some instances of a class are related by a specialisation relationship; but a class instance can only have at most one ancestor. Each attribute has a signature that includes name, cardinalities and return type details. The
Framework for an Object Database - [ 176]
return types can be any one of the following: a class, a structure, a basic domain, and an enumerated domain.
A constraint is specialised into primary key (marked PK in figure 8.1), functional dependence (marked FD), referential constraint (binary and no attributes – marked RC ODMG), and referential constraint (other than binary with no attributes – marked RC). This EERM ISA
relation is disjoint and total.
The primary key constraint instances are related to attributes through a one-to-many (but all attributes must be from the same class or structure).
Either referential constraint is composed of exclusive elements that represent each degree. For example a binary relationship has two element components whereas a ternary has three.
If the referential constraint is binary and without attributes (i.e. RC ODMG) then each element is related to a class attribute (i.e. the foreign key) and a relationship to the class it is pointing to. Each element has properties for its cardinalities range, lower and upper limits, and an arbitrary sequential number.
In the case of a binary referential constraint (i.e. RC) element (other than binary with no attributes) they are related by structures through a many-to-one relationship and also have two additional details. The first is the attribute in the structure that is a foreign key and the second is to which class or structure it is pointing to. Also each element has its cardinalities range, lower and upper limits, and an arbitrary sequential number.
In the case of an n-ary referential constraint with attributes the entity (i.e. RC) is related with a weak relationship to many attribute signatures.
The functional dependence (i.e. FD) between attributes is implemented with a many-to-many relationship adorned with an attribute that indicates whether each attribute is on the left or right of a functional dependence.
8.1.2 Logic Programming
Logic programming, based on the resolution inference, is available in Flora-2. The following example highlights its use to develop our object-database framework. As an example, an implementation of an integrity check denial is described; the constraint deals with our
Framework for an Object Database - [ 177]
insistence that any instance of a class has to be an instance of at most one class. The main part of the denial checks for an object instance (?I) being related (i.e. by “:”) to two objects.
The latter objects are distinct class instances and are not related through the ISA relationship (i.e. “::”). If such instances exist then the method collects and reports them and finally fails.
ATTRIBUTE (SIGNATURE) Aname Lower L Upper L CLASS ISA 1 N Cname HAS STRUCTURE Sname U 1 1 N DOMAIN EM. DOMAIN RETURN U N 1 1 1 1 CONSTRAINT d RC (ODMG) RC FD PK ELEMENT (STRUCTURE) ELEMENT HAS HAS HAS 1 1 N N N N 1 1 RETURN RETURN N N 1 1 HAS PART 1 N HAS PART 1 N HAS Direction HAS N 1 HAS N 1
Figure 8.1 – High-level Data relationships for Object Database Framework constraint[%ic_schema_no_mio]:-
write('-- ic schema no multiple instance-of ')@_prolog, writeln('relationships for instances of classes:')@_prolog,
?C1:class, ?C2:class, ?C1!=?C2, not(?C1::?C2), not(?C2::?C1), if (?I:?C1, ?I:?C2)
then (?L=collectset{?I | ?C1:class,?C2:class, ?C1!=?C2,
not(?C1::?C2), not(?C2::?C1), ?I:?C1, ?I:?C2 }, writeln('IC Broken! Problem with: ')@_prolog,
writeln(?L)@_prolog, false)
else (writeln('OK!')@_prolog).
The following session script shows how one can use this method to sift out such instances.
andy:ptstudent. Remark object andy is an instance of andy:unit. Remark ptstudent and unit
javaprog:project. javaprog:unit.
?- constraint[%ic_schema_no_mio].
-- ic schema no multiple instance-of relationships for class instances: IC Broken! Problem with:
[andy, javaprog] No.
Framework for an Object Database - [ 178]
8.2 Schema in F-logic
An example schema is required to encode in the object database framework. The application domain deals with a university setup that caters for courses and projects. Colloquially we call this schema ‘afterScott’. The main requirements follow and a graphical interpretation is in figure 8.2.
The main players are lecturers, students and part-time students. These are related with two disjoint and partial ISA relationships. Also each person has a set of communication lines but some communication lines can be unassigned. Each lecturer can have a number of degrees. A project is composed of a number of jobs and each job has a budget. Project instances have a number of relationships: a lecturer can lead a number of projects and each must have one leader; each project can have a number of persons working on it and conversely a person can work on many projects; some projects are a continuation of other projects.
The university is split into departments and each department has a number of lecturers but each lecturer works in one department. A department has an exclusive address. Each department can co-sponsor, with other departments, a number of courses for students to enrol on. Each student can enrol in one course at a time. It is expected that many students enrol on a course. Also a course has a number of units that students are required to take up and a unit is included in many courses. Each unit has one coordinator, a lecturer, but many lecturers can be involved in teaching it from year to year.
Every student’s performance for a transcript is to be kept: that’s a student registers for many units and a unit is taken by many students. For each registration the grade awarded is recorded.