Explain the two constraints check and foreign key in sql, Database Management System

Assignment Help:

Explain the two constraints, check and foreign key in SQL along with an example for each. Give the syntax.

CHECK constraint - CHECK constraint specifies an expression which must always be true for every row in the table. It can't refer to values within other rows.
Syntax:
ALTER TABLE
ADD CONSTRAINT CHECK();

FOREIGN KEY constraint - A foreign key is a combination of columns along with values based on the primary key values from another table. A foreign key constraint, also called as referential integrity constraint, specifies in which the values of the foreign key correspond to actual values of the primary or unique key in other table. One can refer to a primary or unique key in the similar table also.

Syntax:
ALTER TABLE
ADD CONSTRAINT FOREIGN KEY()
REFERENCES () ON {DELETE | UPDATE}
CASCADE;


Related Discussions:- Explain the two constraints check and foreign key in sql

Query to delete constraint from alter table, A constraint named less_than_2...

A constraint named less_than_20 was defined on the field date_of_birth of table student. Delete this constraint. ALTER TABLE student DROP CONSTRAINT less_than_20;

Hangman, a method named WonGame that checks each letter in the word is matc...

a method named WonGame that checks each letter in the word is matched by its label

What is relational calculus, What is Relational calculus? Relational c...

What is Relational calculus? Relational calculus is a Non- Procedural language.

Define deadlock prevention, Define Deadlock prevention These protocols...

Define Deadlock prevention These protocols make sure that the system will never enter a deadlock state. There are two methods to deadlock prevention. One approach makes sure t

Money making supermarket chain problem, Consider the ER schema below for th...

Consider the ER schema below for the MoneyMaking supermarket chain problem. Translate the given ER schema into SQL CREATE TABLE statement.

Windows 8 Administrative Tools, Which two tools are used to administer user...

Which two tools are used to administer users for Active Directory?

ERD, A student entity type has the following attributes,name..

A student entity type has the following attributes,name..

MULTI-LIST FILE ORGANIZATION, sir, could anybody help me in getting complet...

sir, could anybody help me in getting complete information about the mentioned topic

Draw an e_r model in oracle, Draw an E_R Model for the following: An or...

Draw an E_R Model for the following: An organization uses number of items of a equipment to generates goods. Each item is at one LOCATION, of one TYPE and has a DETAILED_DISCRI

Explain the advantages of database management system, Advantages of Databas...

Advantages of Database management system Let us summarize the advantages. Reduction of Redundancy: This is perhaps the most important advantage of using DBMS. Redundancy i

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd