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

  • SEARCH
  • Home
  • 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 6536113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:27:10+00:00 2026-05-25T10:27:10+00:00

I’m working on a project that must store employees’ timetables. For example, one employee

  • 0

I’m working on a project that must store employees’ timetables. For example, one employee works Monday through Thursday from 8am to 2pm and from 4pm to 8pm. Another employee may work Tuesday through Saturday from 6am to 3pm.

I’m looking for an algorithm or a method to store these kind of data in a MySQL database. These data will be rarely accessed so it’s not important performance questions.

I’ve thought to store it as a string but I don’t know any algorithm to “encode” and “decode” this string.

  • 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-05-25T10:27:11+00:00Added an answer on May 25, 2026 at 10:27 am

    As many of the comments indicate, it’s usually a poor idea to encode all the data into a string that is basically meaningless to the data base. It’s usually better to define the data elements and their relations and represent these structures in the data base. The Wikipedia article on data models is a good overview of what’s involved (although it’s way more general than what you need). The problem you are describing seems simple enough that you could do this with pencil and paper.

    One way to start is to write down a lists of logical relationships between concepts in your problem. For instance, the list might look like this (your rules may be different):

    • Every employee follows a single schedule.
    • Every employee has a first and last name, as well as an employee ID. Different employees may have the same name, but each employee’s ID is unique to that employee.
    • A schedule has a start and stop day of the week and a start and stop time of day.
    • The start and stop time is the same for every day of the schedule.
    • Several employees may be on the same schedule.

    From this, you can list the nouns used in the rules. These are candidates for entities (columns) in the data base:

    • Employee
    • Employee ID
    • Employee first name
    • Employee last name
    • Schedule
    • Schedule start day
    • Schedule start time
    • Schedule end day
    • Schedule end time

    For the rules I listed, schedules seem to exist independently of employees. Since there needs be a way of identifying which schedule an employee follows, it makes sense to add one more entity:

    • Schedule ID

    If you then look at the verbs in the rules (“follows”, “has”, etc.), you start to get a handle on the relationships. I would group everything so far into two relationships:

    Employees
        ID
        first_name
        last_name
        schedule_ID
    
    Schedules
        ID
        start_day
        start_time
        end_day
        end_time
    

    That seems to be all that’s needed by way of data structures. (A reasonable alternative to start_day and end_day for the Schedules table would be a boolean field for each day of the week.) The next step is to design the indexes. This is driven by the queries you expect to make. You might expect to look up the following:

    • What schedule is employee with ID=xyz following?
    • Who is at work on Mondays at noon?
    • What days have nobody at work?

    Since employees and schedules are uniquely identified by their respective IDs, these should be the primary fields of their respective tables. You also probably want to have consistency rules for the data. (For instance, you don’t want an employee on a schedule that isn’t defined.) This can be handled by defining a “foreign key” relationship between the Employees.schedule_ID field and the Schedules.ID field, which means that Employees.schedule_ID should be indexed. However, since employees can share the same schedule, it should not be a unique index.

    If you need to look up schedules by day of week and time of day, those might also be worth indexing. Finally, if you want to look up employees by name, those fields should perhaps be indexed as well.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
i got an object with contents of html markup in it, for example: string
I am reading a book about Javascript and jQuery and using one of the
I need a function that will clean a strings' special characters. I do NOT

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.