CREATE TABLE article (
day integer,
is_chosen boolean
)
CREATE UNIQUE INDEX day_is_chosen_unique_index ON article (day, is_chosen);
The above will give me an unique index on the two columns, which means on a given day we can have one article that is chosen and one article that is not chosen.
I need to the unique index for the is_chosen field only. In other words, on any given day, we can only have one article that is chosen and multiple articles that are not chosen
Maybe something like this:
CREATE UNIQUE INDEX day_is_chosen_unique_index ON article (day, is_chosen true);
How would I go about creating this composite index?