View Single Post
  #5  
Old June 5th, 2009, 09:27 PM posted to microsoft.public.access.tablesdbdesign
Michael Gramelspacher
external usenet poster
 
Posts: 482
Default New Database - Primary Key

On Fri, 5 Jun 2009 12:58:01 -0700, Trini Gal wrote:

Bernard and Armen,

Thank you for answering. Honestly, I have read so much about why I should
and shouldn't be using the AutoNumber, that I just didn't use it and used the
DMax function instead. I don't know anything about the SQL Server, I only
know a little Access. I don't know what you mean by "natural key".

This is what I have right now:

Channel_ID (incrementing #, say 9 is the next #)
Division (NC, SC)
Region (Manhattan, Bronx, Brookly, Queens)

So when the user selects the Division and Region, the File_Name eg
SC_Bronx_9, which is a concatenation of all three fields, which I have as the
Primary Key.

Was that a good decision? Thats where I need your input. I read some
threads where there are like 2 and 3 primary keys, but I didn't quite
understand that.

Thanks,

"Bernard Peek" wrote:

In message , Trini
Gal writes
Hello,

I've read a lot of the threads referencing Primary Key and I need a little
help. I'm creating a database for my company to track changes to channels.
This database will be accessed in different regions throughout the company
(possibly sometimes at the same time). I need to figure out how to create a
Primary Key for one of my tables. I've figure out how to use the DMax
function to increment #s, but if two users try to enter a new record at the
same exact time, one of them won't be able to save that record because the
one before got the #. I know this because its happened before.


If your database is going to be accessed by lots of people
simultaneously then it's worth considering whether Access is the right
tool for the job. Depending on the usage pattern you may want to
consider using a client-server database like SQL Server which can wrap
multiple updates into a transaction.

If all you want is a unique ID then an autonumber field will do the job.
Don't your tables have natural keys?


--
Bernard Peek

Is channel_id something real, as perhaps a television channel number?

In that case the natural primary key is
PRIMARY KEY (channel_id, division, region).

If you go with an autonumber as a primary key, then make that
UNIQUE (channel_id, division, region).

Do not concatenate the three values together in the table. if you need then
concatenated, then do it in a query.