From the course: Database Foundations: Data Structures
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Check constraints
From the course: Database Foundations: Data Structures
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
(Locked)
Validate data with constraints3m 9s
-
(Locked)
Null constraints5m 34s
-
(Locked)
Unique constraints3m 46s
-
(Locked)
Setting default values3m 14s
-
(Locked)
Check constraints3m 8s
-
(Locked)
Challenge: Add constraints to a table46s
-
(Locked)
Solution: Add constraints to a table6m 29s
-
(Locked)
Solution: Set additional constraints on the data10m
-
(Locked)
-