Integrity constraints (Chapter Summary), integrity constraints Chapter Summary

Source: Internet
Author: User

Integrity constraints (Chapter Summary), integrity constraints Chapter Summary
1. The Integrity Constraint of the database is a check measure for data updating. One or more constraints exist on a data table.


2. constraints are divided into five types: non-NULL constraint (not null), UNIQUE constraint (UNIQUE), primary key constraint (primary key), CHECK constraint (CHECK ), foreign key constraint (foreign key ).


3. When defining constraints, you can use the CONSTRAINT keyword to set the CONSTRAINT name.


4. When setting foreign key constraints, you can perform cascade data update operations as follows.
On delete cascade: when the primary table data is deleted, the corresponding sub-table data is also deleted;
On delete set null: when the primary table data is deleted, the corresponding sub-table data is SET to null.


5. constraints can be set when the table is defined, or you can add constraints separately for existing data tables. The ALTER command is used to modify the constraints.


6. When a constraint is temporarily not in use, you can set it to disabled and then re-enable it.
What are the differences between the column-level integrity constraints and the table-level integrity constraints?

When creating a table, you can also define integrity constraints related to the table. These integrity constraints are stored in the system's data dictionary, when you operate data in a table, DBMS automatically checks whether the operation violates these integrity constraints. If the integrity constraints involve multiple attribute columns of the table, they must be defined at the table level. Otherwise, they can be defined at either the column level or the table level.
Example 1 creates a Student table consisting of five attributes: Student ID Sno, name Sname, Gender Ssex, age Sage, and department Sdept. The student ID cannot be blank, the value is unique, and the name value is also unique.
Create table Student
(Sno CHAR (5) not null unique,/* constraints on column-level integrity. The Sno value is UNIQUE,
Sname CHAR (20) UNIQUE. null values are not allowed */
Ssex CHAR (1 ),
Sage INT,
Sdept CHAR (15 ));

Common integrity constraints:
Master code constraint: PRIMARY KEY
Uniqueness constraint: UNIQUE
Non-NULL constraint: NOT NULL
Integrity constraints
Reference: hi.baidu.com/...6.html

Experiment 4 database integrity constraints and Relationship Diagram

% [Z, A] = X (0, pi/2, 0 );
N = 3; % recursion times
Len = 400/3 ^ n;
Hold on;

If n> = N
Plot ([z, z + len * exp (I * A)]/I );
Z = z + len * exp (I * );
Else
[Z, A] = X (z, A, n + 1); % X
A = A + pi/3; % +
[Z, A] = Y (z, A, n + 1); % YF

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.