Explanation: Constraints enforce rules at the database level, ensuring data integrity.
- Why It Matters: They prevent invalid data from being entered and maintain relationships between tables.
- Example: Add a foreign key constraint:
ALTER TABLE employees ADD CONSTRAINT fk_department FOREIGN KEY (department_id) REFERENCES departments(department_id);
Leave a Reply