SQLServer2012 book learning Chapter IV

Chapter IV enforce data integrity rules

 aims

1     Understanding data integrity rules
 2    understanding the role of various constraints
 3     creation and deletion of constraints on the data in Table
 4    understood that the concept of an identity column
 5    according to the actual need to create an identity column

Data integrity rules 1 - data integrity to ensure data consistency, accuracy, completeness is divided into columns, and referential integrity table

. 1    column also known as user-defined integrity integrity of the data must, consistent with the definition in the valid range.
2    Table integrity, also called entity integrity, the data table must have a primary key, and can not be null
 3    referential integrity, also referred to as referential integrity, foreign key value must refer to the corresponding primary key, data bits the number and type must match exactly. A foreign key is a public key from both tables, to establish contact between the table and the table through the foreign key
 . 4    . 1   when insertion of foreign keys, foreign key value must be present to ensure that the primary key in the primary table.
. 5    2   updates foreign key values, to ensure that the updated foreign key value exists in the primary table primary key values
 . 6    . 3   must pay attention to the presence of the foreign key value updating primary key values, if there is a need to update or prevent cascading update all related foreign key
 . 7    . 4   delete the primary key, the master key to observe whether there is a foreign key, if present, to prevent cascading update or update

Introduction 2 Constraints

A    primary key constraint integrity rules implementing entity, which is the value that uniquely identifies each row in database is identifiable and only
 two    foreign key referential integrity constraint rule implemented, so that the data primary key the foreign key table data table consistent. Foreign key reference columns may be a master key may be a column uniqueness constraint
 3    uniqueness constraint based on one or more columns defined object is to ensure a non-primary key or columns can not enter the same value, the constraint can only remove not Review
 4    check constraint for limiting the range of columns, a column can limit the range of values can be restricted constraints between the plurality of columns in a table. When the column is updated, the system may determine the effectiveness of self-value column
 5    Default constraints provide a default value constraint for the column, if there is no default, and only one constraint may have a default value, and can not be IDENTITY property and used with TIMESTAMP property

3 After you create a primary key constraint, create a foreign key constraint, create a unique constraints, check constraints created, create a default value constraints, drop constraints Code Completion

4 embodiment using the identifier data integrity

1    , if a data table without significant primary key column, the table can be used to ensure that the identifier does not appear in duplicate records, establish IDENTITY property with
 2    1   a table has a defined attribute IDENTITY, numeric data type
 . 3    2   does not allow for the empty, it can not have a check constraint
 . 4    . 3   often try not to use the deleted columns
 . 5    . 4  generates the next identifier by incrementing the value of the method of seed, seed and increment values can be specified, the default is 1. scope the enrollment record table, books to borrow record sheet

 

 

  

Guess you like

Origin www.cnblogs.com/27floor/p/11235504.html
Recommended