Alex Rivera | Logout

Should each and every table have a primary key?

Asked 2009-05-08T14:49:14.963
417

I'm creating a database table and I don't have a logical primary key assigned to it. Should each and every table have a primary key?

Edit
Report

3 Answers

9

Just add it, you will be sorry later when you didn't (selecting, deleting. linking, etc)

answered 2009-05-08T14:55:10.283
4

To make it future proof you really should. If you want to replicate it you'll need one. If you want to join it to another table your life (and that of the poor fools who have to maintain it next year) will be so much easier.

answered 2009-05-08T14:58:34.113
2

If you are using Hibernate its not possible to create an Entity without a primary key. This issues can create problem if you are working with an existing database which was created with plain sql/ddl scripts, and no primary key was added

answered 2009-05-08T15:00:45.090

Your Answer