[thelist] (SQL) Query with Multi FK's to the same lookup

Hassan Schroeder hassan at webtuitive.com
Wed May 19 11:37:34 CDT 2004


Tab Alleman wrote:

>>Frankly, if this were MySQL, at least, I'd redefine all the rating
>>columns to ENUM('Poor','Fair','Average','Good','Excellent'); you'd
>>use your existing numeric insert/update statements but would get a
>>string back on selects...
> 
> Hard-coding like this isn't desirable in this case because if I ever
> need to change "Excellent" to "Superior", for instance, I'd have to
> change it in all my SQL queries instead of in the lookup table.

Well, what I didn't say last time was that those terms shouldn't
be considered user-visible "output" anyway, but just pointers to
the *real* values.

As in, suppose your app suddenly needs to be bi-lingual, and you
might show one user "Superior" and another "Muy Bueno", or maybe
"Ausgezeichnet". In a servlet context you'd use a ResourceBundle
for this, but in pseudocode something like
	getRatingText("Excellent",locale)
would return the appropriate superlative depending on the browser's
locale/language choice.

Your current app may not be subject to internationalization, but
even so approaching it this way leaves that door open, as well as
making terminology changes like your example easier.

FWIW!
-- 
Hassan Schroeder ----------------------------- hassan at webtuitive.com
Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com

                           dream.  code.




More information about the thelist mailing list