views:

64

answers:

2

I am working on an attendance/overtime module for a schedule web app. The idea is that there is a table in MySQL of shifts, each shift having a start and end time. The manager will choose a shift and make an entry into the attendance table specifying whether the employee was early/late/left early/worked overtime. That entry in the attendance table is keyed to the shifts ID # (which is just an enumerated key).

But if someone comes in on their day off, there is no shift to key it to. What is a good system to use for those keys? Ccan I set up a conditional enumeration? And how do I avoid the risk of overlap with a shift ID? Adding the overtime shift back into the original schedule DB is not an option.

A: 

Similar to your previous question, if there is no data, then NULL is appropriate. In this case the work isn't attached to a particular shift so what else can you put there? And again the status should reflect this.

cletus
But if I use null, the key won't be unique. Isn't that an issue?
Anthony
actually, I just realized that it's a foreign key and that I can just have a separate enumerated column for the primary key. Thanks to you and Ryan for getting that to slip in to my head.
Anthony
A: 

What's wrong with adding an additional key to your enum column? That shouldn't hurt existing code, and seems the best solution to me.

Ryan Ballantyne