Re: multiple field, primary key
- From: Jim <dragonoff@xxxxxxxxx>
- Date: Wed, 04 Mar 2009 13:22:05 -0700
On Wed, 04 Mar 2009 10:28:47 -0600, Michael Gramelspacher
<gramelsp@xxxxxxxx> wrote:
On Wed, 04 Mar 2009 08:24:25 -0700, Jim <dragonoff@xxxxxxxxx> wrote:
I have tblAccounts, where I have the following (each field will be
sorted on):
field1 long integer
field2 long integer
field3 text (this field can be null-see below)
Field1 & "-" & Field2 & Field3 = Field4 (text), which is the primary
key.
thus,
10 & "-" 200 & AH = Account# 10-200AH
The primary key (10-200AH) is the foreign key in several other tables.
My question is, would it be better to have field1,field2,field3 a
"multiple field primary key", which would mean that I would need to
require a zero in field3 if null and just display "" (blank) for
field3 in any reports. Thats why I didn't make the 3 fields a primary
key to begin with, because of nulls in field3.
But, I'm revisting my design for two reasons. First, in making any
queries, I have to be sure to add the "breakdown" of the account
number in order to sort correctly. Second, I have a Form where user
enters field1, field2, field3, and the afterupdate event of each is:
Field4 = Field1 & "-" & Field2 & Field3
But, I've run across a couple of instances where user somehow mananged
to not fill in complete account or whatever strange thing happened,
and the PK field (field4) didn't get updated properly.
Any suggestions would be appreciated
Thanks, Jim
CREATE TABLE Table1 (
partA LONG NOT NULL,
partB LONG NOT NULL,
partC TEXT(50) DEFAULT "" NOT NULL,
PRIMARY KEY (partA, partB, partC)
);
Drop the Field4 as it is a computed field and can be computed on the fly anytime needed.
Just a suggestion.
Seems logical. It's bothered me that I set it up this way in the
first place, but fortunately I believe I can change it pretty easy.
Thanks.
.
- References:
- multiple field, primary key
- From: Jim
- Re: multiple field, primary key
- From: Michael Gramelspacher
- multiple field, primary key
- Prev by Date: RE: fund1, fund2, fund3 - repeating field question
- Next by Date: Re: Copy Data from One Form to another
- Previous by thread: Re: multiple field, primary key
- Next by thread: Re: multiple field, primary key
- Index(es):
Relevant Pages
|