Sometimes, you want to make sure that every record of a particular type
contains certain fields.
To do this, use the special field %mandatory
.
The usage is:
%mandatory: field1 field2 ... fieldN
The field names are separated by one or more blank characters.
The fields listed in a %mandatory
entry are
non-optional; i.e. at least one field with this name shall be present
in any record of this kind.
Records violating this restriction are
invalid and a checking tool will report the situation as
a data integrity failure.
Consider for example an “address book” database where each record
stores the information associated with a contact. The records will be
heterogeneous, in the sense they won’t all contain exactly the same
fields: the contact of an Internet shop will probably have a
URL
field, while the entry for our grandmother probably won’t.
We still want to make sure that every entry has a field with the name
of the contact. In this 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
A word of caution, however: In many situations, especially in day to day social interaction, it is common to find that certain information is simply unavailable. For example, although every person has a date of birth, some people will refuse to provide that information.
It is probably wise therefore to avoid stipulating a field as mandatory, unless it is essential to the enterprise. Otherwise, a data entry clerk faced with this situation will have to make the choice between dropping the entry entirely or entering some fake data to keep the system happy.