7
Most read
9
Most read
11
Most read
Integrity constraints
Presented by
Madhav Bansal
Roll no. - 1336710027
Presented by
Varsha Divakar
Roll no.- 1336710026
Data base management system
DBMS is a collection of interrelated data and a set of program
to Access those data.
Management of data involve both defining structure for
storage of information & providing mechanism for manipulation
of information.
Data base system ensure the safety of information stored
,despite system or an unauthorized access in attempted on data
base.
. Integrity means something like 'be right' and consistent.
The data in a database must be right and in good
condition.
Need of integrity constraint
 Many user enter data item in data base becomes very
important that the data item &association among them destroy .
 Therefore Data insertion ,updating& other processes have to
be perform in such a way that data integrity is not affected .
 For this integrity checks are made at data level by checking
the value to certain specify rule.
Integrity
Constraints
Referential
Entity
TupleKey
Domain
 Domain integrity means the definition of a valid
set of values for an attribute. You define
- data type,
- length or size
- is null value allowed
- is the value unique or not
for an attribute.
 The range (values in between) and/or specific
values for the attribute. Some DBMS allow you to
define the output format and/or input mask for the
attributes.
Emp_ID ADD Phone No. Age Name
X1 VBN 111 21 A
X2 MTR 123 23 E
X3 MUB 432 22 D
(Age>=18)
Varchar Integer Character
 The entity integrity constraint states that primary
keys can't be null.
 On the other hand, there can be null values other
than primary key fields. Null value is different from
zero value or space.
 The entity integrity constraints assure that a
specific row in a table can be identified.
REG.NO MODEL_id RATE
ABC-112 1 45,00$
ACC-223 6 65,00$
BAA-441 2 57,00$
NULL 5 35,00$
CCE-325 3 45,00$
CCE-326 4 61,00$
Null value not
allowed
The referential integrity constraint is specified between two tables and
it is used to maintain the consistency among rows between the two
tables.
The rules are:
1. You can't delete a record from a primary table if matching records
exist in a related table.
2. You can't change a primary key value in the primary table if that
record has related records.
3. You can't enter a value in the foreign key field of the related table
that doesn't exist in the primary key of the primary table.
4. However, you can enter a Null value in the foreign key, specifying
that the records are unrelated.
Primary table
Related table
Model_id Mark Model
1. ford focus
2. ford mondeo
3. Peugeot 307
4. Peugeot 407
REG.NO MODEL_id RATE
ABC-112 1 45,00$
ACC-223 6 65,00$
BAA-441 2 57,00$
BSA-224 5 35,00$
CCE-325 3 45,00$
CCE-326 4 61,00$
Example of referential
S.No Emp_ID ADD
1 X1 VBN
2 X2 MTR
3 X2 JHS
3 X2 JHS
Same
tuple
doesn’t
allow
S.No. Emp_ID ADD
1 X1 VBN
2 X2 MTR
3 x3 JHS
3 X4 KNP
Foreign Key Integrity Constraint
There are two type foreign key integrity constraints:
• cascade update related fields
• cascade delete related rows.
These constraints affect the referential integrity constraint.
I. CascadeUpdate RelatedFields
Any time you change the primary key of a row in the primary
table, the foreign key values are updated in the matching rows
in the related table.
This constraint overrules rule 2 in the referential integrity
constraints.
Primary table
REG.NO Model_i
d
Mark Model
ABC-112 1. ford focus
ACC-223 2. ford
mondeo
BAA-441 3.
Peugeot
307
BSA-224 4.
Peugeot
407
REG.NO MODEL_i
d
RATE
ABC-112 1 45,00$
ACC-223 2 65,00$
BAA-441 3 57,00$
BSA-224 4 35,00$
CCE-325 5 45,00$
CCE-326 6 61,00$
Related table
7.
7.
Example of Cascade Update Related Fields
II. CascadeDelete Related Rows
Any time you delete a row in the primary table, the matching
rows are automatically deleted in the related table.
This constraint overrules rule 1 in the referential integrity
Primary table
REG.NO Model_i
d
Mark Model
ABC-112 1. ford focus
ACC-223 2. ford
mondeo
BAA-441 3.
Peugeot
307
BSA-224 4.
Peugeot
407
REG.NO MODEL_i
d
RATE
ABC-112 1 45,00$
ACC-223 2 65,00$
BAA-441 3 57,00$
BSA-224 4 35,00$
CCE-325 5 45,00$
CCE-326 6 61,00$
Related table
Example of Cascade Delete Related Rows
S.No. Name Age course Ph No. Roll no. Enroll no.
1 Amit 21 B.Tech 542312 432876 234567
2 Anju 20 B.Tech 543122 432873 234890
3 Vijay 18 MBA 543114 432098 456789
4 Tarun 20 B.Tech 765432 432876 456789
5 Sita 19 BBA 987654 432098 987543
6 Rita 19 BCA 123456 432878 123456
7 Dinesh 20 B.Tech 765434 NUL3 456789
7. Dinesh 20 B.tech. 765434 547894 456789
547894
567483
(Age => 18)
Domain Constraint
Integrity Constraints

