Resolved Audit table primary key

BlackByte

Well-known member
Joined
Jun 29, 2008
Messages
126
Location
South Africa, Durban
Programming Experience
1-3
hi, i have an audit table which is updated by a trigger set on another table, but since all tables must have primary keys, i just dont know how i can make the trigger work, so what i want to know is, is it okay not to have primary keys in audit tables.
 
Last edited:
If you do have a PK on your audit table it would be an identity. You may not see a need for it right now but it takes so little effort and storage space, there really isn't a reason not to. If you do find a need for it later you'll be glad you did.
 
Thanks for the quick reply, my problem is, the table is updated by a trigger, using an INSERT Statement, how can i make sure the primary key value is never duplicated?
 
Because my audit table primary key willl never be used outside the system, i have learned that i can use an auto-increment field as my primary key, or in my case (ms sql server) an IDENTITY field
The problem was, i didnt want the trigger attempting to enter a value which already existed
 
Back
Top