Skip to content

Constraint Overview

In the MatrixOne Intelligence database, in order to ensure the correctness, integrity and validity of the data, restrictions will be added to certain columns in the table building statement to ensure that the information stored in the database complies with certain business rules. These restrictions are called constraints. For example, if the execution result of a DML statement violates the Integrity Constraint, the statement will be rolled back and an error message will be returned.

Integrity constraint type

MatrixOne Intelligence has multiple constraints, and different constraints have different restrictions on database behavior. Currently supported constraints are table-level constraints:

A non-null constraint means that the data in a certain column cannot have a null value (NULL), and data that violates this restriction cannot be inserted or updated in the corresponding column. In MatrixOne Intelligence, a table allows zero, one or more non-null constraints.

A unique key constraint means that in a column or combination of columns stored in a table, the value of the inserted or updated data row is unique in this column (or column set). In MatrixOne Intelligence, zero, one or more unique key constraints are allowed in a table, but unlike other relational databases, the unique key constraints of MatrixOne Intelligence must also be non-empty.

Primary key constraints refer to the fact that in a certain column or combination of multiple columns stored in a table, each data row can be uniquely determined by a certain key value and is not empty, and there can only be at most 1 primary key constraint in a table.

Foreign key constraints refer to a column or column combination stored in a table that is referenced by a column or column in another table. The referenced table is usually called a parent table and a referenced table is called a child table. The data of the corresponding column of the child table references the parent table can only be the data or null value of the parent table. This constraint is called a foreign key constraint.

Autoincrement constraint is a feature used to automatically generate unique identifier values ​​for a column in a table. It allows you to automatically generate an incremental unique value for the specified autoincrement column when inserting a new row.