Is there a way to create a unique index on two integer fields, such that a given integer can only appear once in one of those fields? I.e.
+------+-------+
| Left | Right |
+------+-------+
|    1 |     2 |
|   *2*|     3 | < INVALID
+------+-------+
EDIT: note, the left..right range should still be able to contain other ranges in their entirety:
+------+-------+
| Left | Right |
+------+-------+
|    1 |     4 |
|    2 |     3 | < VALID CHILD
+------+-------+
I'm using Rails 4 and Postgres 9.2.
 
    