View Full Version : relational database design - timesheet


JimSmith
11-08-2009, 09:42 AM
Hi,


I can't get my head around this very basic relationship between tables, and was hoping for some guidance.

I want to store the number of hours worked by each named person on each date. Many individuals can work on the same date. However I want to set up the relationships in the access database to ensure it is impossible to record more than number of hours worked per date per person.

My logic so far-

I need an employee table :
Unique employee id (primary key)
First name
Second Name
etc...


I need a hours worked table
Unique ID (primary key)
Date
Hours worked
Unique employee id

Then I would have a one to many relationship between the two tables linked on unique employee id.

But this is where I get stuck, as it doesn’t stop me entering hours worked for the same date twice for one employee.

I toyed with the idea of a 3rd table containing dates, but then I don’t know how to link these 3 tables.

Please can some one give me some guidance?

Many Thanks in advance

Jim

lagbolt
11-08-2009, 10:35 AM
Your HoursWorked table needs a new unique index on the Date and EmployeeID fields. Find the index button for the table in design view, create a name, add the fields, set the Unique property to 'Yes'.
The impact of this is that the table will not allow the duplicate entry.
Cheers,

JimSmith
11-08-2009, 12:15 PM
Many thanks for your assitance, and such a quick reply. That entirely solves my problem.

Thanks again!