Previous Up Next

2  Define a simple Entity-Relationship notation



Exercise 1: The task is to define two classes EntityType and RelationshipType. The class RelationshipType shall have an attribute role with value EntityType.



EntityType end

RelationshipType with
  attribute
     role: EntityType
end

Enter the definitions into the Telos Editor window and store them to the ConceptBase server with the "Tell" function.



Exercise 2: Add to EntityType an attribute attr with value Domain. Also define Domain as an object without attributes.



EntityType with
  attribute
    attr: Domain
end

Domain end

This provides us with a very simple entity-relationship language. It just allows to define entity types with attributes, and relationship types with role links. Entity attributes are restristed to domains. So we need to specify the allowed domains.



Exercise 3: Specify Integer and String as domains, i.e. as instances of the class Domain.



Integer in Domain end
String in Domain end

The classes Integer and String are predefined in ConceptBase. Any integer number occurring in an object definition will automatically be an instance of Integer. Likewise any double-quoted string will be regarded as an instance of String.



Exercise 4: Specify a new domain Date. Include "2009-05-19" and "2001-01-01" as two possible values for dates.



Date in Domain end
"2009-05-19" in Date end
"2001-01-01" in Date end

The object Date is not predefined in ConceptBase. Hence, we need to take care ourselves about the set of possible values (=instances of Date).

After these exercises, you can visualize the current state with the graph editor. User RelationshipType as start object. The graph editor is started from CBIva via the menu item "Browse / Graph Editor". Expand the outgoing attributes of RelationshipType (right mouse button) and select "Show all". Do the same with EntityType. For Domain, show the instances. For Date, show the instances as well.


Figure 2: Graphical display of the ER language

The graph window shows already three abstraction levels: the objects "2009-05-19" and "2001-01-01" are at the lowest abstraction level (data level). The objects Date, Integer, and String are classes (model level), and the objects RelationshipType, EntityType, and Domain are meta classes (notation level).





Previous Up Next