SQL Server - Add allowance to employee table is wrong or true according to my case

Asked By ahmed elbarbary on 12-Feb-15 03:31 AM
Hi guys I have problem i need to make ERD relation entity
between employee and allowance
Employee table
Name
address
Basic Salary
Bonus

Allowance table
House rent
Food Allowance
Moving Allowance

Basic Salary is monthly and fixed
Bonus is monthly and fixed
food allowance is monthly and fixed for married employee
House rent is monthly and fixed for some employee and some employee take house rent two time in year every 6 month
every employee married take 3 months salary from basic salary in year
suppose i m married and i take basic salary 5000
i will take rent 5000 x 3=15000/12=1250 monthly
some employee take rent every half year meaning every 6 month
meaning 15000/2=7500


My question according to my case above
Which is best put allowance in table allowance or put allowance(food,housing,moving)
in employee table and what relation between two tables
Robbe Morris replied to ahmed elbarbary on 12-Feb-15 09:05 AM
Allowance type

AllowanceTypeID
Description
IsActive


EmployeeAllowance

EmployeeID
AllowanceTypeID
Amount
IsCurrent
StartDate
EndDate

Over the history of the employee, you'll need to be able to report on additional allowances.  Some will get added.  Some will need to be hidden from the user interface as they are no longer used.  All need to show up in historical reports.

Having an AllowanceType table lets you create an admin section in your application for users to administer current Allowance Types to use without having to alter the structure of a table when new allowances come into play in the future.

The EmployeeAllowance table stores all the different allowance types and current values for each over the history of the employee.  The IsCurrent bit column just makes it easier to run simple reports of the status of active employees.  Trust me, you'll need to report on  all of these scenarios at some time in the future if you do not already do so.

You may also need a separate table that contains AllowanceTypeID and an EmployeeTypeID if you need to permit certain allowance types for certain employee types.  For example, a CEO might be eligible for an automobile allowance but a receptionist probably wouldn't.