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

Data control, Data Control The data control mostly refers to commands that...

Data Control The data control mostly refers to commands that permit system and data privileges to be passed to several users. These commands are usually available to database admi

Why object-oriented system use the relational dbms, Why, generally does an ...

Why, generally does an object-oriented system use the relational DBMS? The reasons for using relational DBMS for OO systems could be any combination of following: a. Many or

Give expression in both tuple calculus and domain calculus, Consider the fo...

Consider the following relational schema: Doctor(DName,Reg_no) Patient(Pname, Disease) Assigned_To (Pname,Dname) Give expression in both Tuple calculus and Domain calculus for

Entities, Entities Let us first be aware of the question: What are e...

Entities Let us first be aware of the question: What are entities? An entity is an object of concern used to show the things in the actual world, e.g., table, car, bo

Modelling and normalisation, Task Part A. Create an ERD from a business pro...

Task Part A. Create an ERD from a business problem. (50 marks) Read the following problem and complete the tasks listed below. THE ABS Blood Bank Australian Blood Services (ABS) i

State the two-way associations, Two-way Associations Mostly, associati...

Two-way Associations Mostly, associations are travel in both directions, although not usually with same frequency. There are three approaches for the implementation. In

How can you connect to the mysql server, How can you connect to the MySQL S...

How can you connect to the MySQL Server? In order to connect to the MySQL server it is necessary to give the username and password so this be able to done with The following

What is data storage, What is Data Storage? The storage structures and ...

What is Data Storage? The storage structures and access methods used by database system are specified by a set of explanation in a special type of DDL called data storage-defin

Explain outer join, Explain outer join? Outer Join - If there are any...

Explain outer join? Outer Join - If there are any values in one table which do not have corresponding value(s) in the other, in an equi-join which will not be chosen. Such ro

What are referential integrity constraints, What are referential integrity ...

What are referential integrity constraints? A value that appears in single relation for a given set of attributes also appears for a particular set of attributes in another rel

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