Thread: Chrish
View Single Post
  #2 (permalink)  
Old 04-26-2008, 04:10 PM
Haul Asp's Avatar
Haul Asp Haul Asp is offline
Senior Member
 
Join Date: Feb 2006
Location: Lonestar state
Posts: 4,414
Let’s say that you are Walmart and you want to run a report each month on your customer purchases.


You would need to set up a database table that would hold your customer information (like name, address, phone #, etc.). Walmart has millions of customers, and some have the same names (like John Smith). So you need to assign a unique identifier to each customer (a customer number), so you will be able to find that customer in the future. You would assign a customer number and make it the primary key to the file. If you are searching for a specific customer, you will always find it by its customer number. You can also set up secondary keys (like last name), but a search on last name would usually produce a large list of all customers with that last name.


To track the customer purchases, you would need to set up another database table, which would include information about the customer’s purchases, such as item number (which would have its own database table), purchase quantity, purchase date, price and any other information that you want to track. It would also contain the customer number (that you created in the customer information table), and it would be assigned as the primary key for this file as well.

So now you have two separate tables (customer and customer purchase information). You will not be able to create your report without information from both tables. That’s where the primary key comes in. You will need to link (or relate) the two tables together using the primary key (the customer number). Linking by primary key ensures that both tables are on the same customer (in this case), so there is no mix up.

Does that help?
__________________
I had a life once, but my job ate it.

Last edited by Haul Asp : 04-26-2008 at 04:13 PM.
Reply With Quote