Constraints

Here are the constraints used in SQL Server 2012 to help with the integrity problem that otherwise will occur.

There are five different kinds of constraints which are used to enforce the integrity of the tables in the relational model.

1. Primary Key, this one is used to identify a unique row and you can not have null values here. This is often used as some kind of int to identify different customers or orders in a table. The primary key creates a unique index to help create uniqueness and speed up queries.

2. Foreign Key, are used to point to another table with a primary key or unique constraint to restrict the values in the foreign key column to those in the other table with the primary key/unique constraint. These tables are also called “referenced tables”. This connection sometimes provide a problem when deleting rows in a table. This can be adjusted/configured with the “cascade” option.

3. Unique, enforces uniqueness of a row – you can have multiple of these in a table.

4. Check, are used to make a predicate that says something about what can be inserted in the table, i.e. only put in products that has the value greater than 200. This constraint will reject updates or inserts that does not comply with the predicate.

5. Default, this is used to create a default value when you choose not to enter a value for some columns. Then this default value will be used.

Advertisements
Tagged with: , , ,
Posted in T-SQL

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Archive
Categories

Blogstatistics
  • 3,840 hits
Boyan Penev on Microsoft BI

This is my journey towards greater knowledge with Microsofts Business Intelligence Solutions.

Sherry's BI Corner

All about Microsoft’s BI Platform (SQL Server, Reporting Services, Analysis Services, Integration Services)

Sherry's BI Corner

This is my journey towards greater knowledge with Microsofts Business Intelligence Solutions.

Comments for CALUMO

This is my journey towards greater knowledge with Microsofts Business Intelligence Solutions.

True Tiger Recordings

This is my journey towards greater knowledge with Microsofts Business Intelligence Solutions.

Data Inspirations

This is my journey towards greater knowledge with Microsofts Business Intelligence Solutions.

%d bloggers like this: