Monday 18 July 2016

INTEGRITY CONSTRAINTS



Integrity constraints provide a way of ensuring that changes made to the database by authorised users do not result in a loss of data consistency. An integrity constraint can be any arbitrary predicate applied to the database. They may be costly to evaluate, so we will only consider integrity constraints that can be tested with minimal overhead.


DOMAIN CONSTRAINTS   

 

Domain constraints specify that the value of each attribute A must be an atomic value from the domain dom (A) for that attribute. Some data types associated with domains are given below;  

  • Standard numeric data types for integers (such as short-integer, integer, long-integer). 

  • Real numbers (float and double-precision float). 
  •         Characters, fixed-length strings, and variable-length strings.


ENTITY INTEGRITY

Entity integrity is a property that ensures that no records are duplicated and that no attributes that make up the primary key are NULL. It is the one of the properties necessary to ensure the consistency of the database.


Entity Integrity ensures that there are no duplicate records within the table and that the field that identifies each record within the table is unique and never null.

The existence of the Primary Key is the core of the entity integrity. Entity integrity specifies that the Primary Keys on every instance of an entity must be kept, must bt unique and must have values other than NULL.


REFERENTIAL INTEGRITY

Referential integrity is usually enforced by the combination of a primary key or candidate key (alternate key) and a foregin key. A foregin value must match an existing value of the parent table.Foregin hey based on data values and are purely logical not physical.

DATA TYPES


The data types available with SQL are given below;


Internal Data type
Description
VARCHAR2 (size)
Variable length character string maximum length size bytes. Maximum size is 2000 and minimum is 1. You must specify size for a VARCHAR2.
NUMBER (p,s)
Number having precision p and scale s. The precision p can range from 1 to 38. The scale s can range from -84 to 127.
LONG
Character data of variable length up to 2 gigabytes, or 231-1 bytes.
DATE
Valid date range from January 1,4712 BC to December 31, 4712 AD.
RAW (size)
Raw binary data of length size bytes. Maximum size is 255 bytes. You must specify size of a RAW value.
LONG RAW
Raw binary data of variable length up to 2 gigabytes.
ROWID
Hexadecimal string representing the unique address of a row in its table. This data type is primarily for values returned by the ROWID pseudo column.
CHAR(size)
Fixed length character data of length size byte. Maximum size is 255. Default and minimum size is 1 byte.