Constraints are not part of models.wrm, but are registered in wspec/constraints.wrm using the syntax shown below. The constraint names the target class, then specifies the relevant query.
Objects which violate constraints will not be loaded and the violation will be reported. The example below uses tace and pparse.
Constraints can be used to specify tags, particular values in fields or even the presence of a value, as is shown below.
?Paper Year UNIQUE Int
Author Text
Class Paper
Constraints "Year:1"
This constraint requires a value in the first field following the Year
tag (it must be non-void). An attempt to load this data
Paper X Author Sam Year 1995 Paper Y Author Tom Paper Q Year 1992 Paper Z Author Sallywill generate these warnings:
acedb> pparse rawdata/test.ace // Parse error near line 7 in Y : Object Y does not satisfy constraints // Parse error near line 13 in Z : Object Z does not satisfy constraints // 3 objects read with 2 errors// 2 Active Objects acedb>