contract
is the name of the relation,Order
is the source concept of the relation,ContractID
is the target concept of this relation, andUNI
and TOT
are constraints of this relation.RELATION owner[Person*Building]
, owner
is the name and [Person*Building]
is the type of the relation. Relation names start with a lower case character, to avoid confusion with concept names. The signature of this relation is owner[Person*Building]
. The signature identifies the relation within its context. The left hand concept, Person
, is called the source of the relation and the right concept, Building
, is called the target.<properties>
and <pragma>
-parts are discussed in the sequel. The <meaning>
-part is discussed here.name[Book*Name]
can be specified in the same context as name[Person*Name]
. Because they have different source concepts, these are different relations.<properties>
-part is meant for writing multiplicity constraints in a comma separated list between square brackets '[' and ']'. E.g. [UNI,TOT]
. The following properties can be specified on any relation r[A*B]
a
in A
there can be not more than one b
in B
in the population of r
. This implies that every a
occurs not more than once (is unique) in the source of r
.b
in B
there can be not more than one a
in A
in the population of r
. So, every b
occurs not more than once in the target of r
.b
in B
there must be at least one a
in A
in the population of r
.a
in A
there must be at least one b
in B
in the population of r
.r[A*A]
.a
,b
) in r
, (b
,a
) is in r
.a
,b
) and (b
,a
) are both in r
, then a
= b
a
,b
) and (b
,c
) are both in r
, then (a
,c
) is in r
.a
in A
, the pair (a
,a
) is in the population of r
a
in A
, the pair (a
,a
) is not in the population of r
PRAGMA
. The PRAGMA
is followed by two or three strings. It is used to construct sentences in natural language, using pairs from the actual population of a relation. A pragma specifies how we speak (in natural language) about any pair in the relation. Ampersand also uses pragmas to generate examples in the functional specification. Example of a pragma with three strings:(John,Amsterdam)
results in the sentence "Student John flies the flag of Amsterdam in top."
. The two atoms are fitted in between the three strings. A pragma with two strings is identical to a pragma in which the third string is empty.PRAGMA
keyword will become obsolete in a future version of Ampersand. It will be replaced by the VIEW
-statement which offers more flexibility in composing sentences.)PRAGMA
tells us that it makes sense to utter the phrase "Provider Mario's Pizza's has accepted order 12345."