Need help with constraint to prevent overlaps - Mailing list pgsql-general

From Matthew Wilson
Subject Need help with constraint to prevent overlaps
Date
Msg-id slrng7en5p.6rt.matt@sprout.tplus1.com
Whole thread Raw
Responses Re: Need help with constraint to prevent overlaps
List 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

pgsql-general by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: lc_ctype and lower()
Next
From: Augustin Amann
Date:
Subject: Update / Lock (and ShareLock) question