I have an articles table that references a categories table. I'm defining the foreign key like this:
constraint fk_categoryid foreign key (categoryid) references categories (categoryid)
on update no action
on delete no action
Is it possible in the foreign key definition to restrict the categories that can be referenced based on another column in the categories table? For example, say there is a hasarticles column in the categories table. I'd like the foreign key constraint to be restricted to those categories where hasarticles = true.