Tom or anyone...(primary key)

  • Thread starter Thread starter zena
  • Start date Start date
Z

zena

Thank you for the warning. I now know not to delete the primary key.
HOWEVER, on one table i did delete it to see what would happen. How do
I put it back in? Also, the other tables have 1st field listed
as...Mail list id, db id, clients id, id, etc. Are these just different
names for the primary key? And why different names?
-zena
 
Hi Zena,
HOWEVER, on one table i did delete it to see what would happen.
How do I put it back in?

Restore the table from a back-up copy of your database, if available. A primary key can
be numeric (integer, long integer, etc.) or text based. Since I don't know what type your
original PK field was, I'd have no way of advising you of the correct way to restore it.
Even if I did know the data type, there would still be an issue of relating your records
to any child tables. So, I think the best answer is to restore the table from a back-up.
Click on File > Get External Data > Import..., browse to a back-up copy if you have it,
and import the table. It will likely import with an appended suffix of 1. If you can
send me your database, along with a back-up copy, I'll restore it for you and send it
back.
Are these just different names for the primary key?
Most likely, yes.
And why different names?
Field names must be unique within a table and they should be unique within a database.
Although one commonly sees people using identical field names for a primary key in one
table, and its related foreign key in another table, this is not my style. I prefer to
prefix my primary keys with lowercase pk and foreign keys with lowercase fk. For example,
pkCustomerID in a Customers table (tblCustomers) is related to fkCustomerID in an Orders
table (tblOrders). The reason I do this is that when I am reading VBA code, and I come
across pkCustomerID or fkCustomerID, I know immediately that I am dealing with either a
primary or foreign key--I don't have to guess! Another reason involves setting the
control source for a combo box used to select values from a list and store the data. If
you accidentally specify a primary key, you'll find a nasty error when you attempt to
navigate to a new record. I can tell at a glance whether the control source is foreign
key, as it should be, by use of my naming convention.

Tom
______________________________________


Thank you for the warning. I now know not to delete the primary key.
HOWEVER, on one table i did delete it to see what would happen. How do
I put it back in? Also, the other tables have 1st field listed
as...Mail list id, db id, clients id, id, etc. Are these just different
names for the primary key? And why different names?
-zena
 
Back
Top