Take Advantage of CREATE TABLE Supported Constraints

Take Advantage of CREATE TABLE Supported Constraints

You should always try to take advantage of the features in SQL Server to automatically maintain the integrity of data. The CREATE TABLE statement supports data integrity. You can specify table or column level constraint along with the CREATE TABLE statement. CHECK constraints ensure that column values are valid. DEFAULT and NOT NULL constraints avoid the problems caused by missing column values which may be present in the system due to application bugs. PRIMARY KEY and UNIQUE constraints enforce the uniqueness of rows. FOREIGN KEY constraints ensure that rows in dependent tables always have a matching master record. IDENTITY columns efficiently generate unique row identifiers. TIMESTAMP columns ensure efficient concurrency checking between multiple user updates.

By taking advantage of these CREATE TABLE options, you can make the data rules visible to all users of the database. These server enforced rules help avoid errors in the data that can arise from incomplete enforcement of integrity rules by the application.


Share the Post: