![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
This isn't the way I would have done it, ... |

|
..restricted to a list of countries in the world. |

#3
| |||
| |||
|
|
Can anyone suggest a better way? |
#4
| |||
| |||
|
|
Can anyone suggest a better way? 1) Do a web search about "Normal Forms" and get a book about database design 2) Look up standards. Postal codes have standards. There are ISO country and location codes. A database can enforce them by DRI and CHECK constraints. 3) Do not confuse the front end (reporting / presentation layer) with the backend (database). How you print addresses on paper, based on local needs is a matter of the reporting tools and not the database. Sorry, but there are fundamental problems with your design. brgds Philipp Post |
#5
| |||
| |||
|
|
This isn't the way I would have done it, *... That is being kind ![]() Try the "CHECK()-from-hell approach" ..restricted to a list of countries in the world. * As opposed to those countries that are somewhere else? ![]() *CONSTRAINT GenralAddressValidation CHECK( CASE county_code * * * * * * * WHEN *'xx' * * * * * * * THEN (CASE WHEN line1 NOT LIKE ..THEN 'F' * * * * * * * * * * * * * * * * * * WHEN line2 NOT LIKE ..THEN 'F' * * * * * * * * * * * * * * * * * * *..END) * * * * * * * WHEN *'yy' * * * * * * * THEN (CASE WHEN line1 NOT LIKE ..THEN 'F' * * * * * * * * * * * * * * * * * * WHEN line NOT LIKE ..THEN 'F' * * * * * * * * * * * * * * * * * * *..END) * * * * * * *.. ELSE 'T' END = 'T') This is a pain to write, but the idea is to give each country its own second level CASE expression. |
|
..restricted to a list of countries in the world. As opposed to those countries that are somewhere else? ![]() Yup. You could restrict the selection to the list of countries in |
#6
| |||
| |||
|
|
Love it or hate it, the information is stored in that structure. *My question is, GIVEN the existing structure, what is the best way to put some referential integrity in? * |
#7
| |||
| |||
|
| Love it or hate it, the information is stored in that structure. My |
#8
| |||
| |||
|
|
However, when I recommend this to you, xyzzy, I think you will treat my suggestion with the caveat it deserves. BTW, I'm sorry you're stuck in a database that resembles a bunch of twisty little passages, all different. ^^^^^^^^^ |
#9
| |||
| |||
|
|
"Walter Mitty" <wamitty (AT) verizon (DOT) net> wrote: [snip] However, when I recommend this to you, xyzzy, I think you will treat my suggestion with the caveat it deserves. BTW, I'm sorry you're stuck in a database that resembles a bunch of twisty little passages, all different. ^^^^^^^^^ Aren't they all the same? Over and over again. It is hardly that it has never been seen before. For those who have led a sheltered life: Announcing a new beginning for Entity Attribute Value DBMSs: EVE. Do not put your constraint handling under one roof when you can apply it all over on the eaves. Applications are for applying. ... Excuse me. I am getting ill. You should, too. |
#10
| |||
| |||
|
|
"Walter Mitty" <wami... (AT) verizon (DOT) net> wrote: [snip] However, when I recommend this to you, xyzzy, *I think you will treat my suggestion with the caveat it deserves. *BTW, I'm sorry you're stuck in a database that resembles a bunch of twisty little passages, all different.. *^^^^^^^^^ * * *Aren't they all the same? *Over and over again. * * *It is hardly that it has never been seen before. * * *For those who have led a sheltered life: * * *Announcing a new beginning for Entity Attribute Value DBMSs: EVE. Do not put your constraint handling under one roof when you can apply it all over on the eaves. *Applications are for applying. ... *Excuse me. *I am getting ill. *You should, too. Sincerely, Gene Wirchenko Computerese Irregular Verb Conjugation: * * *I have preferences. * * *You have biases. * * *He/She has prejudices. |
![]() |
| Thread Tools | |
| Display Modes | |
| |