AlphaPress Publishing
P.O. Box 5942 Albany, NY 12205
Tel: 518-250-3890
Email: alphapress@hotmail.com 


  

Section Menu 

Are you a University or College bookstore and want to order multiple books?  Email us at alphapress@hotmail.com or call us at 518-250-3890.  We will be happy to talk to you.  

Are you a professor and you need a sample copy?  We will be happy to send you a pdf or printed copy!  Email us at alphapress@hotmail.com.

Are you outside the United States?  We can ship multiple books worldwide in most countries.

  

 

 

Create multi-field indexes to avoid duplicate records

To contact the author click here

This article is from the book "Access 2007 Pure SQL

To download the sample database click here


Discussion:

When working with customers you would like to make sure that no duplicate customer records exist in your database.  At the same time, it is logical that many customers might have the same last name and many of them the same first name.

Consequently, from a design point of view, we need to allow multiple customers to have the same last name or the same first name but not the same combination of both. We can easily solve this problem with a multi-field index. 

With a multi-field unique index, your database will accept values such as Smith John and Smith Tracy.  However, if you try to enter another Smith John in the database, then you will get a message that such entry violates existing index rules and will not be accepted.  Multi-field indexes are extremely useful to keep your data in a good state.  
 

Code:

CREATE UNIQUE INDEX indLastFirst ON tblCustomer1 (LastName, FirstName);
 

Result: