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.
February 3, 2006
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.
About the Author
You May Also Like