If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > need help creating a punch clock system

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-10-07, 06:44
demiurgen demiurgen is offline
Registered User
 
Join Date: Apr 2006
Location: Norway
Posts: 26
need help creating a punch clock system

i am trying to set up a mysql db for a simple punch clock system but i am unsure what is the best way to go about it.

it is just going to be a web interface with php, with an "in" button and an "out" button. and i just need the time a day when each individual clicks either button.

so i am thinking:
punch_clock(name, in, out)
is this going to be good enough??

i am not very good with db's but i would like to do it right... and as simple and clean as possible.

anybody know how i can set up a simple punch clock table/db???
Reply With Quote
  #2 (permalink)  
Old 06-10-07, 08:34
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Quote:
Originally Posted by demiurgen
punch_clock(name, in, out)
Ok, let's think of it this way.
Today I clock in at 10am and out at 2pm.
I do the same tomorrow.
Quote:
Originally Posted by georgev
George 10/06/2007 10:00 10/06/2007 14:00
George 11/06/2007 10:00 11/06/2007 14:00
I just violated your primary key.

You may wish to consider using a foreign key relationship.
Something like this may be acceptable depending on your requirements.
Code:
users(UserID, FirstName, LastName)
clocks(ClockID, DateTimeIn, DateTimeOut, UserID)
__________________
George
Twitter | Blog
Reply With Quote
  #3 (permalink)  
Old 06-10-07, 09:01
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,262
do you need to consider people who forget to clock in or out? if so how does your model allow for the fact that a retrospective adjustment is being made?

it depends on your requirements but do you want to have to look for a previous clock on to register a clock out event.

at first glance Id be looking for at least 2 tables

User
UserID PK
FName
SName....etc

ClockEvent
EventID PK
UserID FK in User
EventTimeStamp 'the time the event occurred according to the clock
ChangedBy 'something to record WHO/WHAT made changed (optionally FK to User)
RowTimeStamp 'date this row was last edited/changed (should be the same as the EventTimeStamp

you could if you required to also store an event type int he clockevents (eg IN, OUT, IN [adjusted], Out [Adjusted], OnBreak, OffBreak etc......)
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #4 (permalink)  
Old 06-10-07, 09:58
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,609
Is there a reason that you don't use one of the existing time clock routines? I think I've seen 10,000 posted in various source code archives over the last few years.

I'm too lazy to reinvent the wheel, unless I truly need a custom wheel for some reason.

-PatP
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On