Tuesday, 11 October 2011

Candidate, Artificial (Derived) Primary Key, Unique & Primary Key

{\rtf1\ansi\ansicpg1252\deff0\deflang16393{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}{\f1\fnil\fcharset0 Calibri;}}
{\stylesheet{ Normal;}{\s1 heading 1;}{\s2 heading 2;}{\s3 heading 3;}{\s4 heading 4;}{\s5 heading 5;}{\s6 heading 6;}}
{\*\generator Msftedit 5.41.21.2509;}\viewkind4\uc1\pard\li720\lang1033\b\f0\fs22 Integrity Constraint\par
\b0 An \b integrity constraint\b0 is a declarative way to define a business rule for a column of a table. An integrity constraint is a statement about a table's data that is always true and that follows these rules:\par
\pard\fi-360\li1440\sb120\sa100\tx1440 If an integrity constraint is created for a table and some existing table data does not satisfy the constraint, then the constraint cannot be enforced. \par
After a constraint is defined, if any of the results of a DML statement violate the integrity constraint, then the statement is rolled back, and an error is returned. \par
\pard\li1080\sb100\sa100 Integrity constraints are defined with a table and are stored as part of the table's definition in the data dictionary, so that all database applications adhere to the same set of rules. When a rule changes, it only needs to be changed once at the database level and not many times for each application.\par
\pard\li720\lang9\b Candidate key:\b0 \par
A relation (table) may contain more than one key. \line In this case, one of the keys is selected as the primary key and the remaining keys are called candidate keys. \line The candidate key constraint indicates that the table cannot contain two different rows with the same values under candidate key columns.\par
\lang1033\b\par
\pard\keepn\s5\li720 Artificial (Derived) Primary Key\par
\pard\li720\b0 A derived key comes from a sequence. Usually it is used when a concatenated key becomes too cumbersome to use as a foreign key.\par
\b\par
\pard\keepn\s1\li720 UNIQUE Constraints\par
\pard\li720\b0 You can use UNIQUE constraints to ensure that no duplicate values are entered in specific columns that do not participate in a primary key. Although both a UNIQUE constraint and a PRIMARY KEY constraint enforce uniqueness, use a UNIQUE constraint instead of a PRIMARY KEY constraint when you want to enforce the uniqueness of a column, or combination of columns, that is not the primary key.\par
Multiple UNIQUE constraints can be defined on a table, whereas only one PRIMARY KEY constraint can be defined on a table.\fs14\par
\pard\b\fs22\par
\pard\keepn\s6\li720 FOREIGN KEY Constraints\par
\pard\li720\b0 A foreign key (FK) is a column or combination of columns used to establish and enforce a link between the data in two tables. A link is created between two tables by adding the column or columns that hold one table's primary key values to the other table. This column becomes a foreign key in the second table.\fs14\par
\pard\b\fs22\par
\pard\keepn\s6\li720 PRIMARY KEY Constraints\par
\pard\li720\b0 A table usually has a column or combination of columns whose values uniquely identify each row in the table. This column (or columns) is called the primary key of the table and enforces the entity integrity of the table. A table can have only one PRIMARY KEY constraint, and a column that participates in the PRIMARY KEY constraint cannot accept null values.\par
\pard\sa200\sl276\slmult1\lang9\f1\par
}

No comments:

Post a Comment