Column constraints, Database Management System

Assignment Help:

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.


Related Discussions:- Column constraints

Relation schema for student, Example RELATION SCHEMA for STUDENT: STU...

Example RELATION SCHEMA for STUDENT: STUDENT (Roll No: string, name: string, login: string, age: integer) RELATION INSTANCE

Hello, Java program for horrizontal fragmentation in distributed database

Java program for horrizontal fragmentation in distributed database

Explain the lock based protocol, Lock Based Protocol A lock is nothing ...

Lock Based Protocol A lock is nothing but a mechanism that tells the DBMS whether a particular data item is being used by any transaction for read/write purpose. As there are t

Basics of relational models, In the first unit of this block, you have been...

In the first unit of this block, you have been given with the details of the Database Management System, its structure, advantages etc. This unit is an attempt to give you informat

Explain generalization and aggregation in e_r diagram, Explain the concept ...

Explain the concept of generalization and aggregation in E_R diagrams. Give one example for each one of them? Generalization: Consider extending the entity set account throug

Define the term database, QUESTION (a)(i) Define the term database. ...

QUESTION (a)(i) Define the term database. (ii) How is it different from a database management system? (b) What is the difference between an entity and an attribute? (c

What is database trigger, What is database Trigger? A database trigger ...

What is database Trigger? A database trigger is a PL/SQL block that can explained to automatically execute for insert, update, and delete statements against a table. The trigge

Trigger , Flights(FlightNo, DeptDateTime, Origin, ArrivalDateTime, Destinat...

Flights(FlightNo, DeptDateTime, Origin, ArrivalDateTime, Destination, Capacity, SoldSeats) Tickets(FlightNo, Seat, CustID) Where - flightNo is the PK of the flights table - DeptDa

Er diagram, Design a generalization–specialization hierarchy for a motor-ve...

Design a generalization–specialization hierarchy for a motor-vehicle sales company. The company sells motorcycles, passenger cars, vans, and buses. Justify your placement of attrib

Define the traditional system analysis and design, Define the Traditional S...

Define the Traditional System Analysis and Design Traditional System Analysis and Design (SAD) have three basic life cycle models. A typical software lifecycle consists of the

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd