:ADD-RELATION
Purpose
Creates a new relation (called a slot or property in some KBMS).
The user can optionally specify properties of the relation such as
maximum cardinality and a default value.
Parameters
- name
- The name of the new relation.
- (domain-class range)
- The domain and range (also called from
and to) of the relation.
- :MIN-CARDINALITY (optional, default 0)
- Specifies the minimum cardinality of the relation (how
many values it can hold). The default is zero, which
means that the relation is not required for a frame.
- :MAX-CARDINALITY (optional, default 1)
- Specifies the maximum cardinality of the relation (how
many values it can hold). The default is one. Use :ANY to
specify unlimited maximum cardinality.
- :DEFAULT (optional, default is none)
- Specifies the default value of the relation which is
stored in new instances of the relation if a value is
not given when the relation instance is created.
- :INVERSE (optional, default is none)
- Specifies the name of the inverse of this relation.
In most KBMS, when a relation is created from frame A to
frame B, its inverse is also automatically created from
frame B to frame A. The inverse relation must already
be created.
Examples
(:ADD-RELATION Color (Physical_Objects Colors))
(:ADD-RELATION Length (Physical_Objects :INTEGER))
(:ADD-RELATION Pet (Humans Animals) :MAX-CARDINALITY 10 :DEFAULT Rover :INVERSE OwnedBy)
(:ADD-RELATION Friend (Humans Humans) :MAX-CARDINALITY :ANY)
Success criteria
Succeeds if the relation is successfully created.
Failure criteria
Fails if the relation can not be created.
Notes
- The domain and range classes of the new class must already exist.
- The domain must always be a class.
- The range may be a class or a data type. The allowed data types are:
- :BOOLEAN
- :FLOAT
- :INTEGER
- :LIST
- :STRING
- :SYMBOL
- MAX-CARDINALITY, if specified, must be greater than MIN-CARDINALITY.
- The INVERSE relation must already exist.
- The DEFAULT value must be a legal value for the relation.
- In some KBMS, such as Protege, the same relation can be created multiple times
with different domains and ranges. This is legal in Algernon if the KBMS backend
allows it.
Related commands
Back to...
Algernon commands
Algernon Documentation Central
Algernon home page