A constraint defines a
test
element that compares the
identity or
attribute values
of two vertices or two edges.
You cannot mix vertices and edges within a constraint,
but queries may include both vertex constraints and edge
constraints. Because constraints apply to two different query
elements, they occur at the top level within a query, rather than
under any specific element. Specifically, you cannot include
constraints within subquery
elements. You can combine multiple constraints with
and elements.
Constraints take slightly different forms depending on whether
they are comparing attributes or identity. In the example below, the
first test requires that query
items (vertices or edge) A and B have the same value for attribute
attr. The second test requires that query items B and C do
not map to the same entity in the database.
Vertex and edge names
used in the constraint, as specified by
the item-name element, must match
the name and case of vertices and edges defined for this query.
<constraint>Attributes None.
Children
test |
member of a required set | Requirement for query elements’ attribute values |
and |
member of a required set | Requires all of the included tests be satisfied |
or |
member of a required set | Requires one of the included tests be satisfied; allowed by DTD but prohibited by current Proximity implementation |
not |
member of a required set | Requires that the specified test not be satisfied; allowed by DTD but prohibited by current Proximity implementation |
Content Model
Although the DTD does not enforce this, Proximity requires that
constraint test elements may only
be combined with and.
(or | and | not | test)
<constraint>
<and>
<test>
<operator>eq</operator>
<item>
<item-name>A</item-name>
<attribute-name>objtype</attribute-name>
</item>
<item>
<item-name>B</item-name>
<attribute-name>objtype</attribute-name>
</item>
</test>
<test>
<operator>ne</operator>
<item>
<item-name>B</item-name>
<id/>
</item>
<item>
<item-name>C</item-name>
<id/>
</item>
</test>
</and>
</constraint>