View Single Post
  #2 (permalink)  
Old May 2nd, 2012, 04:10 PM
Rod Stephens's Avatar
Rod Stephens Rod Stephens is offline
Wrox Author
Points: 3,166, Level: 23
Points: 3,166, Level: 23 Points: 3,166, Level: 23 Points: 3,166, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

Sorry but both of those look valid to me. But I've seen some posts that say MySQL doesn't support CHECK constraints. See this thread:

http://forums.mysql.com/read.php?136...474#msg-152474

Be sure to read the replies. They say you may be able to use a trigger to perform the job of the CHECK constraint.

In this case you could also build a lookup table and use it as a foreign key to validate the field. That seems like serious overkill but it should work.
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)
The Following User Says Thank You to Rod Stephens For This Useful Post:
masterlayouts (May 3rd, 2012)