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
Give an example of enforcement in Typing. You can understand the idea of enforcement as it makes sure objects of dissimilar classes may not be interchanged as below:  Exampl

A field-groups statement or an insert statement reverses storage space and transfers values. False.

The Conceptual Level or Global level The conceptual level presents a logical view of the complete database as a unified whole. It permits the user to bring all the data in th

coventions for displaying an ER schema as ER diagram

Compare the two log-based recovery schemes in terms of ease of implementation and overhead cost.    Ans:  There are two types of log based recovery techniques: deferred update


A Functional dependency is described by X Y between two groups of attributes Y and X that are subsets of R specifies a constraint on the possible tuple that can make a relation

Define hot swapping? Hot swapping permits the removal of faulty disks and changes it by new ones without turning power off. Hot swapping decreases the mean time to repair.

What are the authentication modes in SQL Server? How can it be changed? Windows mode and Mixed Mode - SQL and Windows. To alter authentication mode in SQL Server click Start, P