The content of this article is the review notes of the self-study course "Introduction to Database System" by Professor Wang Shan and Sa Shixuan of Renmin University of China. The learning video comes from Xiaopo Station ( portal ), corresponding to video P32-P36, which belongs to the textbook "[First Basics]" "[Chapter 5 Database Integrity]" content.
Article Directory
P32 database integrity overview and entity integrity
32.1 Integrity of the database
- The correctness of the data (the data must conform to the actual situation)
- Data compatibility (data in different relational tables for the same object is logical)
32.2 Physical integrity
- Definition code eg1:
Define the Sno attribute in the Student table as a code
eg2: Define the Sno, Cn oh attribute group in the SC table as a code
- Entity integrity check and default handling
① Check whether the master code value is unique, if not, refuse to insert or modify it
② Check whether each attribute of the master code is empty, and refuse to insert or modify as long as one of them is empty
P33 Referential integrity
33.1 Referential integrity definition
33.2 Referential integrity check and default handling
P34 User-defined integrity
34.1 Constraints on attributes
- Column value is not empty (NOT NULL)
- Unique column value (UNIQUE)
- Check whether the column value meets a conditional expression (CHECK phrase)
34.2 Constraints on Tuples
34.3 Summary and Comparison of Database Integrity
P35 Integrity Constraint Naming Clauses and Assertions
35.1 Integrity Constraint Naming Clause
- Example eg: integrity constraint naming clause
- Example eg: modify the integrity restriction in the table
35.2 Affirmation
- Statement format for creating assertion
CREATE ASSERTION <断言名> <CHECK 子句>
- Example eg:
- Statement format for delete assertion
DROP ASSERTION <断言名>;
P36 trigger
36.1 Trigger
- A special event-driven process defined by the user on the relational table ;
- Any user's addition, deletion or modification of the table will be automatically activated by the server to the corresponding trigger
- Triggers can try more complex inspections and operations, with more surprises and more powerful data control capabilities
36.2 Trigger operation
- Define triggers (can only be defined on the basic table )
- Activation trigger
- Delete trigger