I put in a check constraint that only one row has the id equal to another column in the table. I created a function that included a subquery that counted the number of times in the table there was a row that had the id column equal to another particular column. Where it equals 1, all is good with the check constraint. Otherwise of course it shouldn't work. But I can't seem to get it to work right. When the first row is the row that has the equal values id=1 and the comparsion column in the same row equals 1, and no other columns have the id equal to the comparison column, it seems to work. But if I try to change it up and have for instance the first row not have this attribute but the second row for instance where the id =2 and the comparison =2, it does not work. It gives me an error that the check constraint failed. What am I missing here on how these check constraints work? Thanks.