Next: , Previous: %rec, Up: Top


7 %mandatory and %prohibit

Those special field names are used to restrict the fields that can appear in the records stored in a database. Their usage is:

     %mandatory: field1 field2 ... fieldN
     %prohibit: field1 field2 ... fieldN

In both cases the list of field names are separated by one or more blank characters.

The fields listed in some %mandatory entry will be considered mandatory; i.e., at least one field with this name shall be present in any record of this kind. Records violating this restriction will be considered invalid and a checking tool will report the situation as a data integrity failure.

Consider for example an “addressbook” database where each record stores the information associated with a contact. The records will be heterogeneous, in the sense they won't feature exactly the same fields: the contact of an internet shop will probably have an Url field, while the entry for our grandmother probably wont. We still want to make sure that every entry has at a field: the name of the contact. In that case we could use %mandatory as follows:

     %rec: Contact
     %mandatory: Name
     
     Name: Granny
     Phone: +12 23456677
     
     Name: Yoyodyne Corp.
     Email: sales@yoyod.com
     Phone: +98 43434433

Similarly, the fields listed in some %prohibit entry will be considered forbidden; i.e., no field with this name shall be present in any record of this kind. Again, records violating this restriction will be considered invalid.

This can be useful when some field name is reserved for some future use. For example, if we want to make sure no Telex will be even used in our contacts database, we would change the record descriptor as follows:

     %rec: Contact
     %mandatory: Name
     %prohibit: Telex

Several %mandatory and/or %prohibit fields can appear in the same record descriptor. The set of mandatory or prohibited fields is the union of all the entries. For example, in the following database both Id and id are prohibited:

     %rec: Entry
     %prohibit: Id
     %prohibit: id