What are constraints? Explain different types of
constraints?

Answer Posted / rahul shrivastava

Constraints enable the RDBMS enforce the integrity of the
database automatically, without needing you to create
triggers, rule or defaults.

Types of constraints:
• PRIMARY KEY
• UNIQUE
• FOREIGN KEY
• CHECK
• NOT NULL

A PRIMARY KEY constraint is a unique identifier for a row
within a database table. Every table should have a primary
key constraint to uniquely identify each row and only one
primary key constraint can be created for each table. The
primary key constraints are used to enforce entity
integrity. ( Entity integrity is an integrity rule which
states that every table must have a primary key and that
the column or columns chosen to be the primary key should
be unique and not null)

A UNIQUE constraint enforces the uniqueness of the values
in a set of columns, so no duplicate values are entered.
The unique key constraints are used to enforce entity
integrity as the primary key constraints.

A FOREIGN KEY constraint prevents any actions that would
destroy link between tables with the corresponding data
values. A foreign key in one table points to a primary key
in another table. Foreign keys prevent actions that would
leave rows with foreign key values when there are no
primary keys with that value. The foreign key constraints
are used to enforce referential integrity.

A CHECK constraint is used to limit the values that can be
placed in a column. The check constraints are used to
enforce domain integrity.

A NOT NULL constraint enforces that the column will not
accept null values. The not null constraints are used to
enforce domain integrity, as the check constraints.

Is This Answer Correct ?    10 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the language structure to add a record to a table?

568


Tell me about the approaches which you used to counter the DI problems.

747


Explain identity in sql server?

558


Difference between Sql server reporting services and Crystal reports?

124


Why do we backup Active Directory ?

607






What are the differences in Clustering in SQL Server 2005 and 2008 or 2008 R2?

591


Tell me what is the difference between locking and multi-versioning?

573


What is 1nf 2nf?

540


List the different normalization forms?

530


what are triggers? : Sql server database administration

491


Which is the best place or learning center for MS SQL?????In Bangladesh?????

1586


What are “lost updates”?

606


How exceptions can be handled in sql server programming?

539


What are the authentication modes in sql server? How can it be changed?

591


When a primary key constraint is included in a table, what other constraints does this imply?

591