Reputation:
I have column having name id in my table. id is the primary key in table. I want to know that is it necessary to have separate column for id as it is primary key in my table.
Upvotes: 1
Views: 366
Reputation: 3735
The PRIMARY KEY constraint uniquely identifies each record in a database table and if your table already contain that column then u don't need to add another column.
Upvotes: 0
Reputation: 14306
It's always better to keep things simple. If you already have a column that identifies the record it's just fine - don't add a new one.
There is also something called composite primary keys. You can use it if a combination of 2 or more columns always creates a unique sequence. Than you don't really need the 'Id' column. The truth though is some frameworks don't like this approach.
In your case the column you already have should be sufficient.
Upvotes: 1
Reputation: 10079
Any field or combination of fields can be a primary key if:
Upvotes: 1
Reputation: 463
Not necessary to have a separate column, you could have an existing column as primary key if it can identify each record uniquely..
Upvotes: 1