Compartir a través de


Applying Constraints

[This content is no longer valid. For the latest information on "M", "Quadrant", SQL Server Modeling Services, and the Repository, see the Model Citizen blog.]

In almost every data model, there are values that are not supported for a particular field. In an “M” model, you add constraints to specify the range of valid values for each field in your extent.

Adding Constraints

Consider a Contact model that contains a Hometowns extent. One requirement for this extent could specify that the State field should accept the two-letter state abbreviations rather than the full state name. The following code example shows how to add this constraint to the State field.

    Hometowns :
    {(
        {
            Id : Integer64 => AutoNumber;
            
            City : Text;
            
            State : Text where value.Count == 2;                       
        }
    )*} where identity Id;

There are many different kinds of constraints that can ensure the validity of data added to your models. For more information, see Constraints ("M" Programming Guide).

See Also

Concepts

Basic Data Modeling Patterns

Other Resources

Constraints ("M" Programming Guide)