First, NOT NULL Specifies the column that does not accept NULL values.
Second, the Check constraint is limited to the values that can be placed in the column to force the integrity of the domain.
Check Constraint Specifies the Boolean (True or False) search criteria for all values entered in the column, rejects all values that do not value TRUE. Multiple Check constraints can be specified for each column. The following example shows the creation of the CHK_ID constraint, which ensures only the number within the specified range, to further force the domain of the primary key.
Create Table Cust_Sample
(
Cust_id int Primary Key,
Cust_name char (50),
Cust_address char (50),
Cust_credit_limit Money,
ConsTRAINT CHK_ID CHECK (Cust_id Between 0 and 10000)
3. The Uniqueness of the UNIQUE constraint in the column set. For columns in UNIQUE constraints, there is no two rows to contain the same non-null value in the table. The primary key is also enforced uniqueness, but the primary key does not allow null values. UNIQUE constraints preferred over the unique index
Fourth, the primary key constraint identity column or column set, these columns, or column values uniquely identify the rows in the table. In a table, there is no two lines containing the same primary key. You cannot enter NULL values in any column within the primary key. NULL in the database is a special value, representing an unknown value different from the blank and 0 value. It is recommended to use a small integer column as the primary key. Each table should have a primary key. There is more than one column combination in a table that can uniquely identify the rows in the table, each combination is a candidate key. The database administrator selects one as a primary key from the candidate key. For example, in a part_sample table, Part_nmbr and part_name can be a candidate key, but only part_nmbr is selected as a primary key. Create Table Part_Sample
(Part_nmbr Int Primary Key,
Part_name char (30),
Part_weight decimal (6, 2),
Part_color char (15)) 5. The relationship between the Foreign Key constraint identification table. The foreign key of a table points to the candidate key for another table. When the other key value does not have a candidate key, the foreign key prevents operations from keeping retaining the outer key value. In the following example, the Order_PART table creates a part_sample table defined in front of the foreign key. Typically, ORDER_PART also has a foreign key on the ORDER table, which is just a simple example. Create Table ORDER_PART
(ORDER_NMBR INT,
Part_nmbr int
Foreign Key References Part_sample (Part_nmbr)
On Delete No Action,
Qty_ORDERED INT)
Go
If a foreign key is not a candidate button, the row with this value (except NULL) cannot be inserted. If you try to delete a row pointing to the existing foreign key, the ON DELETE clause will control the operation taken. On Delete clause has two options:
No an action fails to delete errors. Cascade specifies that all rows containing foreign keys that point to deleted rows are also deleted. If you try to update the candidate key value directed by the existing foreign key, the ON Update clause will define the operation taken. It also supports the NO Action and Cascade options.