Education logo

Enforcing Integrity Constraints in DBMS

Ensuring Data Accuracy and Consistency using Integrity Constraints in DBMS

By Pushpendra SharmaPublished 2 months ago 3 min read
Types of Integrity Constraints

Enforcing Integrity Constraints in a Database Management System (DBMS) is the process of ensuring the data in the database is accurate, consistent, and reliable. We can call it the law or rule that must be followed by database to maintain the Data.

What are Integrity Constraints?

1. Entity integrity:

Entity Integrity makes sure that each table has a primary key and that the key is unique and not null, or we can say that the primary key always has a Value. This guarantees that every record can be uniquely identified.

2. Referential Integrity:

Make sure that foreign keys correctly reference primary keys in another table. To maintain the consistency of relationships between tables, foreign key must reference correct Primary key otherwise database could become corrupted.

3. Domain Integrity:

Make sure that all entries in a column lies within a specified range or lies within set of values. For example, a column which is made to contain ages of Humans then the data value should only contain numbers within a realistic human age range.

4. User-Defined Integrity:

Any other rules which are defined by the user to fit specific business requirements. For example, an employee’s salary must be greater than the minimum wage, or the minimum age of employees to get promotions.

How Are Integrity Constraints Enforced?

Entity Integrity

Primary Key:

The Database Management System (DBMS) requires that each table must has a column, or a set of columns which are marked as the primary key in Database. When a user adds a new record, the DBMS checks that the primary key is unique and not null.

Example: When you have a table of students then the Student IDs should be the primary key. The DBMS will make sure that every student must have their unique ID.

Referential Integrity

Foreign Key:

When a foreign key is used, the DBMS checks that the foreign key does matches with the primary key in another table. This process makes sure that the relationships between these tables are valid.

Example: If a table is for courses and another table for Student admissions, then the admission table has foreign key referring Student ID (or Primary key), this process will help in validating Students' admissions.

Domain Integrity

Check Constraints:

The DBMS allows user to make and set rules on what values are permissible in a column. If data entered does not follow the set rules, then the Database would reject it.

Example: If a user made a column to accept the data of only dates, then the DBMS will reject every entry which are not a date.

User-Defined Integrity

Custom Rules:

Users can define or make any specific rules using triggers and these rules will be enforced by the DBMS.

Example: A Company or an Organization might require the data of employee’s hire date, then this date cannot be in the future. The DBMS can be set to enforce this rule so nobody can enter future's date.

Why Are Integrity Constraints So Important?

Accuracy: It makes sure that the data entered is accurate and the data makes sense.

Consistency: It maintains consistent relationships between tables using references of primary key in another table.

Reliability: It helps in keeping the data reliable for analysis and decision-making. Reliability is one of the most important factors of Database Management System.

Error Prevention: It prevents mistakes like duplicate entries of the same data or invalid references, for examples foreign key using references of correct primary key in another table.

Enforcing integrity constraints in DBMS is the process of setting up rules or laws that are followed by database in every situation to keep the data correct, consistent, and reliable.

These given rules are automatically checked by the DBMS whenever data is added, modified, or deleted, to make sure that the overall quality and integrity of the stored data.


About the Creator

Pushpendra Sharma

I am currently working as Digital Marketing Executive in Tutorials and Examples.

Enjoyed the story?
Support the Creator.

Subscribe for free to receive all their stories in your feed. You could also pledge your support or give them a one-off tip, letting them know you appreciate their work.

Subscribe For Free

Reader insights

Be the first to share your insights about this piece.

How does it work?

Add your insights


There are no comments for this story

Be the first to respond and start the conversation.

    Pushpendra SharmaWritten by Pushpendra Sharma

    Find us on social media

    Miscellaneous links

    • Explore
    • Contact
    • Privacy Policy
    • Terms of Use
    • Support

    © 2024 Creatd, Inc. All Rights Reserved.