I want to have a SQL table with two columns. One of them is the key to another table, the other is a string literal. The idea is that phone numbers can be entered exactly (in this case, the identifier is used in the phonebook table) or as a template (which uses a string literal).
This means that one column in the table will contain a value and the other will contain NULL.
Is it possible to restrict a table so that one column must have a value and the other should be NULL? If both columns are NULL or both are value, then the row is invalid.
I have a feeling that MySQL cannot do this (since it does not have complex tools when it comes to restrictions), but that does not hurt to ask.
source share