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
Consider the join of a relation R with relation S. If R has m tuples and S has n tuples, then the maximum size of join is: If R has m tuples and S has n tuples then maximum siz

Question 1 Explain the concept of Foreign Key. How a foreign key differs from a Primary Key? Can the Foreign Key accept nulls? Question 2 With a necessary example explain (i)

Normalization :It is a process of examine the given relation schemas based on their primary key and Functional Dependencies (FDs) to achieve the properties Minimizing redun

What is the difference between SQL Server 2000 clustered and nonclustered indexes? With a clustered index, the data are kept in the bottom level of the index and in the similar

We need help in Booking System for Golf Business Development of a web based booking system which permits clients to book golf lessons with the following features- a) 4 user p

Briefly describe concurrency execution? Lock - based protocols Locks There are several modes in which a data item may be locked in this section we restrict our attention

Database Administrator One of the main perpose for having the database management system is to have control of both data or programs accessing that data. The person having li

Secondary Indexes Let consider the student database and its clustering index and primary (only one will be applicable at a time). Now consider the state when the database is to

statical data

Objectives After Reading this part, you should be able to: Explain the term CONCURRENCY; Describe the term transaction and concurrent transactions; Talk about co