Chapter :-2 (English)
Topic wise chapter (English)
4. Constraints in DBMS
Constraints in DBMS
Definition:
A constraint is a rule applied on a database table to restrict the type of data that can be inserted, updated, or deleted, ensuring data accuracy, consistency, and integrity.
Common Types of Constraints:
1. Primary Key Constraint – Uniquely identifies each record.
2. Foreign Key Constraint – Maintains referential integrity between tables.
3. Unique Constraint – Ensures all values in a column are unique.
4. Not Null Constraint – Ensures a column cannot have NULL values.
5. Check Constraint – Ensures column values satisfy a specific condition.
6. Default Constraint – Assigns a default value to a column if no value is provided.
✅ Advantages of Constraints
1. Maintains Data Integrity – Ensures the accuracy and consistency of data.
2. Prevents Invalid Data – Restricts incorrect or inappropriate values.
3. Supports Referential Integrity – Foreign keys prevent orphan records.
4. Simplifies Application Logic – Reduces the need to validate data at the application level.
5. Improves Reliability – Helps ensure the database reflects real-world rules and conditions.
❌ Disadvantages of Constraints
1. Slower Performance – Checking constraints during insert, update, or delete operations can reduce speed.
2. Complexity – Designing and managing multiple constraints increases database complexity.
3. Rigid Structure – Constraints may make schema changes or updates more difficult.
4. Dependency Issues – Violating a constraint can block operations, requiring careful management.
5. Extra Storage Overhead – Some constraints (like unique indexes) may require additional storage.