Hallo Michael,

Op 29 Aug 05 schreef Michael Stassen aan [EMAIL PROTECTED]:

 >>  >> I would like a single row in a table, and not more than one, to
 >>  >> be used as a preferred value in another application.
 >>  JBG> add a column 'preferred', tinyint(1) NOT NULL.
 MS> It's hard to say without knowing just what you mean by "used as a
 MS> preferred value in another application", but I suspect that adding a
 MS> whole column for this may not the best way to go.  You'd be storing a
 MS> lot of 0s just to keep one 1.  The simplest solution may be to code the
 MS> preferred row's id in your app.  Your instinct to keep this value in the
 MS> db is probably a better idea, however, especially if the preferred id
 MS> could ever change.

It won't change very often, but there certainly is a chance. That's why I 
decided to keep it in the database somehow, rather than hard-coding it. Also, 
this way the users can change it without having to mess with the code. The 
amount of 0s would not be more than about 40, so not a big disaster.

 MS> An alternative to adding a column would be to add a table.
 MS> Something like:
 MS>    CREATE TABLE pref_value (pref_id INT);
 MS>    INSERT INTO pref_value (pref_id) VALUES (id_of_preferred_row);

But this method is much more elegant. I wonder why I couldn't think of it 
myself...

Thank you very much!

Groetjes,

           Hans.

--- GoldED+/LNX 1.1.5/050823
 * Origin: The Wizard is using MBSE/Linux (2:280/1018)

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to