Suppose I have the following table:
PERSON :
ID INT
NAME STRING
LASTNAME STRING
In my CRUD application I cannot allow the user to insert an existing NAME-LASTNAME combination. What is the best way to do this? The user can either be inserting a new person, or editing one that already exists.
You’re not specifying the database, but if you’re using SQL Server 2008 or newer, you should create a composite UNIQUE index on the columns, in your case since only active users should be unique, a filtered one;
This index will only index active users and disallow duplicates on them only.