You might consider using a bit field to represent open/close hours for the
business and ''working'' or ''not-working'' for
an employee. Since you''re restricting it to 15 minute increments
that''s only 96 bits of data...
One upside to this is it makes it very quick to find overlaps or gaps as they
are bit-wise operations in the db. One drawback is it''s either
''on'' or ''off''... which may make your
lunchtime indicator problematic.
-p
On Aug 19, 2011, at 7:16 AM, Brett Hammond wrote:
> I have been googling for hours on this, what I am trying to do is
> build a application with the following criterias
>
> Employees
> Company
> Business Hours
> Shifts
>
> This will allow one user to create a business account with the ability
> to add other employees to the account, the one user will first create
> the businesses general business hours by selecting open and close
> hours for Sunday - Saturday. Then once the first user adds other
> employees to the business account, that user will be able to edit each
> employees shifts. The one user will be able to manage each of the
> employees entire day by 15 minute increments, this is going to be used
> for a calendering system.
>
> So lets say...
>
> Company A hours are 9am-5pm Mon-Fri
> Employee 1 hours are 11am-3pm Mon-Thurs
> Employee 2 hours are 9am-5pm Tues-Fri
> Employee 3 comes in at 9am but has to leave at 11am but comes back at
> 11:45am-5pm Mon-Fri
>
> and each employee needs to be able to have there lunch break blacked
> out whether that is a 15 min lunch or 60 min lunch
>
> Now the question is how would I go about designing the database
> (MongoDB) structure and models. I could build this out but I want to
> use the best practice from the start of the project since this will
> need to be scalable to hundreds of companies and thousands of
> employees. Everything that I have read leads no where. My thinking on
> this(I come from PHP background)
>
>
> Companies
> company_id
> name
> address
> ....
> ....
> Employees
> employee_id
> company_id
> name
> ....
> .......
>
> Hours (Just for the business hours)
> hour_id
> business_id
> either do a hours field that holds a array OR something like the
> following
> sun_open = 9:00:00
> sun_close = 17:00:00
> mon_open ...
> ......
> sat_close ...
>
> Shifts
> shift_id
> shift_name
> employee_id
> day
> month
> year
> start_time
> end_time
> THEN HERE IS WHERE I AM STUCK - Going back to Employee 3''s
> requirements:
>
> Employee 3 comes in at 9am but has to leave at 11am but comes back at
> 11:45am-5pm Mon-Fri
>
> How can I store it in the database for the 11am to 11:45 off period as
> well as a lunch break for each employee. I dont want to create
> seperate columns for each of the 15 min increments for each day. And I
> dont want millions of records in the database, also once the shifts
> are set they need to be able to be changed still be 15 min increments.
> Hopefully that is the best explanation for this problem any help would
> be appreciated!!! Thanks for your time in advance, I really do
> appreciate it!
>
>
>
>
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
> To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.