From the course: Database Foundations: Data Structures

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Check constraints

Check constraints

From the course: Database Foundations: Data Structures

Start my 1-month free trial

Check constraints

- [Instructor] The final type of constraint that you can add to your data tables is called a check constraint. This is the one that most closely resembles the data validation rules that you might be familiar with if you've used a spreadsheet application like Microsoft Excel. Check constraints allow you to specify a numeric range or other types of qualifications that new values must satisfy before there'll be stored in the database. This time, we're going to take a look at the TwoTrees orders table. Here, we're storing a row each time a customer places an order. And this includes a total_price column. Let's suppose that the Two Trees company has a minimum order amount and mail orders can be placed if they're below $100. We can build that business rule right into the tables design. We do that by running another alter table statement. This time we're going to alter the table orders. We'll add a constraint and we'll name…

Contents