Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Unique Email Among Active Users

Users are soft deleted (deleted_at IS NOT NULL). Create a constraint so that no two active users share an email, while deleted users may keep duplicate emails.

Table schema

Users(id INT PRIMARY KEY, email VARCHAR(100), deleted_at TIMESTAMP NULL)

Sample data

Rows: (1, a@x.com, NULL), (2, a@x.com, 2026-01-01). Inserting another active a@x.com must fail.

Discussion

No discussions yet.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.