Dear James:
Starting from the ground up.
"a customer can have more than one widget per account"
Now, is a "customer" the same thing as an "account". In some situations, a
customer could have several accounts. You may need separate, related tables
for this.
"I have a table that lists the billing address (CustomerID)"
If the table has an AccountNo (as shown) why have a CustomerID as well? Why
not drop the ID and make AccountNo the PK?
"a table that records widget (WidgetID)"
Same thing. There is a WidgetSerial. Why have an ID as well? The
WidgetSerial is unique, right?
Maybe I have the wrong idea. Is CustomerID a column, or is it the name of
the table. In reading of other people's databases, CustomerID has always
meant a column, not the name of a table. Do I have the wrong idea?
In some cases, the "ship to" address, not unlike the
WidgetInstallLocationAddress, is an attribute of the Account or Customer,
not the widget. If Joe orders a widget today and another tomorrow, will
they be for the same location? Maybe, probably, certainly? Will Joe have a
short list of locations at which he installs widgets, and which are
frequently reused? Just some possibilities for usefull exploitation in
modeling the data.
Now about building the form. On the main form, or a separate subform
according to your preference, select an existing customer or add a new one.
How do you envision finding an existing customer? The best answer is this:
What do you know when you need to find the customer? Is it a person on the
phone? If it is an existing customer, what does he say: "This is customer
14072." I doubt it. He says, "This is Joe Wilson", right? So you need a
Joe Wilson type of combo box lookup. So, you type in "Joe Wi" in the combo
box, and it auto fills to say Joe Wilson. You open the combo box list, but
there are 7 Joe Wilsons there. How do you identify one from another? Well,
there are a lot of possibilities.
Here's my suggestion. Let Joe decide how to make himself unique. Why?
Because, when you're on the phone with Joe, the thing that makes him unique
in your computer needs to be something he can remember. Maybe it's the fact
that he's the Joe Wilson from Tampa. Maybe it's that he's Joe W Wilson.
Let him be the one who decides what his distinguishing characteristic is.
After all, he's the one on the phone who has to remember what that
characteristic is. When he chooses that "characteristic" at first, it will
be entered in the computer and tested for uniqueness. If you don't already
have a Joe Wilson with the characteristic "Tampa" then he gets that
assignment. If you do, have him choose another.
Contrast this with the "account number" alternative. Do you think he's
going to remember his account number? If he calls in an order from his job
site and doesn't have his filing cabinet with him, he won't have the account
number with him. Now what are you going to do? Refuse to take his order?
Here's another aspect. If you go into your boss's office to discuss the Joe
Wilson account, how do you tell the boss what account you're talking about?
Do you say, "I have a question about account 94131." Is that how your boss
knows the customers? Or does he know this as the Joe Wilson Tampa account?
This is what I call a unique human key. It's like a "natural" key
(something we discuss in database technology) but it goes just a bit
farther. The account number is technically a natural key, but not the one
humans use. "Tampa" is the kind humans use. We have the need for
uniqueness, too. We cannot talk about the Joe Wilson account accurately
without saying "Tampa" and we know that, and why that is so.
All this discussion is to suggest you add a column to the customer table for
HumanKey and make the CustomerName / HumanKey combination a unique index.
There have been many debates on this. The above is my take.
Well, I'm nothing if not long winded. Don't know if you like the
discussion, if it helps move you toward the product you'd like to have, or
what. I'll stop for now. Need you encouragement if I'm to continue.
Sorry if it seems complex. In my opinion, a database should be only as
complex as the thing it is modeling. No more, but no less.
Everybody else: It's time to pile on Tom again. He's gone off the deep end
on natural keys again!
Tom Ellison