官术网_书友最值得收藏!

Domain integrity constraint

The domain integrity constraint ensures data validity. The first step in defining the domain integrity constraint is to determine the appropriate data type. The domain data types could be integer, real, boolean, character, text, inet, and so on. For example, the data type of first name and email address is text. After specifying the data type, check constraints, such as the mail address pattern, need to be defined.

  • Check constraint: A check constraint can be applied to a single attribute or a combination of many attributes in a tuple. Let's assume that the customer_service schema is defined as customer_id, service_id, start_date, end_date, order_date. For this relation, we can have a check constraint to make sure that start_date and end_date are entered correctly by applying the following check start_date<end_date.
  • Default constraint: The attribute can have a default value. The default value could be a fixed value such as the default hourly wage of the employees, for example, $10. It may also have a dynamic value based on a function such as random, current time, and date. For example, in the customer_service relation, order_date can have a default value, which is the current date.
  • Unique constraint: A unique constraint guarantees that the attribute has a distinct value in each tuple. It allows null values. For example, let's assume that we have a relation player defined as player (player_id, player_nickname). The player uses his ID to play with others; he can also pick up a nickname which is also unique to identify himself.
  • Not null constraint: By default, the attribute value can be null. The not null constraint restricts an attribute from having a null value. For example, each person in the birth registry record should have a name.
主站蜘蛛池模板: 余干县| 彰化市| 保德县| 丹寨县| 剑川县| 从江县| 广丰县| 锡林浩特市| 绍兴市| 枣强县| 衡南县| 永清县| 普陀区| 桦川县| 罗田县| 山阴县| 鄂州市| 潮州市| 元谋县| 仲巴县| 昔阳县| 怀来县| 老河口市| 昌吉市| 沙田区| 珲春市| 荆州市| 清涧县| 吉首市| 普定县| 花垣县| 濮阳县| 汾西县| 尼勒克县| 平顺县| 阜平县| 长沙市| 新密市| 和林格尔县| 盱眙县| 嘉义市|