Click here to Skip to main content
15,886,857 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I already make payroll database i have all tables but one relation in this database i don't know how to make relation

between payroll table and deduction and income

Employee Table

Employee ID
Name
Address
Nationality


Salary Table(1 to 1 Employee Table)

Salary ID 
Employee ID
Salary

Income Table(N to 1 Employee Table)

Income ID
Employee ID
Bonus
Over Time
From Date
To Date

Deduction Table ( N to 1 Employee Table)

Deduction ID
Employee ID
Deduction 
From Date
To Date

Payroll Table(I don't know Relation)

And this is my question how to collect Deduction and income from two tables and make relation to Payroll table

Meaning what relation between Payroll and( Deduction And Income)

How to collect two foreign key of income and Deduction in Payroll Table

Are relation one to many or what

[edit]Code block added - OriginalGriff[/edit]
Posted
Updated 4-Dec-14 3:41am
v2
Comments
Krunal Rohit 4-Dec-14 9:30am    
please re-format the question.

-KR
ZurdoDev 4-Dec-14 9:30am    
If you can explain it in clear English then that should define the relationship you need, if any.
Richard MacCutchan 4-Dec-14 9:41am    
Why would you have an Income or Deduction table? Income will be a variable value for each employee, and deductions will be calculated according to a set of rules.

1 solution

We can't say - we have no idea what your payroll table is going to contain, or what you are going to use it for.

So start by thinking about what information it needs to contain, and that should give you a clue. If you draw a diagram (and SQL Server Management Studio can do that for you) of your various tables it may help - but I'm not convinced by the Salary Table:
If it's 1to1 with Employee, why have it at all? It would be simpler to add a Salary field to the Employee table instead.
And what happens when a salary changes? Surely, you want to keep a number of salaries for people: could it change in mid month? If so, then half the monthly wage is at the old rate, and half at the new. Myself, I'd probably have a "effective from" date in a Nto1 salary table instead.
 
Share this answer
 

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