Column constraints, Database Management System

Column Constraints: NOT NULL, UNIQUE, CHECK, PRIMARY KEY, DEFAULT, REFERENCES,

On  delete  Cascade:  Using  this  key  whenever  a  parent  row  is  removed  in  a referenced table then all the corresponding child rows are removed from the referencing table. This constraint is a form of referential integrity constraint.

Example 1:

CREATE TABLE product

(

pno number (4) PRIMARY KEY, pname char (20) NOT NULL,

qoh number (5) DEFAULT (100),

 class char (1) NOT NULL,

rate number (8,2) NOT NULL,

CHECK ((class='A' AND rate<1000) OR (class='B' AND rate>1000 AND rate<4500) OR (class='C' AND rate>4500))

);

The command above makes a table. Primary key constraint makes sure that product number (pno) is not null and unique (both are the properties of primary key). Please note down the use of data type char (20). In many executions of SQL on commercial DBMS such as Oracle and SQL server, a data type known as varchar and varchar2 is used respectively. Varchar mainly is variable length character type subject to a maximum specified in the declarations. We will use them at most of the places soon.

Please note the use of check constraints in the table formed above. It correlates two dissimilar attribute values.

Posted Date: 3/11/2013 12:55:29 AM | Location : United States







Related Discussions:- Column constraints, Assignment Help, Ask Question on Column constraints, Get Answer, Expert's Help, Column constraints Discussions

Write discussion on Column constraints
Your posts are moderated
Related Questions
FDs in Relationships:  Enrols Relationship: None as it is many to many Teaches Relationship : Course code → Instructor Instructor → Course code The next question is:

Briefly explain what is to be done during defining problem statement. To define Problem Statement of a system, define what is to be done and how you can go to implement that. Y

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

What is a Name? A user-supplied name is used for identity. This form of identity is used for files in file systems. The user gives every file a name that uniquely identifies it


What is Trigger? Trigger: A database trigger is procedural code which is automatically executed in response to specific events on a particular table in a database. Triggers can

Explain Recursive relationship type? Recursive relationship type: A recursive relationship is one in that the similar entity participates more than once in the relationship

QUESTION (a) Using an appropriate example, explain what is a recursive function? (b) Explain in detail the C++ function given below. void search2(int list[],int n,int ele

Before we talk about the relational model in more detail, let us first define some very basic terms used in this model. Tuple Every row in a table shows a record and is cal

What is indexed sequential file organization? What are the applications of this organization?  Ans: An index file can be employed to effectively overcome the problem of storing