-
Junior Member
Column for Primary Key
SQL which column to select as primary key and why
I have a table employee_account where only two coloums are there emp_id and acc_id. Which coloum i will make as primary key and why?
-
Expert Member
Re: Column for Primary Key
U need to Set a data column as the primary key and guarantees that each record contains a unique value .
Based on this rule decide yourself and add primary key
Last edited by susarlasireesha; 01-09-2008 at 08:11 AM.
-
Re: Column for Primary Key
Deciding the mrimay key of the table entirely depends on the design and the end user requirments. Simply the field which you ant to be unique and not null should be the primary key . In your case select emp_Id as the primary jey. That is a better candidate for being the PK of the table.
-
Junior Member
Re: Column for Primary Key
emp_id and acc_id should be unique and should not be null.so the requirement of primary key arises.if this table does not need any child records
we can define primary key on either of the columns.if there is any need of child records follw belo procedure
if we r using this as a parent table and we r having child table to this then we have to define the primary or unique key on the parent column and then foreign key on child column(in child table)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules