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 SQL, and why is it important? SQL stands for Structured Query Language, and is the most significant data processing language in use today. It is not a complete programm

What is an object ID? Each class-derived table has an ID for primary key, one or more object IDs form primary key for association derived tables. An object ID is equivalent dat

Differentiate between a Global and a Local temporary table? - A local temporary table exists only for the duration of a connection or if defined inside a compound statement, fo

Which two files are used during operation of the DBMS? Data dictionary and transaction log are two files used during operation of the DBMS.

The Proliferation of Object-Oriented Methods The first few years of the 1990s saw blossoming of around fifty various object oriented methods. This proliferation is a sign of g

Define the terms   i) DDL   ii) DML   DDL: Data base schema is specified by a set of definitions expressed by a special   language known as a data def

What is the difference among a primary index and a secondary index? Primary Index: A primary index is an ordered file whose records are of fixed length along with two fields.

What is Relational calculus? Relational calculus is a Non- Procedural language.

These are interactive interfaces, graphical that hide the difficulty of the DBMS and query language behind an intuitive, simple to understand, and convenient interface. This permit

What is Stored Procedure? A stored procedure is a named group of SQL statements that have been previously formed and kept in the server database. Stored procedures accept input