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

Describe the functions and features of foreign key, Describe the functions ...

Describe the functions and features of foreign key? Foreign Key : The primary key of one file or table that is implanted in another file or table to implement the relationships

Data manipulation language, Data Manipulation Language Data manipulatio...

Data Manipulation Language Data manipulation language (DML) describes a set of commands that are used to query and change data within existing schema objects. In this case comm

Having clause with sub queries, Having Clause with sub queries: First we h...

Having Clause with sub queries: First we have to recollect the GROUP BYclause. The following query searches the minimum salary in every department. SELECT DEPTNO, MIN (SAL)

Security-drawbacks of data distribution, Security: In a centralised system...

Security: In a centralised system, access to the data can be simply controlled. Though, in a distributed DBMS not only does access to replicated data have to be controlled in many

What are the parts of sql language, What are the parts of SQL language? ...

What are the parts of SQL language? The SQL language has various parts: data - definitition language  Data manipulation language  View definition  Transaction contr

The average amount of their orders , Make SQL statements for the following ...

Make SQL statements for the following scenarios. Your response should contain SQL statement, output and any other assumptions you have made to arrive at the answer. For Colorado cu

Define dbms, Define DBMS? DBMS: database management system (DBMS) is co...

Define DBMS? DBMS: database management system (DBMS) is computer software designed for the reason of supervision databases based on a variety of data models.

Describe the relational model, a) Distinguish between ‘database' and ‘Data...

a) Distinguish between ‘database' and ‘Database Management Systems (DBMS)'. b) List and briefly describe five potential benefits of the database approach compared to conventio

Explain physical and logical independence, Define Physical and Logical inde...

Define Physical and Logical independence  Ans: Physical data independence: The ability to modify physical level without causing application program to be rewritten. Logic

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