Click here to Skip to main content
15,898,897 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
let us have two tables such as employee table and salary table in which employee id is a primary key

as we know primary key eradicates duplicate values

first we insert the salary of particular employee in first month

but during insertion of second month salary of that employee we will get primary key error

but we need to solve this problem

how can we solve it

waiting for ur responses ?
Posted

1 solution

Hi,
In employee table keep employee id as primary key. In salary table keep employee id as foreign key with reference as employee table. Then you can add first month salary as well as second month for particular id in your salary table. This solves your problem.
 
Share this answer
 
v3
Comments
gowthammanju 6-Mar-12 1:56am    
ya ur solution is k for me if we have combined both the table in single table den how is it possible
gowthammanju 6-Mar-12 1:58am    
if we have fields such as empid,emname,salary,date in a table let us assume primary key is empid we need to insert the salary month by month how it will be possible
psgviscom 6-Mar-12 4:40am    
There is no possibility in creating duplicates to primary key field. Better create two tables. Otherwise don't use primary key.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900