From the course: PostgreSQL Essential Training

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Constrain acceptable input values

Constrain acceptable input values - PostgreSQL Tutorial

From the course: PostgreSQL Essential Training

Constrain acceptable input values

- [Instructor] Part of a database's responsibility is to maintain the integrity of the data. This means that the database can help ensure that the data that it's storing is trustworthy and valid. You can do this by placing constraints on the table so that the values that are stored fall within an acceptable and expected range or meet some other criteria that you've determined. For instance, you probably never want the price of a product to be negative. Let's take a look at the Kinetico categories table now and see how we can apply a constraint to help ensure that the data that's stored is accurate. I'll select the categories table in the tree and then click the view data button. Now, the market category in this table is used to determine whether a particular product is in the domestic or the industrial market but there's nothing from preventing someone from accidentally making a typo when they enter in the data. For instance,…

Contents