0% found this document useful (0 votes)
35 views

Notes Chapter 1.1 Lecture 1.5(Integrity)

Integrity constraints in Database Management Systems (DBMS) are rules that ensure the validity, integrity, and consistency of data during operations like insert, update, and delete. There are several types of integrity constraints, including domain constraints, entity integrity constraints, referential integrity constraints, and key constraints, each serving to maintain data quality and prevent accidental damage. These constraints are essential for ensuring that data remains accurate and reliable across the database.

Uploaded by

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

Notes Chapter 1.1 Lecture 1.5(Integrity)

Integrity constraints in Database Management Systems (DBMS) are rules that ensure the validity, integrity, and consistency of data during operations like insert, update, and delete. There are several types of integrity constraints, including domain constraints, entity integrity constraints, referential integrity constraints, and key constraints, each serving to maintain data quality and prevent accidental damage. These constraints are essential for ensuring that data remains accurate and reliable across the database.

Uploaded by

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

UNIT-1

CHAPTER 1.1

Lecture-1.5 (Integrity)

Integrity Constraints

Integrity constraints in Database Management Systems (DBMS) are a set of rules that are
applied on the table columns or relationships to ensure that the overall validity, integrity, and
consistency (i.e. the quality) of the data present in the database table is maintained. Each and
every time a table insert, update, delete, or alter operation is performed, it is evaluated against
the terms or rules mentioned in the integrity constraint. The data is inserted, updated, deleted,
or altered only if the result of the constraint comes out to be True. Thus, integrity constraint
prevents accidental damage to the database by an authorized user.

 Integrity constraints are a set of rules. It is used to maintain the quality of information.

 Integrity constraints ensure that the data insertion, updating, and other processes have
to be performed in such a way that data integrity is not affected.

 Thus, integrity constraint is used to guard against accidental damage to the database.

Types of Integrity Constraint


1. Domain constraints

These are the constraints on the domain value and thus are column level constraints unlike
entity integrity constraint which are row level. The domain integrity constraints are used to
impose restrictions on some particular column. Thus they affect the domain value. These can
be enforced in the form of the following-

 Check value
 Default value

Check is used to impose certain checks like checking if a value is greater than or lesser than a
particular value etc. thus the upper and the lower limit can be set.

Default value is the value to be provided in case no value is provided by the user. We can set
a default value for any column depending on its data-type. These are also used during
defining the structure of the tables, in the data definition language statements.

 Domain constraints can be defined as the definition of a valid set of values for an
attribute.

 The data type of domain includes string, character, integer, time, date, currency, etc.
The value of the attribute must be available in the corresponding domain.

Example:

2. Entity integrity constraints

Entity integrity constraints as the name implies is applied on each entity. i.e. it is applied on
individual rows. The constraint here is to have a unique value for each row in the column or a
group of columns it is applied to. This attribute is essential when a particular record or row of
data is to be accessed. It can be accessed using the entity integrity constraint by supplying the
unique value and accessing the entire record.
There are two such constraints which ensure uniqueness of data. They are-

 Primary key
 Unique keyword

Primary key ensures that values in a column are unique so that duplicate values are not
allowed and also the primary key column cannot be null. Thus it focuses on two properties-
uniqueness and not null. A table can contain only one primary key. Primary key can consist
of a column or a group of columns. It is used to uniquely identify records in a table.

Unique keyword is just like the primary key but it allows null values. Both these are defined
on columns during defining the structure of table. Thus these are used in data definition
language.

 The entity integrity constraint states that primary key value can't be null.

 This is because the primary key value is used to identify individual rows in relation
and if the primary key has a null value, then we can't identify those rows.

 A table can contain a null value other than the primary key field.

Example:

3. Referential Integrity Constraints

Referential integrity constraint makes sure that the values in the column on which it is
applied are already present in the column it is referring to. Thus here a column of a table
refers to the other column of the same or different table. This ensures that the values are
consistent and similar in both the columns. This is implemented using-
Foreign key

Foreign key normally references the primary key of same or another table. But it can refer to
other columns too. Whenever, same type of attribute exists in two different tables, the
attribute in one of the table is declared as the primary key and in the other, it is made foreign
key, so that the values in both become consistent. Foreign key is dependent on primary key.

 A referential integrity constraint is specified between two tables.

 In the Referential integrity constraints, if a foreign key in Table 1 refers to the


Primary Key of Table 2, then every value of the Foreign Key in Table 1 must be null
or be available in Table 2.

Example:

4. Key constraints

 Keys are the entity set that is used to identify an entity within its entity set uniquely.

 An entity set can have multiple keys, but out of which one key will be the primary
key. A primary key can contain a unique and null value in the relational table.

Example:
OTHER REFRENCES

 DBMS Integrity Constraints - javatpoint


 Integrity Constraints in DBMS (indiastudychannel.com)
 Integrity Constraints in DBMS | SQL - Database Management System |
SQL Tutorials (dbmstutorialpoint.com)

SUGGESTED BOOK REFERENCES

1. C.J.Date, “An Introduction to DatabaseSystems”, Addison Wesley.

2. Thomas M. Connolly, Carolyn & E.Begg,“Database Systems: A Practical Approach


to Design, Implementationand Management”, 5/E, University of Paisley, Addison-
Wesley.

3. Rob,”Database Principal Fundamental Design, Cengage Learning.

You might also like