Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

CHAPTER 5 Constraints > UNIQUE Constraints

UNIQUE Constraints

A UNIQUE constraint is a table-level constraint, because it makes the value in a column or set of columns unique within the table. Table-level constraints apply to relationships between columns, sets of columns, or all columns in one row against the same columns in other rows of the same table. UNIQUE constraints are out-of-line constraints set after the list of columns in a CREATE statement. Alternatively, you can add them through an ALTER statement after creating a table.

Every well-designed table should have a minimum of two unique keys: natural (covered in Chapter 4) and surrogate keys. The natural key is a column or set of columns that describes the subject of the table and makes each row unique. You can search a table for a specific record by using the natural key in a WHERE clause (see Chapter 11 for more on queries), which makes them internal identifiers within the set of data in a table. Natural keys are rarely a single column.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint