The Duplicate Registration Plague
On Google Forms, 10% to 15% of all submissions are duplicates:
A student registers on Monday, forgets by Thursday, and submits again.
A student uses different capitalizations: Rahul.Sharma@gmail.com vs rahul.sharma@gmail.com.
* In a paid event, a student registers twice while trying different payment options.
This inflates confirmed registration counts, causing organizers to turn away genuine attendees because the system falsely reports "Event Full".
---
1. Why Client-Side Deduplication Fails
Many generic web forms attempt to prevent duplicates using JavaScript checks: If the user clears browser cookies, opens an incognito window, or has high network latency, client-side checks fail. Concurrent clicks by the same user insert duplicate rows into the database.
---
2. Spark’s Database-Level Invariant
In Spark (20260910100000_phase_2_database_hardening.sql):
1. Generated Stored Column: The registrations table maintains a stored generated column:
``sql
normalized_email text GENERATED ALWAYS AS (lower(btrim(email))) STORED
`
2. **Unique Composite Index**:
`sql
CREATE UNIQUE INDEX registrations_event_normalized_email_key
ON public.registrations (event_id, normalized_email);
`
3. **Atomic Short-Circuiting**:
* If register_for_event encounters an existing active registration for that email, it safely returns ALREADY_REGISTERED along with the user's existing ticket_code`.
* It never inserts a second row, never burns an extra seat from the tier capacity, and prevents double-charging.
This guarantees that festival capacity records remain 100% accurate.
Frequently Asked Questions
How does Spark define a unique attendee?
Spark enforces a unique database constraint on (event_id, normalized_email), where normalized_email is lower(trim(email)).
What happens if a student attempts to register twice with the same email?
The registration procedure intercepts the attempt and returns ALREADY_REGISTERED with their existing ticket code, preventing duplicate ticket issuance.
Topics covered in this guide:
Next Step: Eliminate Duplicate Registrations
Zero commission on tickets. Direct UPI payments to your club account. Instant gate QR passes and automated certificate delivery.