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
What is vertical fragmentation? Vertical fragmentation divides the relation by decomposing the scheme R of relation r.

What are the advantages of object ID? The main advantages of Object IDs are as below: i) IDs are not changing  ii) IDs are completely independent of the changes in data v

You group has been hired by  TrainingrUs.com to keeps track of training revenues. TrainingrUS.com wants you to keep scheduling. COURSE table contains following information:

I am going to develop a web site to present decision tree structure. For this, I want a web application with AJAX technology to connect the database and prepare the decision tree's

What is the purpose of tables, private synonyms and public synonyms? If there are multiple objects of similar name on an Oracle database, that order are they accessed in? The r

Project Description: I would like to get a database of a website which has clients email name and phone number. If you are able to get information from a website, by entering

ERD Diagram of Medical Recruitment Agency?

Why are cursors necessary in embedded SQL? A cursor is an object used to store the output of a query for row-by-row processing through the application programs. SQL statements

#question benefits and limitations of data models..

Q.   Explain the terms key constraints participation constraints and mapping caradinalities in ER model.  Participation Constraints :   The participation of an entity set E i