Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8589675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:06:49+00:00 2026-06-11T23:06:49+00:00

I currently have a table which represents the start and stop work times of

  • 0

I currently have a table which represents the start and stop work times of an employee:

  • id_employee int
  • check_in datetime
  • check_out datetime

It requires an update on check_out when the employee is finished.

Would it be preferable to have a table as follows ?

  • id_employee int
  • date_event datetime
  • event_type varchar, values can be CHECKIN or CHECKOUT.

To determine if an employee has already checked in all I have to is check if the last record for a given employee has an event_type of CHECKIN. Also, fetching a record and updating it is no longer necessary.

Is the second approach better ? Or do you have other suggestions ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T23:06:50+00:00Added an answer on June 11, 2026 at 11:06 pm

    As usual, “it depends”.

    Option 1 is easier to build, and simpler to query. Finding out who checked in but didn’t check out is a simple query; finding the total hours worked for each employee is also straightforward. This simplicity probably means it will be faster for common queries. The only drawback I see is that it is harder to extend. If you want to capture a different event type for “lunch break”, for instance, you have to add extra columns.

    Option 2 is more flexible – you can add new event types without changing your schema. However, simple queries – how many hours did employee x work in June – are quite tricky. You pay for the flexibility in significant additional effort.

    So, it depends what you mean by “better”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a (currently InnoDB) table which contains roughly 500,000 rows. This represents a
I currently have a table which only has a single editable column. I have
I currently have a user's table which contains a one-to-one relationship for Youtube OAuth
I have a table which is currently displayed like this: Question OptionType What is
I currently have a table of concentrations, which are linked to a table of
I currently have a table called paper , which holds all the information for
I have a table in MySQL 4.0 which currently has a year field as
I have an application in which I'm currently using a two column table in
I have a User entity which represents a User table in my database. This
I'm currently building a small database which represents a pipe network. I have divided

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.