Experiment 3: Integrity language

The integrity of the language test included three pilot projects, of which two required items, an elective project. The experiment of the various pilot projects are proof-test project.

Experiment 3.1 entity integrity test

1. The experiment
to master the method of defining and maintaining the integrity of the entity.
2. Experimental content and requirements
defined entity integrity, delete entity integrity. Two ways to be able to write SQL statements defined entity integrity: integrity when you create a custom entity table, after creating a custom entity integrity table. SQL statement to verify the integrity of the design constraints is working.
3. Experiment important and difficult
experiments focus: the definition of entity integrity when creating tables.
Experimental difficulties: a definition entity integrity of the plurality of candidate codes.
4. Experimental procedure

When you create a table defined entity integrity (column-level entity integrity), to create the department, dept_name-based code, define the department of physical integrity, that blue line defines the dept_name a statement that its main code.

Here Insert Picture Description

Defined entity integrity (table-level entity integrity) when you create the table, also to create department1, dept_name-based code, define the department's physical integrity, that gives the blue line on the table level entity integrity level.

Here Insert Picture Description

After you create a table definition entity integrity to department2, for example, create department2, do not declare the primary key, and then after that two rows of blue create table defines department2 in dept_name property-based code.

Here Insert Picture Description

Definition entities integrity (primary key of a plurality of attributes) to create a table, for example classroom

Here Insert Picture Description

When a plurality of candidate code defined entity integrity, instructor to create a table, for example, where the name, salary, dept_name are candidate code and ID, the master key selected as the ID, name limits non-empty, checking whether the salary pay more than 29,000, dept_name foreign key references the master code department.

Here Insert Picture Description

Entity integrity delete, delete instructor Master Code

Here Insert Picture Description

Increased by the same master key record two, whether the integrity verification entity acts to department, for example, the same master key record insert can see two entities would violate an integrity constraint.

Here Insert Picture Description

Experiment 3.3 Experiment integrity custom

1. The experiment
grasp the definition of user-defined integrity and maintenance methods.
2. The experimental and requirements
for specific applications semantics select NULL / NOT NULL, DEFAULT, UNIQUE , CHECK , etc., define constraints on attributes.
3. Experiment important and difficult
experiments focus: NULL / NOT NULL, DEFAULT.
Experimental difficulties: CHECK.
4. Experiment procedure
(1) define the properties NULL / NOT NULL constraints

NOT NULL ID and name of the attribute definition table stu, as, when inserting null time can not pass

Here Insert Picture Description
(2) define the properties DEFAULT constraint

tot_cred stu1 credit default attribute definition table is 0, the initial credit students represent 0

Here Insert Picture Description
(3) define the properties UNIQUE constraints

The definition of nation table name must be unique attributes of integrity constraints, represents the country's name can not be the same

Here Insert Picture Description
(4) CHECK

Using constraints score should meet the definition of CHECK stu3 table.

Here Insert Picture Description

Published 11 original articles · won praise 2 · Views 123

Guess you like

Origin blog.csdn.net/sinat_40875078/article/details/104099029