Design Tip: Choosing a Primary Key for a Web-Customer Table

What to do—and not to do—when choosing a primary key for a table containing your Web-site customers.

Michelle A. Poolet

February 3, 2006

1 Min Read
ITPro Today logo

When you design a Web-customer table, do not make the email address the primary identifier for a user who sets up an account or a profile at your website! You know how often an email address can change, and one of the prime rules of what makes a good primary key is stability: The key's value never changes.

Instead, assign a surrogate primary key for internal identification, as I’ve done in the main article's Figure 1. The email address is fine to use as an external identifier that the Web user will recognize and use for sign-in purposes at your retail site. For more information about primary keys and how to choose a good candidate, see “SQL by Design: How to Choose a Primary Key," April 1999.

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like