T
TC
Can you set Required=No for the individual fields within the multi-field
primary key? (I don't have Access here to check)
HTH,
TC
primary key? (I don't have Access here to check)
HTH,
TC
No part of a primary key can be Null.Can you set Required=No for the individual fields within the multi-field
primary key? (I don't have Access here to check)
HTH,
TC
A multifield primary key where no single field of the multifield key
can be null does not seem to make sense.
Tim Ferguson said:Yes it does. A PK is like an address for a record. A null is a very special
value: it is not equal to itself, and it is not necessarily different from
another known value. So record (2003, "NY", 43) might or might not be a
duplicate for (2003, NULL, 43) -- the db engine has no way of knowing.
Is there any way to make a blank entry as opposed to a null such that a key
of the form (2003,,43) or (2003,"NY",,) is produced? Other index systems
I've dealt will allow such.
A Text field can be set with its Allow Zero Length property True, its
Required property True, and its Default property equal to "" (an empty
string). This is permissible in Primary Keys. I don't know any way to
do the same for numeric or date fields, just text.
A zero-length-string is presumably equivalent to a zero or some other
"empty" surrogate.
In the jet file structure, each text field has an "is null?" bit, a
data-length byte, and zero or more bytes of actual data.
I was actually referring to the logical decisions. The use of a "" sentinel
value to get round the (Null = Null) and (Null <> Something) catch is
_logically_ equivalent to using a Special Number or a Special Date.
Armen seems to be saying that from a conceptual viewpoint, it does not make
sense for any field within a multi-field primary key to be null - even if
that was allowed.
I for one have never quite resolved this particular issue in my own mind, so
I'd like to see a real-life example where someone says that it *does* make
sense for one field of a composite primary key to be null.
So, can you say more about your own example? What is the table & columns in
question?
TC
Armen Stein said:The reason I said that a null cannot participate in a primary key is
because I think of nulls as *unknown* values. An unknown value cannot
be a key because it is never "equal" to anything, even (paradoxically)
the Null keyword.
This concept is reinforced in VBA and SQL by the fact that FieldName =
Null is never true; instead, you must use the function IsNull to check
for null values.
Because SQL doesn't allow a direct "equals" operator against null
values, looking them up using comboboxes or other user interfaces
becomes difficult because they need special handling.
If you replace the word "Null" with "Unknown" in your thinking, then
you'll see that having a primary key with an unknown value doesn't make
sense. Meaningless keys (like AutoNumbers) are the way to go in these
cases, and in my opinion *most* cases.
End of 2 cents,
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.