|
Posted by --CELKO-- on 10/30/06 20:50
>> I would really like to know how you would validate this as a URL (or email address) in a constraint. <<
I would Google it and find this website, which is full of handy regular
expressions for my constraints. This page gives ten answers.
http://regexlib.com/Search.aspx?k=URL
I guess cowboys post first and Google later :)
>> The only way you are going to write a safe constraint like this is to use regular expressions and for that you'll need CLR. <<
No CLR, Tony. You need the SIMILAR TO operator in SQL-92 or a vendor
grep() functions such as Oracle and DB2 have. In SQL Server, you will
still have an ugly translation today. The x|y operator becomes <exp>
LIKE x OR <exp> :LIKE y and so forth. There was an old public domain
parser for grep() to SQL Server dialect, but I cannot find it on my
disk. It probably should be re-done with CASE expressions.
>> How would you write this constraint to truly validate the URL is valid and also protect yourself from a DBA making an accidental update (or malicious....)? <<
Nothing can protect you from a malicious DBA; with full DBA powers he
can destroy the world.
"On two occasions I have been asked, 'Pray, Mr. Babbage, if you put
into the machine wrong figures, will the right answers come out?' I am
not able rightly to apprehend the kind of confusion of ideas that could
provoke such a question." -- Charles Babbage
But you are confusing two different concepts; validation and
verification. A constraint can only validate a data element (This is a
syntactically correct URL) and verification (This URL actually belongs
to someone). Verification has to be external to the schema by
definition.
The way people verify a URL is to send an email to it. It is like
having a GPS tool or sextant to verify a (long, lat) location.
Navigation:
[Reply to this message]
|