PRIMARY KEY does not allow
NULLs. But a
UNIQUE KEY does. I suggest you try a simple table that has
B, each nullable, then
INSERT suitable combinations to see if they work.
UNIQUE(A,B) says that the pair is unique, while allowing either column to be repeated. Your Question is vague--is that what you wanted?
This will not check for "can't both be null"; that would have to be tested for at the application level.
Based on your Comment, you seem to be asking about the
WHERE clause of a
SELECT, not the table definition. And it seems like neither column should allow
CREATE TABLE ... (
vat ... NOT NULL,
ssn ... NOT NULL,
(or swap the two keys)
Then the application should decide which of these to use:
SELECT ... WHERE vat = ?
SELECT ... WHERE ssn = ?
SELECT ... WHERE vat = ? AND ssn = ?
depending on what is given in the