Need help with constraint to prevent overlaps

From: Matthew Wilson <matt(at)tplus1(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Need help with constraint to prevent overlaps
Date: 2008-07-11 13:14:33
Message-ID: slrng7en5p.6rt.matt@sprout.tplus1.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I'm building a shift-scheduling app. I want to make a constraint in my
database that prevents one human from being assigned to work two
different jobs at the same time.

In other words, if I schedule John Doe to mop bathrooms from 10 AM until
4 PM, some other manager will not be able to schedule John Doe for a 1
PM meeting.

How can I do this with constraints? Would I need to write a trigger
that does some 'select ... between ...' work?

I know I could do this in the python application code I am using on top
of postgres, but I really like putting as many constraints as possible
in my data model.

TIA

Matt

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adam Rich 2008-07-11 14:00:25 Re: Need help with constraint to prevent overlaps
Previous Message Augustin Amann 2008-07-11 13:07:28 Update / Lock (and ShareLock) question