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
Explain natural join? Natural Join - Similar as equi-join except in which the join attributes (having similar names) are not involved in the resulting relation. Only one sets

What is De-normalization? De-normalization is the method of attempting to optimize the performance of a database by adding redundant data. It is sometimes essential because cur


Project Description: I am having a random problem with my Wordpress site. If I click on "Publish" and "Add new", it takes me to a 404 page not found of /wp-admin/post.php (th

Explain the concepts of relational data model? Relational Data Model - The relational model was first introduced through Prof. E.F. Codd of the IBM Research in the year 1970

This project requires you to perform a systems analysis and then design a system solution using database software. Ace Auto Dealers specializes in selling new vehicles from Subaru.

For every n-ary relationship type R where n>2, we make a new table S to represent R. We contain as foreign key attributes in s the primary keys of the relations that show the parti

What should be declared explicitly in the corresponding ABAP/4 Statements to access internal tables without header lines & why? Work Area. This is needed as the Work Area is

Cyber Transit Ltd keeps up-to-date information on the processing and current position of each dispatched item. Dispatched items are the main concern of the Cyber Transit product tr

What is the use of integrity constraints? Integrity constraints make sure that changes made to the database by authorized users do not result in a loss of data consistency. The