O'Reilly logo

MySQL by Robert D. Schneider

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

5. Using Constraints to Improve Performance

Simply defined, constraints are rules that a database designer specifies when setting up a table. MySQL enforces these rules when changes are made to information stored in the database. These changes usually occur via INSERT, UPDATE, or DELETE statements, although they can also be triggered by structural alterations to the tables themselves.

MySQL offers the following constraints:

UNIQUEGuarantees that there will be no duplicate values in a column

PRIMARY KEYIdentifies the primary unique identifier of a row

FOREIGN KEYCodifies and enforces the relationships among two or more tables with regard to appropriate behavior when data changes

DEFAULTProvides an automatic value for ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required