wiki:Additional Integrity Constraints

Version 4 (modified by 193284, 13 days ago) ( diff )

--

Additional Integrity Constraints

Description

This section documents additional CHECK and UNIQUE constraints implemented during the advanced database development phase.

The constraints improve data integrity by restricting invalid values and preventing duplicate RSVP and attendance records.

SQL Code

ALTER TABLE event_rsvp
ADD CONSTRAINT chk_rsvp_status
CHECK (status IN ('accepted', 'declined', 'pending'));

ALTER TABLE attendance
ADD CONSTRAINT chk_attendance_status
CHECK (status IN ('attending', 'absent'));

ALTER TABLE event_rsvp
ADD CONSTRAINT uq_guest_event_rsvp
UNIQUE (guest_id, event_id);

ALTER TABLE attendance
ADD CONSTRAINT uq_guest_event_attendance
UNIQUE (guest_id, event_id);

Constraint Overview

  • CHECK constraints are used to restrict invalid status values.
  • UNIQUE constraints prevent duplicate RSVP and attendance records for the same guest and event combination.
  • Integrity rules are enforced directly at database level independently from the application layer.
Note: See TracWiki for help on using the wiki.