Database - Constraint classification

2010-10-18  来源:本站原创  分类:Database  人气:89 

Today is the first day of java classes into the medium term, bear brother told us of the database paradigm, the way I talked about database constraints, let us look under the constraints of classification, but I understand is that we learn through different channels under the constraints of the database, more good grasp. So their books through the various networks and to understand, the way read a foreign language data, first summarized as follows, does not also please advice.
But first, what is the database should be said that under the constraints?
Database constraints to ensure data integrity and to achieve a mechanism that is based on the specific implementation of the different databases have different tools. So we will see when studying binding domain integrity (Domain Integrity), physical integrity (Entity Integrity), referential integrity (Referential Integrity) and user-defined integrity (User-defined Integrity) classification of the different constraints . But today I say next, or some of us are new to our database of students, and from a basic understanding of SQL language and learn to.
1, non-empty constraint (Not Null Constraint)
This may be we all know, is that we add that table userinfo, the id, name added to the back are not null, that is, some columns can not set it to empty, I believe we all understand, I said next information I see in an English to the period of English: The not null specification prohibits the insertion
of a null value for this attribute.Any database modifucation that would cause a null to be inserted in an attribute declared to be not null generates an error diagnostic. (we have translated their own)
2, the only constraint (Unique Constraint)
A unique constraint does not include a NULL value. Defined directly in the field can be defined by adding the unique constraint UNIQUE.
1) A table can only create a primary key constraint, but a table can create the need for a number of different columns unique constraint
2) the primary key field does not allow for the null, unique to allow for the empty
3) create a primary key constraint general, the system automatically generates a clustered index, unique constraint automatically produce non-clustered index
3, the check constraint (The Check Clause)
By definition of the database table, the field level or at the table by adding a check constraint to meet specific requirements.
Let me give an example
create table student (
name varchar (15) not null,
student_id varchar (15),
degree_level varchar (15),
primary key (student_id),
check (degree_level in ('Bachelors',' Masters', 'Doctorate')));
Here, we use the check clause to simulate an enumerated type by specifying that degree_level must to be one of 'Bachelors', 'Masters', 'Doctorate';
4, primary key constraints (Primary Key Constraint)
In fact, the primary key constraint is a table can only create a primary key constraint, in fact, the only constraint + non-null constraints. All through the class discussion so much about "dependency" thing, it is estimated that everyone can understand
5, the foreign key constraint (Foreign Key Constraint)
Foreign Key Constraint mainly to ensure that the same or different table referential integrity between tables, it must refer to a PRIMARY KEY Or UNIQUE constraint, the user in the application form must have REFERENCES permission; a table can have up to 31 foreign key constraints ; in the temporary table, you can not use foreign key constraints; primary key and foreign key data type must match exactly. This is not to say to you recommend a website http://tech.sina.com.cn/s/2010-01-04/00481199365.shtml
See also the summary may be a bad cold, hope to interact when

