next up previous contents
Next: The ConceptBase Server Up: The O-Telos Language in Previous: Query evaluation strategies

The View Language CBVL

 

The view language of ConceptBase is a natural extension of the ConceptBase Query Language CBQL. Besides some extensions that allow an easier definition of queries, views can also be nested to express n-ary relationships between objects.

The system class View is defined as follows:

Class View isA GenericQueryClass with
attribute
    inherited_attribute : Proposition;
    partof : SubView
end

Attributes of the category inherited_attribute are similar to retrieved attributes of query classes, but they are not necessary for answer objects of the views, i.e. an object has not to instantiate the attribute to be a solution of the view.

The partof attribute allows the definition of complex nested views, i.e. attribute values are not only simple object names, they can also represent complex objects with attributes. The following view retrieves all employees with their departments, and attaches the head attribute to the departments.

View EmpDept isA Employee with
retrieved_attribute, partof
    dept : Department with
        retrieved_attribute
            head : Manager
    end
end

As the example shows, the definition of a complex view is straightforward: for the ``inner'' frame the same syntax is used as for the outer frames. The answers of this view are represented in the same way, e.g.

John in EmpDept with
dept
    JohnsDept : Production with
        head
            ProdHead : Phil
    end
end

Max in EmpDept with
dept
    MaxsDept : Research with
        head
            ResHead : Mary
    end
end

To make the definition of views easier, we allow some shortcuts in the view definition for the classes of attributes.

For example, if you want all employees who work in the same departments as John, you can use the term John.dept instead of Department. In general, the term object.attrcat refers to the set of attribute values of object in the attribute category attrcat. This path expressions may be extended to any length, e.g. John.dept.head refers to all managers of departments in which John is working.

A second shortcut is the explicit enumeration of allowed attribute values. The following view retrieves all employees, who work in the same department as John, and earn 10000, 15000 or 20000 Euro.

View EmpDept2 isA Employee with
retrieved_attribute
    dept : John.dept;
    salary : [10000,15000,20000]
end

As mentioned before, ``inner'' frames use the same syntax as normal frames. You can also specify constraints in inner frames which refer to the object of an outer frame.

View EmpDept_likes_head isA Employee with
retrieved_attribute,partof
    dept : Department with
        retrieved_attribute, partof
            head : Manager with
                constraint c : $ A(this,likes,this::dept::head) $
        end
    end
end

The rule for using the variable ``this'' in nested views is, that it always refers the object of the main view, in this case an employee. Objects of the nested views can be referred by this::label where label is the corresponding attribute name of the nested view. In the example, we want to express that the employees must like their bosses. Because the inner view for managers is already part of the nested view for departments we must use the double colon twice: this::dept refers to the departments and this::dept::head refers to the managers.

If you reload the definition of a view into the Telos Editor, the complex structure of it is lost. During compilation of the view, the view is translated into several classes and some additional contraints are generated, so the resulting objects might look quite strange if you reload them.


next up previous contents
Next: The ConceptBase Server Up: The O-Telos Language in Previous: Query evaluation strategies

ConceptBase Team