Previous Topic: General Integrity ConstraintsNext Topic: Composite Attributes


User-Defined Domains

Complex and user-defined domains were mentioned in the primitive domains section. The user-defined domains define sets of possible values that are shared by multiple attributes.

For example, PRODUCTs are available in a limited number of colors. Elsewhere in the business, there is an entity type EMPLOYEE whose security badge can be one of a number of badge colors.

Assuming a standard list of colors, it is possible to have a common definition for both the PRODUCT attribute Color and EMPLOYEE attribute Badge Color, named simply Color, which has the same:

Such a definition is named a user-defined domain. The specification of the user-defined domain Color is as in the following table.

Primitive Domain

Text

Length

25 characters

Permitted Values

red
blue
yellow
silver
gold
green

Ask whether the set of permitted values is stable or whether more colors could be added.

Assume that this is unlikely (but not impossible) for badge color but possible for product color. You have another option for modeling this situation: a new entity type COLOR with an attribute Name. The set of COLOR entities includes Red, Blue, and so forth, with the possibility of adding, for example, a Brown entity when the business needs it.

The use of domains provides some benefits over the use of discrete attribute definitions:

However, it is probably not reasonable to allow the attributes to be compared (If PRODUCT Price is greater than ORDER ITEM Quantity, …) or added together.

Dates should not be added, multiplied, or divided.

You can represent user-defined domains by observing the following guidelines:

Domain QUANTITY

Attributes

 

Entity Type ORDER ITEM

Attribute QUANTITY

Entity Type INVOICE ITEM

Attribute QUANTITY

Entity Type PRODUCT STOCK

Attribute QUANTITY

Domain COLOR

Attributes

 

Entity Type PRODUCT

Attribute COLOR OPTION

Entity Type EMPLOYEE

Attribute BADGE COLOR

Entity Type BUILDING

Attribute EXTERIOR COLOR

Attribute INTERIOR COLOR

Domain

Type of Values Allowed

Description

Address

Any

Postal or physical address in standard format.

Code

Any

Attribute with value not in natural language, for which one or more other attributes define the meaning of each code value.

Count

Numeric integer

Integer quantity of objects.

Duration

Numeric

Length of time in specified unit of time.

Indicator

Any (typically Yes or No)

Code that has two or three permitted values.

Percentage

Numeric

Ratio expressed as percentage.

Period

Any

Name of a specified length of time.

Price

Numeric

Monetary quantity that can be exchanged for goods or services.

Rate

Numeric

Value that is commonly understood to be a percentage or ratio (for example, interest rate or exchange rate, respectively).

Ratio

Numeric

Proportion of amounts of two objects, expressed as number not as percentage.

Value

Numeric

Monetary quantity that expresses the value of an object.