Primary and Foreign Keys

Primary key is the database term for the column(s) that contains values that uniquely identify each row. A primary key is usually a single column, but doesn’t have to be.

There are only two requirements for primary keys:

  • Every row must have a value in the primary key. Empty fields, sometimes called null fields, are not allowed.

  • Primary key values can never be duplicated. If two movies were to have the same ID, all relationships would fail. In fact, most database applications prevent you from entering duplicate values in primary key fields.

When you are asked for a list of all expenses sorted by movie, you can instruct the database to build the relationship and retrieve the required data. The movie table is scanned in ...

Get Adobe ColdFusion 8 Web Application Construction Kit, Volume 1: Getting Started now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.