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 6376169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:42:39+00:00 2026-05-25T01:42:39+00:00

Does it make any sense to use bitfields to store and manage a schedule?

  • 0

Does it make any sense to use bitfields to store and manage a schedule?

I’m working on a Ruby on Rails application to handle restaurant opening hours and reservations, and I’m having some difficulty modeling schedule.

Each restaurant will have opening hours (like Monday 9am-12pm and 2pm-5pm) each day, and each table in the restaurant will have a size (2, 4, 8-seat, etc.) and its own openings.

So far, I’ve been using two tables to keep track of things:

opening_hours

  • day_of_the_week (string)
  • starts_at (time)
  • ends_at (time)

bookings

  • table_id (int)
  • starts_at (datetime)
  • ends_at (datetime)

With those tables, I can make sure new bookings don’t overlap other bookings for the same table and that the booking falls within an opening-hour range for that day of the week.

It’s problematic to find the open slots in the schedule, though. That is, given a set of opening hours and existing bookings, where are the gaps that could accommodate new bookings?

While looking through StackOverflow for inspiration, I came across this comment about using bitfields for schedules, and it piqued my curiosity. I don’t really know anything about bitwise logic, but I wonder if I could replace the above tables with something like:

opening_hours

  • day_of_the_week (string)
  • hours (96 bits, representing open/closed times for each quarter-hour of the day)

bookings

  • table_id (int)
  • date (date)
  • hours (96 bits, representing available/booked times for each quarter-hour of the day)

And then I could use bitwise logic (waves hands) and find the open, available times for a given day.

So my questions:

  • Would it make sense to do something like this?
  • Can anybody point me to a blog post or tutorial covering using bitfields for schedules?
  • What else should I look at to learn about bitfields & bitwise logic, specifically in the ruby/Rails realm?

thanks,

Jacob

  • 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-25T01:42:39+00:00Added an answer on May 25, 2026 at 1:42 am

    This seems like a strange way to store what are dates.

    Ask yourself what the behavior of the Restaurant or OpeningHours will be? I bet you’ll find yourself converting back to real date objects to implement that behavior. So why use a weird encoding in the database (day of week and bit string)?

    Additionally, do you ever intend to use SQL date operators to find what Restaurants or tables are open? That just got a whole lot trickier if it’s possible at all with your encoding scheme.

    I doubt you want to do this.

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

Sidebar

Related Questions

I'm working on a web based application that belongs to an automobil manufacturer, developed
Why does INDEX creation statement have UNIQUE argument? As I understand, the non-clustered index
I am trying to get PIL working with Django 1.2.1 and Python 2.7 on
I'am building a website where I need to make an url form article title.
I'm using Zend and want to know if there's any disadvantages to using it
i have an application that has a tabActivity and 3 tabs. all off the
ArrayList queryParms = new ArrayList(); StringBuffer sql = new StringBuffer(); sql.append( SELECT A.FLDREC_NUM, +
In C++, is a const method returning a pointer to a non-const object considered
What I'm trying is this: 1) Create a new manged object 2) Get it's
I've a method in a separate class from my main form that I've created

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.