Along with 16 years of hands on experience he holds a Masters of Science degree and a number of database certifications.
Before using Postgres, I would have to rely heavily on Rails validations to ensure data integrity—My SQL simply doesn’t provide the tools to do this. Outside of rogue processes connecting to the database, there’s also application bugs and, well, the Active Record API itself: insert into users(id,name,email) values (1,'','[email protected]'); ERROR: new row for relation "users" violates check constraint "users_name_must_look_like_a_name" DETAIL: Failing row contains (1, , [email protected]).
UNIQUE Constraints CHECK Constraints Related Tasks Constraints are rules that the SQL Server Database Engine enforces for you.
Although both a UNIQUE constraint and a PRIMARY KEY constraint enforce uniqueness, use a UNIQUE constraint instead of a PRIMARY KEY constraint when you want to enforce the uniqueness of a column, or combination of columns, that is not the primary key.
Unlike PRIMARY KEY constraints, UNIQUE constraints allow for the value NULL.