Integrity Constraints

  • 1.
    Integrity constraints Presented by MadhavBansal Roll no. - 1336710027 Presented by Varsha Divakar Roll no.- 1336710026
  • 2.
    Data base managementsystem DBMS is a collection of interrelated data and a set of program to Access those data. Management of data involve both defining structure for storage of information & providing mechanism for manipulation of information. Data base system ensure the safety of information stored ,despite system or an unauthorized access in attempted on data base.
  • 3.
    . Integrity meanssomething like 'be right' and consistent. The data in a database must be right and in good condition.
  • 4.
    Need of integrityconstraint  Many user enter data item in data base becomes very important that the data item &association among them destroy .  Therefore Data insertion ,updating& other processes have to be perform in such a way that data integrity is not affected .  For this integrity checks are made at data level by checking the value to certain specify rule.
  • 6.
  • 7.
     Domain integritymeans the definition of a valid set of values for an attribute. You define - data type, - length or size - is null value allowed - is the value unique or not for an attribute.  The range (values in between) and/or specific values for the attribute. Some DBMS allow you to define the output format and/or input mask for the attributes.
  • 8.
    Emp_ID ADD PhoneNo. Age Name X1 VBN 111 21 A X2 MTR 123 23 E X3 MUB 432 22 D (Age>=18) Varchar Integer Character
  • 9.
     The entityintegrity constraint states that primary keys can't be null.  On the other hand, there can be null values other than primary key fields. Null value is different from zero value or space.  The entity integrity constraints assure that a specific row in a table can be identified.
  • 10.
    REG.NO MODEL_id RATE ABC-1121 45,00$ ACC-223 6 65,00$ BAA-441 2 57,00$ NULL 5 35,00$ CCE-325 3 45,00$ CCE-326 4 61,00$ Null value not allowed
  • 11.
    The referential integrityconstraint is specified between two tables and it is used to maintain the consistency among rows between the two tables. The rules are: 1. You can't delete a record from a primary table if matching records exist in a related table. 2. You can't change a primary key value in the primary table if that record has related records. 3. You can't enter a value in the foreign key field of the related table that doesn't exist in the primary key of the primary table. 4. However, you can enter a Null value in the foreign key, specifying that the records are unrelated.
  • 12.
    Primary table Related table Model_idMark Model 1. ford focus 2. ford mondeo 3. Peugeot 307 4. Peugeot 407 REG.NO MODEL_id RATE ABC-112 1 45,00$ ACC-223 6 65,00$ BAA-441 2 57,00$ BSA-224 5 35,00$ CCE-325 3 45,00$ CCE-326 4 61,00$ Example of referential
  • 13.
    S.No Emp_ID ADD 1X1 VBN 2 X2 MTR 3 X2 JHS 3 X2 JHS Same tuple doesn’t allow
  • 14.
    S.No. Emp_ID ADD 1X1 VBN 2 X2 MTR 3 x3 JHS 3 X4 KNP
  • 15.
    Foreign Key IntegrityConstraint There are two type foreign key integrity constraints: • cascade update related fields • cascade delete related rows. These constraints affect the referential integrity constraint.
  • 16.
    I. CascadeUpdate RelatedFields Anytime you change the primary key of a row in the primary table, the foreign key values are updated in the matching rows in the related table. This constraint overrules rule 2 in the referential integrity constraints.
  • 17.
    Primary table REG.NO Model_i d MarkModel ABC-112 1. ford focus ACC-223 2. ford mondeo BAA-441 3. Peugeot 307 BSA-224 4. Peugeot 407 REG.NO MODEL_i d RATE ABC-112 1 45,00$ ACC-223 2 65,00$ BAA-441 3 57,00$ BSA-224 4 35,00$ CCE-325 5 45,00$ CCE-326 6 61,00$ Related table 7. 7. Example of Cascade Update Related Fields
  • 18.
    II. CascadeDelete RelatedRows Any time you delete a row in the primary table, the matching rows are automatically deleted in the related table. This constraint overrules rule 1 in the referential integrity
  • 19.
    Primary table REG.NO Model_i d MarkModel ABC-112 1. ford focus ACC-223 2. ford mondeo BAA-441 3. Peugeot 307 BSA-224 4. Peugeot 407 REG.NO MODEL_i d RATE ABC-112 1 45,00$ ACC-223 2 65,00$ BAA-441 3 57,00$ BSA-224 4 35,00$ CCE-325 5 45,00$ CCE-326 6 61,00$ Related table Example of Cascade Delete Related Rows
  • 20.
    S.No. Name Agecourse Ph No. Roll no. Enroll no. 1 Amit 21 B.Tech 542312 432876 234567 2 Anju 20 B.Tech 543122 432873 234890 3 Vijay 18 MBA 543114 432098 456789 4 Tarun 20 B.Tech 765432 432876 456789 5 Sita 19 BBA 987654 432098 987543 6 Rita 19 BCA 123456 432878 123456 7 Dinesh 20 B.Tech 765434 NUL3 456789 7. Dinesh 20 B.tech. 765434 547894 456789 547894 567483 (Age => 18) Domain Constraint