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

Explain data independence, Explain data independence ? Data independenc...

Explain data independence ? Data independence is the capacity to modify the schema at one stage of a database system without having to change the schema at the further level.

What is the use of raid, What is the use of RAID? A variety of disk-org...

What is the use of RAID? A variety of disk-organization methods, collectively called redundant arrays of independent disks are used to better the performance and reliability.

Relationship for college database, Using the concepts defined previous, we ...

Using the concepts defined previous, we have identified that strong entities in COLLEGE database are FACULTY, STUDENT, COURSE and DEPARTMENT. This database also has one weak entity

Describe the concept of aggregation, Aggregation Aggregation is strong...

Aggregation Aggregation is stronger form of association. It represents the "has-a" or "part-of" relationship. An aggregation association depicts a complex object which is comp

Applications and goals of dbms, What do you mean by DBMS? What is its need ...

What do you mean by DBMS? What is its need and what are its goals. Explain?        OR   Explain Data Base Management System? Sol.  Database management system is a

Describe integrity and security, Describe integrity and security? a)   ...

Describe integrity and security? a)      Domain constraint b)      Referential integrity A value that appears in one relation for a given set of attributes also appear fo

Type of views-data control, Type of views :  Simple views and Difficult ...

Type of views :  Simple views and Difficult Views Feature Simple Views Complex Views Number of tables One

State the data flow diagram of functional model, State the data flow diagra...

State the data flow diagram of functional model Any action initiated by transition in the state diagram can be extended into an entire data flow diagram in functional model. Th

Define data conversion, Define data conversion? Helpful to load data in...

Define data conversion? Helpful to load data into temporary staging tables. Then can write SQL code to do much of data processing. SQL code is simpler and faster to write than

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