Sie sind auf Seite 1von 19

DEPARTMENT OF TECHNICAL EDUCATION

ANDHRA PRADESH
Name : M. Bhagya Lakshmi
Designation : Lecturer in CCP
Branch : DCCP
Institute : GMR Polytechnic, Gajwel
Year/Semester : V Semester
Subject : RDBMS
Subject Code : CCP505
Topic : SQL Plus
Duration : 50 Mts
Sub Topic : DATA CONSTRAINTS
Teaching aids : PPT and Animations
CCP505.53 1
Objectives :

On completion of the period, you would be


able to know:
 Referential integrity constraint
 Column level constraints
 Table level constraints

CCP505.53 2
Recap :
 Domain integrity constraints
 Not null constraints
 Check constraints
 Entity integrity constraints
 Unique constraints
 Allows only unique values to be stored
 Primary constraints
 Avoids duplication between tables
 Does not allow null values
CCP505.53 3
Introduction :
 Domain integrity constraints set a range and
user is prevented from performing the
manipulation
 Entity integrity constraints does not allow
duplicate values or null values
 What referential integrity means ?

CCP505.53 4
Referential means :

 Referential means reference to another table


 Referential integrity refers to integrity of more
than one table
 More than one table are related

CCP505.53 5
Referential Integrity Constraint :

 The referential integrity constraint enforces


relationship between tables
 It designates a column or combination of
columns as foreign key

CCP505.53 6
Referential Integrity Constraint
(Contd..) :

 The foreign key establishes a relationship with a


specified primary or unique key in another table,
called the referenced key
 In this relationship, the table containing the foreign
key is called the child table and table containing
the referenced key is called the parent table

CCP505.53 7
Referential Integrity Constraint
(Contd..) :

 One can either enable or disable a constraint


 The former enforces the constraint and the latter
will not enforce the rule, even though the
constraint would remain as it is in data dictionary
 By default, the constraint would be enabled
 Further we can define a constraint either at table
or column level

CCP505.53 8
Referential Integrity Constraint
(Contd..) :

 If it is defined at the table level, then it can be


enforced to any number of columns in a table
 On the other hand, if is defined at the column
level
 It holds good only for the column for which it is
defined

CCP505.53 9
Referential Integrity Constraint
(Contd..) :

 To establish a ‘parent-child’ or a ‘master-detail’


relationship between two table having a common
column, we make use of referential integrity
constraints
 To implement this, we should define the column in
the parent table as a primary key and the same
column in the child table as a foreign key referring
to the corresponding parent entry

CCP505.53 10
Basic Concepts Related to
Referential Integrity :

Foreign key:
 A column or combination of columns included in
the definition of referential integrity which would
refer to a referenced key
Referenced key:
 It is a unique or a primary key which is defined
on a column belonging to the parent table

CCP505.53 11
Basic Concepts Related to
Referential Integrity (Contd..) :

Child table:
 This table depends upon the values present in the
referenced key of the parent table. Which is
referred by a foreign key
Parent table:
 This table determines whether insertion or
updation of data can be done in child table. This
table would be referred by child’s table foreign key

CCP505.53 12
Data Constraints :

 Data constraints will be connected to a cell by


the DBA as flags
 Constraints can be placed either at the column
level or at the table level

CCP505.53 13
Column Level Constraints :

 If the constraints are defined along with the


column definition, it is called as a column level
constraint
 Column level constraint can be applied to any one
column at a time i.e. they are local to a specific
column
 If the constraint spans across multiple columns,
the user will have to use table level constraints

CCP505.53 14
Table Level Constraints :

 If the data constraint attached to a specific cell


in a table references the contents of another
cell in the table then the user will have to use
table level constraints
 Table level constraints are stored as a part of
the global table definition

CCP505.53 15
Summary :

We have discussed about

 Referential integrity constraints


 Column level constraints
 Table level constraints

CCP505.53 16
Quiz :

1. Referential integrity constraints refers to


relationship between
a) Persons
b) Tables
c) Objects
d) None of the above

CCP505.53 17
Frequently Asked Questions :

1. What Referential Integrity Constraint means.


Explain.
2. List out referential integrity constraints.

CCP505.53 18
Assignment :

1. List out different types of Integrity Constraints


and compare with one another how they are
useful for data integrity.

CCP505.53 19

Das könnte Ihnen auch gefallen