Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to create Microsoft Access (2013) database of customers where customers are identified by their name and address (I want to allow for null addresses). So for example:

It should accept

Name-------------Address
Joe Smith--------123 Main St.
Sarah Green------123 Main St.
Bob Baker--------Null
Joe Smith--------456 First St.

What I have tried:

The last solution I tried was to make both Name and Address the primary key. Unfortunately, that does not allow for null values in the address column. There won't be any nulls in the name column, but there will be duplicates.

Another solution I expect will be suggested is to make an auto number column and call it CustomerID. I think I may end up including that, but doing that would allow me to give the same customer two different customer ID's like so:

CustomerID------Name-----------Address
1-----------------Joe Smith-------123 Main St.
2-----------------Joe Smith-------123 Main St.
Posted
Updated 19-Nov-17 22:15pm
Comments
Richard MacCutchan 20-Nov-17 4:07am    
Why would you ever want two entries for the same customer?

1 solution

The problem with your whole scheme is that you can get two customers with the same name and address: a father and son for example may well live in the same house.
Additionally, "Main St." is a common address, so it quite possible you will get the same name and address pair in different cities.
And what happens when Joe Smith moves across the city? With a "variable field" as part of a composite key you have to update it in several places and it's very easy to miss some.

Normally, the primary key would be a customer ID - which makes it a lot easier to reference back from other data tables such as AccoungStatus, OrdersPending, OrderHistory, Invoices, and so on - and use a "unique" single field for login such as the email or username which lets you find out the CustomerID once and retain it for the session.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900