I have a table which stores payments and want to ensure if the payment method is a credit card then the card type field should be IN ('Visa', 'MasterCard', 'Discover', 'American Express'), however if the payment method is not a credit card then the card type field should be NULL.
Will a check constraint allow me to use a statement like this:
(method = 'CC' AND cardType IN ('Visa', 'MasterCard', 'Discover', 'American Express'))
OR
(method != 'CC' AND cardType = NULL)
I might be totally off base with this one since constraints should maybe only be used to check 1 field (not sure).
Also if such a statement is allowed would there possibly be an adverse performance hit?
Edit: I plan on eventually creating a cardType field and have cardType in our payments table as a foreign key... this is just something I'm thinking of doing in the meantime