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

Discuss the types of integrity constraints with example, Discuss the types ...

Discuss the types of integrity constraints in which must be checked for the update operations - Insert and Delete. Give examples. Insert operation can violet any of the subse

Design a gennalization and specialization hierarchy for an a, Design a genn...

Design a gennalization and specialization hierarchy for an automobile sales company

What are the two types of indices, What are the two types of indices? T...

What are the two types of indices? The two types of indices are:- A)     Dense index B)      Sparse index

Oracle RDBMS, compare the features of oracle RDBMS with MySQL and Microsoft...

compare the features of oracle RDBMS with MySQL and Microsoft SQL server

What are the various states of transaction process, What are the various st...

What are the various states through which a transaction passes through in its lifetime?  Briefly discuss all the events that causes transition from one state to another.   Ans:

Database errors, Database Errors: An error is said to have occurred if the ...

Database Errors: An error is said to have occurred if the implementation of a command to manipulate the database cannot be successfully finished either due to inconsistent data or

Define database management system, Define database management system? D...

Define database management system? Database management system (DBMS) is a set of interrelated data and a combination of programs to access those data.

Extended star schema, Why did SAP introduce the extended star schema? Expla...

Why did SAP introduce the extended star schema? Explain why it is reported to be better than the traditional schema model?

School portal design and development, Project Description: This is going...

Project Description: This is going to be a School portal to handle each activities in school such as, School fees payment, online registration and every other payment, course re

System level permissions-data control, System level permissions : With the ...

System level permissions : With the use of data dictionary you can view them.       Let us take the table name as user_sys_privs (used in oracle).       DESCRIBE USER_SYS_PRI

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