Hello. My name is Eric. And in this lesson, you'll learn the important concept of constraints. And as school constraints are used to specify the rules in the table whenever a row is inserted, updated, or deleted, the first constraint we'll discuss is the not normal constraint. This constraint ensures that a column cannot have a nor value. So for this example, we're going to use the create Table statement To create a table. We'll give this table a name of students and n or students not normal. And you can see here when we want to use a not no constraint, we simply have to use the not null keyword after each column of interest. Let's go ahead and create this table by pressing control. Enter. So let's see if our constraint worked. Really attempt to insert into this table using the insert into keyword lists the name of the table you want to insert into lists the column headers within this table, and then use the value keyword to list the specific row of data. Please note here we have now listed a no first name, so this should violate our constraint. Let's go and attempt to insert this by pressing control. Enter and we see we get an error saying column first name cannot be null. Next, let's talk about the unique constraint. This constraint ensures that all values in a column are different or unique from each other. So let's create a similar table that now includes the unique constraint. We'll label this table Students U for students Unique. Please note we're still using our not normal constraint on all other columns, and you're allowed to have multiple constraints on one column. So we have added a unique constraint on the email column. So now, by adding this unique constraint on the email column, no two students can have the same email. Let's go ahead and create this by pressing control. Enter. Now let's see what happens when we try to insert a row with the same email. Go ahead and press control. Enter and we receive an error saying duplicate entry for this particular email on our email column. Next is the primary key constraint. This constraint uniquely identifies each record within a database table. Primary keys must contain unique values, and they cannot contain no values. Also, a table can only have one primary key. So for this example, we're going to use our student ID as our primary key. Since each student has a unique I.D. and a student must have an ID to add a primary key constraint, simply add the primary key keywords after the column of interest. Let's go ahead and create this table by pressing control. Enter. And now, if we click on our newly created table, switch over to the structure tab, we can see that our student ID column here has been signified with this call key for our primary key. Now, we created these tables for educational purposes, so let's go ahead and drop these tables and create a clean students table to drop or remove a table, simply use the drop table keyword followed by the name of the table. Let's go ahead and drop all these tables by pressing control. Enter or receive a warning and go ahead and hit. Okay, We can see these tables have been dropped. Now we'll create a clean table just called students with the student ID as the primary key, not null constraint on all other columns and are a unique constraint on the email column. Let's go ahead and create this by pressing control. Enter. Next, let's look at the default constraint. This constraint provides a default value for a column when none is specified. So let's go ahead and create a table labeled teachers that contains a column is active with the Boolean data type and millis the default constraint with a value of one. Now, every time a new teacher is inserted into the teacher's table, even if the is active field is not specified, the value will be a default to one or signifying. This teacher is active. So let's go ahead and create this table by pressing control. Enter. So we'll use our insert into keyword to insert values into the teacher's table. And please note we haven't listed the IS active column header or an associated row in the values keyword. Let's go ahead and insert this row by pressing control. Enter and then if we click on our teachers table, we still see that this column has been added as well as the default one value. Last we have the foreign key constraint. This constraint is used to prevent actions that were destroyed, links or connections between tables. These relationships are defined based on a field in one table that refers to a primary key in another table. Let's create a table name courses for each course has a teacher ID that corresponds to a teacher in the teacher's table to define our foreign key constraint, we will use the foreign key keyword followed by the column that's present in both tables. We'll use the references keyword to define the link well as the name of the table that we're linking to and then followed by the column that creates this link. Let's go ahead and create this table by pressing control. Enter. Thanks for watching. Stay tuned for the next lesson, where we dive deeper into the concept of constraints.