Database: Two columns as primary key

lozina

Lifer
Sep 10, 2001
11,711
8
81
I've got a situation here where I need to have a unique constraint which works on two columns but one of the columns might be null... I know it doesnt work this way though, if its part of primary key it must also be not null, right?

so is there any clever workaround for this?

I guess one cheasy thing is to give column B a default of some stupid value for me to indicate it is empty but I hate that kinda hack.