10.07.2015 Views

Using Data Modeler

Using Data Modeler

Using Data Modeler

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Create ConstraintsThere are two types of constraints—key constraints and check constraints. Keyconstraints restrict data in a column or group of columns to uniquely identify a rowand enforce referential integrity within a relationship. Check constraints restrict theadding to or modifying of a table’s data to enforce business rules.Key ConstraintsThere are three types of key constraints—primary key, unique, and foreign key.However, also included as a type of key constraint is indexes. Indexes are included asa type of key constraint because they relate directly to the other key constraints, anduse a key column list. Each table can have only one primary key constraint and cancontain zero or more unique and foreign key constraints. To enforce the keyconstraints, the database server creates a unique index.Primary Key ConstraintIf you assign a primary key for one of your columns, a primary key constraint isautomatically created for you consisting of that column and any other columns youassign as a primary key. Primary key constraints do not allow any two rows of a tableto have the same non-NULL values in any primary key column, and do not allow anyprimary keys to have NULL values. Primary keys control the characteristics of allcorresponding foreign keys and can identify the parent table in a relationship.Primary key constraints can consist of one primary key or a composite primary key.The composite primary key can consist of primary keys and/or primary/foreignkeys. Primary/foreign keys are embedded keys that enforce the referential integrity ofa relationship, and therefore cannot have NULL values. Primary/foreign keys arecreated through identifying relationships, so you cannot manually control aprimary/foreign key. Refer to Embedded Primary/Foreign Key on page 35 for moreinformation on primary/foreign keys.Unique ConstraintUnique constraints also known as alternate constraints consist of one or more uniquecolumns.Uniqueconstraintsdonotallowanytworowsofatabletohavethesamenon-NULL values in any unique constraint columns. NULL values are not allowedfor this constraint, with the exception of the SQL Server DBMS. SQL Server allowsNULL values for unique constraints.Building a New <strong>Data</strong> Model 33

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!