Updated on 2024-06-03 GMT+08:00

Constraint Design

DEFAULT and NULL Constraints

  • If all the column values can be obtained from services, you are advised not to use the DEFAULT constraint. Otherwise, unexpected results will be generated during data loading.
  • Add NOT NULL constraints to columns that never have NULL values. The optimizer automatically optimizes the columns in certain scenarios.
  • Explicitly name all constraints excluding NOT NULL and DEFAULT.

Unique Constraints

  • The constraint name should indicate that it is a unique constraint, for example, UNIcolumn name.

Primary Key Constraints

  • The constraint name should indicate that it is a primary key constraint, for example, PKcolumn name.

Check Constraints

  • The constraint name should indicate that it is a check constraint, for example, CKcolumn name.