相关文章
  • Database - Constraint classification 2010-10-18

    Today is the first day of java classes into the medium term, bear brother told us of the database paradigm, the way I talked about database constraints, let us look under the constraints of classification, but I understand is that we learn through di

  • What is a database constraint? Three paradigms 2010-10-20

    What database constraints? Database constraints is to standardize data and ensure a high data integrity constraints. Common database constraints are: 1. Check constraints Check constraints that check constraint, set the property by forcing the field,

  • powerdesign generated database Constraint name uniqueness 2010-11-03

    Constraint name uniqueness The problem is that powerdesigner PDM from the CDM transfer, the generated result of Constraint name repeated. Reasons: Constraint name must be within a certain length, and powerdesigner PDM from the CDM transfer time, Cons

  • Add the string in ORACLE database default classification group 2010-09-29

    Quote -- The test script can run -- Now want the data in the database fields grouped according to a fixed sum, I came up with three methods . -- Create a test table. Add test data Sql Code create table test(id varchar2(10),mc varchar2(50)); insert in

  • powerdesign generate database Constraint name uniqueness 2010-11-03

    Constraint name uniqueness The problem is that when powerdesigner PDM from the CDM turn, generated a result of repeated Constraint name. Reasons: Constraint name must be within a certain length, and when powerdesigner PDM from the CDM transfer, Const

  • Chapter database system 2010-09-12

    Database system classification, divided by the number of sites, a centralized DBMS, distributed DBMS Database schema and database design paradigm is the basis for Database three modes: 1 external mode: 2 conceptual model of all data in the logical da

  • (Reserved) of software requirements analysis methods and tools used 2010-02-21

    Abstract In this paper, an IT product sales of the company's information systems project development background, we discuss an information system needs analysis of the whole process, its important features are: the project involved an upgrade replace

  • Summary of content filtering mode 2011-01-10

    This document Copyleft owned yfydz all use under the GPL, can be freely copied, reproduced, reprinted, please maintain the integrity of the document, for any commercial purposes is strictly prohibited. msn: [email protected] Source: http://yfydz.

  • {Reserved} on software requirements analysis methods and tools used 2010-02-21

    Abstract In this paper, an IT product sales of the company's information systems project development background, to discuss an information system needs analysis throughout the process, its important features are: involved in the project is an upgrade

  • Database integrity constraint summary 10 2010-05-24

     definition of data integrity for data in the database to ensure accuracy, consistency and reliability.  Type • entity integrity (Entity Integrity) • Domain Integrity (Domain Integrity) • referential integrity (Referential Integrity) • User-defined

  • [Change] Oracle database design - the definition of primary key constraint 2010-03-30

    Declare the primary key constraint (PRIMARY KEY) A table is not necessarily the primary key, but most tables are created the primary key, primary key must be unique and form the primary key columns can not be empty. Imagine a table of information sto

  • ALTER TABLE statement with COLUMN FOREIGN KEY constraint''conflict. The conflict occurred in database'', table'', column''. 2010-10-13

    Add a foreign key in the database appear ALTER TABLE statement with COLUMN FOREIGN KEY constraint 'FK_product_column' conflict. The conflict occurred in database 'ZhuoLangLvShi', table 'T_Column', column 'Id'. Source: t_product table has data Solutio

  • oracle database design (as defined constraint foreign key constraint) 2010-10-26

    Foreign key constraints to ensure referential integrity. Foreign key constraint limits the range of a column. One example is limited to a finite state abbreviation in the collection, this collection of values ​​is another control structure - a parent

  • oracle database integrity constraint rules 2011-10-10

    Integrity constraints are used to enhance the integrity of the data, Oracle provides five kinds of integrity constraints: Check NOT NULL Unique Primary Foreign key Integrity constraint is a rule, do not take up any database space. Integrity constrain

  • Oracle database, the only constraint in the handling NULL 2010-04-01

    According to the definition of NULL, NULL that is unknown, it is more the result of two NULL is neither equal nor unequal, the result is still unknown. According to this definition, the existence of multiple NULL values should not be the only constra

  • mysql database foreign key constraint 2010-06-22

    mysql foreign key constraints and foreign key constraint oracle somewhat different, mysql foreign key constraint sample code is as follows: create table student( id int primary key , name varchar(20), class_id int , foreign key(class_id) references c

  • (Transfer) Oracle database unique constraint violation handling 2010-07-27

    According to the definition of NULL, NULL that is unknown, it is more the result of two NULL is neither equal nor unequal, the result is still unknown. According to this definition, the existence of multiple NULL values should not be the only constra

  • Access to oracle database table. Field. Constraint information 2010-08-20

    - Access to the database table information select * from dba_tables; select * from all_tables; select * from user_tables; - Access to the database table field information select * from dba_tab_columns; select * from all_tab_columns; select * from use

  • ORACLE database, the default classification of string concatenation group 2010-09-29

    Quote -- The test script can be run directly -- Now want the data in the database grouped according to a fixed sum of the field, three methods are summarized here . -- Create a test table. Add test data Sql Code create table test(id varchar2(10),mc v

  • (To) pre-sort the database tree traversal algorithm (non-recursive infinite pole classification algorithm) study notes 2010-11-16

    Pre-order tree traversal algorithm (non-recursive infinite pole classification algorithm) study notes This is my official tutorial to learn MySQL Managing Hierarchical Data in MySQL notes Multi-layer data structure is estimated that all of the web de