Attribute Constraints

Attribute constraints are used to compare attribute values across different database entities. (See “Implementation in Proximity” later in this chapter, however, for important restrictions regarding mixing object and link attributes in a constraint in Proximity.)

Figure 5.14 shows a fragment of a database containing information about movies released as DVDs. Note that Proximity databases do not necessarily have to be fully connected; as this example illustrates, discontinuities are permitted.

Sample database fragment [Const_DB03.xml]

Figure 5.14. Sample database fragment [Const_DB03.xml]


Suppose that we want to find movies released as DVDs in the same year as their theatrical release. Figure 5.15 shows the QGraph query for this task.

Query: Movies and DVDs released in the same year [Const_DB03_Q01.qg2.xml]

Figure 5.15. Query: Movies and DVDs released in the same year [Const_DB03_Q01.qg2.xml]


The query’s constraint requires that the value of the ReleaseYear attribute of the object corresponding to the movie vertex be the same as the value of the PubYear attribute of the object corresponding to the DVD vertex. Figure 5.16 shows the results of executing the above query on the database fragment shown in Figure 5.14.

Query results: Movies and DVDs released in the same year

Figure 5.16. Query results: Movies and DVDs released in the same year


The query finds two subgraphs where a movie’s DVD release occurred in the same year as its theatrical release.