Database , Employees with daily records [closed]
I am new to database, Please tell me how to make a database of Employee for Attendance, which contains a daily record of login/logout, please tell me how to manage 7 records (1 per day) for a single user, how to check this is new day and input will go to next day,
Thanks in advanced,
Simply, create one 'employees' table where each employe is identified by a unique field or primary key.
This table would typically contain the employee's name and additional contact info if you'd like.
Then we could just go with a simple logins table. Could be something like:
CREATE TABLE loginout (employeeID INTEGER NOT NULL, day DATE, login TIME, logout TIME,
FOREIGN KEY employeeID REFERENCES employees (employeeID ))
May want to add like a boolean field in the employees table 'isloggedin' or something to check for weather that employee is logged to handle error conditions, like if someone logs in and never logs out, then logs back in the next day. Stuff like that.
To check weather it's the next day already, then you'd use the 'day' field. You can get the current date in mysql (and other engines) with the NOW() function or you could get it client side to do comparison.
This question is pretty vague though, you should post your attempts at it and more specificially what aspect of it you're having trouble with.
精彩评论