Ron wrote:
Well, now I'm even *more* confused.
Hi Ron,
What I'm telling you applies to use of a primary key. In the
application you have described, the basic structure should include a
table for invoice header information and a second table for invoice line
items. It sounds as if you are planning to join the two tables in
queries by use of the invoice table's primary key - good - which you
are planing to make the invoice number - bad.
So I assumed you are using the primary key as a menas to link tables.
It truly is a good rule of thumb to have the means by which you link
tables together to be absolutey meaningless. That way you and your
users can happily tinker away with whatever scheme you have for
information. There are some instances when a developer might be tempted
to use actul real information as a PK and the one that comes to my mind
that is often used is an account number or component(s) of an account
number for multi-part account number set ups. How often is an account
number ever going to change?
Well, even bean counters screw up and decide an account number has to
change from time to time. I run a maintenance system which is fed
account numbers from a larger financial system and the maintenance
system populates account fields in various tables with an actual account
number to avoid the pain of having to associate the extra account
table(s) via a "meaningles s" system number in putting together SQL
statements. It always seemd to me to be a reasonable step until 2 years
ago when our university bean counters decided a coule of account codes
had to change. It was a hideous exercise trying to worm through all the
tables in our maintenance app (it does a lot of stuff and there are a
couple of hundred Oracle tables rife with account number information)
and change all these.
Having a link via a meaningless system generated number for the account
PK and linking the account table would have meant the account number
would needed to have been changed once, and once only.
So yes, I would strongly recommend you come up with two numbers to
generate - an autonumber for a PK and an autonumber or some other means
of generating a sequence for the invoice number.
--
Tim
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "What's UP, Dittoooooo?" - Ditto