Hello Friends,

Here is another popular lab from Hands-On-Lab library: Constraints in SQL Server.

Constraints in SQL server are used to enforce rules for the data to be stored in a table. If any rule violation happens, the corresponding constraint will abort the invalid action which is against the rules. We have six constraints in SQL server to ensure referential integrity and domain integrity. The domain integrity means a column should contain only valid values as dictated by the business rules and referential integrity is a database concept that ensures the relationship between tables remains consistent. The six constraints are Primary Key, Foreign Key, Unique Key, Check, Default and Not Null. This lab is divided into five exercise. In this first exercise, we will learn about creating Primary Key, composite Primary Key, creating non-clustered index with Primary Key. In the second exercise, we will learn to create Foreign Key, Update and Delete cascade with Foreign Key. in the third exercise, we will learn about how to ensure domain integrity using Check constraint. In the fourth exercise, we learn to ensure domain integrity using Unique Key constraint and differences between Unique Key and Primary Key. In the fifth and final exercise, we will learn about Not Null and Default constraints.

Exercise 1: Primary Key Constraint
Exercise 2: Foreign Key constraint
Exercise 3: Check constraint
Exercise 4: Unique Key constraint
Exercise 5: Default and Not Null constraints

SQLMaestros Hands-On-Labs enables the practical way of learning. Each lab document consists of multiple exercises and each exercise consists of multiple tasks. Apart from step-by-step instructions, the HOL document contains images, explanations, observations, notes, tips & tricks to ensure a great learning experience. With each lab, you can practice a specific concept step-by-step. With our HOL documents, you will get hands-on with hundreds of topics in SQL Server & Microsoft Data Platform. Learn More.



Happy Learning – The Practical Way.