Renato De Giovanni <rdg@viafractal.com.br> writes:
> FOREIGN KEY (object_id, 'X') REFERENCES object (id, class_id)
Why not just store the class_id in the secondary table (if you're
concerned about space, consider using an int4 to represent class_id).
Then you can do a direct two-column foreign key constraint, plus add
a check constraint like CHECK(class_id = 'X').
regards, tom lane