0% found this document useful (0 votes)
50 views11 pages

Table of Content: SR - No. No

Uploaded by

sandeshlahane901
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views11 pages

Table of Content: SR - No. No

Uploaded by

sandeshlahane901
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Table of content

Page
Sr.No. Contents
No.
1 What is integrity 2

2 Various types of integrity 3

3 Referential integrity constraints 4


Implementation of referential
integrity constraints
4 5
4.1 Insert constraints
4.2 delete constraints
5 Conclusion 11

6 Reference 12

1
WHAT IS INTEGRITY ?.....

Data integrity is a concept and process that ensures the


accuracy, completeness, consistency, and validity of an
organization’s data. By following the process, organizations not
only ensure the integrity of the data but guarantee they have
accurate and correct data in their database.

The importance of data integrity increases as data volumes


continue to increase exponentially. Major organizations are
becoming more reliant on data integration and the ability to
accurately interpret information to predict consumer behavior,
assess market activity, and mitigate potential data security risks.
This is crucial to data mining, so data scientists can work with the
right information.

2
VARIOUS TYPES OF DATA
INTEGRITY

Additionally, data integrity can be applied to database


management as well through one of four categories:
 entity integrity
 referential integrity
 domain integrity
 User defines integrity

Within logical integrity, there are four sub-categories: domain,


entity, referential, and user-defined integrity. All are collections
of rules and procedures which application programmers, system
programmers, data processing managers, and internal auditors
use to ensure accurate d

3
Referential Integrity
Constraints

A referential integrity constraint is also known as foreign key


constraint. A foreign key is a key whose values are derived from
the Primary key of another table. A referential constraint is the
rule that the values of the foreign key are valid only if:

 They appear as values of a parent key, or


 Some component of the foreign key is null.

The base table containing the parent key is called the parent
table of the referential constraint, and the base table containing
the foreign key is said to be a dependent of that table.

Referential constraints are optional and can be defined in


CREATE TABLE statements and ALTER TABLE statements.

4
Implementation Of Referential Integrity
On Table

Syntax for parent table or referenced table is :


CREATE TABLE student
(ROLL number PRIMARY KEY,
NAME char(30),
COURSE varchar2(10));
CREATION OF PARENT OR REFERENCE TABLE :-

5
Here roll is act as primary key ,which will help in deriving the
value of foreign key in the child table.

Syntax for child table or referencing table is :


CREATE TABLE subject
(roll number references student1,subcode number, subname
varchar2(20)
);
CREATION OF CHILD OF REFERENCING TABLE :-

6
REFERENTIAL INTEGRITY

ROLL

NAME ROLL

COURSE SUBCODE

SUBNAME
STUDENT TABLE

SUBJECT TABLE

Foreign Key Constraint OR Referential


Integrity constraint.

There are two referential integrity constraint:

Insert Constraint: Value cannot be inserted in CHILD Table if the


value is not lying in PARENT table

Delete Constraint: Value cannot be deleted from parent Table


if the value is lying in CHILD Table

7
Insert Constraints

Suppose you wanted to insert Roll = 05 with other values of


columns in SUBJECT Table, then you will immediately see an error
"Foreign key Constraint Violated" i.e. on running an insertion
command a

Insert into SUBJECT values(5, 786, OS); will not be


entertained by SQL due to Insertion Constraint ( As you
cannot insert value in a child table if the value is not lying in the
PARENT table, since Roll = 5 is not present in the PARENT table,
hence it will not be allowed to enter Roll = 5 in child table

8
Delete Constraints

Similarly, if you want to delete Roll = 4 from STUDENT Table,


then you will immediately see an error "Foreign key Constraint
Violated" i.e. on running a deletion command as:

9
Conclusion

Referential integrity is a constraint which helps us to


prevent data ambiguity.It uses constraints on primary key
of the parent table which is the foreign key to the child
table.It checks whether the primary key to parent table is
equal to foreign key of the child table, thus keeping the data
of respective fields to be same on both the table.Referential
integrity helps in avoiding generation of some random
value for any field.

10
Reference

https://www.scaler.com/topics/referential-integrity-in-
dbms/#:~:text=Advantages%20of%20Referential%20Integrity%
20in,Thus%20maintaining%20data%20authenticity.

https://www.javatpoint.com/dbms-referential-integrity-
constraint

11

You might also like