Kola Oyedeji wrote: > > I would like to know if constraints other than keys are usually used?
I use them rather frequently. To do stuff like testing whether mutually exclusive fields are valid, from and to fields are in the right order etc. For the rest I will just presume you mean an index if you say key. If not, please elaborate. > I have > a database where the email address must be unique and was wondering if a > constraint should be used. I would go for a unique index. In general, I have invented my own little rule about constraints and indexes. If working vertically (checking a field against the same field in other rows) I try to use indexes (if working horizontally (checking a field against other fields in the same row) I have to use a constraint anyway so little point in making up rules about that). And to add to the confusion, if working with both or with multiple tabels, look up assertions in the manual (on a free day, not for this problem). > I could check for the existence of an email > address prior to inserting a new record but this involves another query. For which query you would want an index on that field anyway. > Alternatively i could attempt to insert a duplicate email address and catch > any database error generated as a result. If you can detect whether an insert errors because of the unique index that would be my choice. Jochem ______________________________________________________________________ Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/[email protected]/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

