MySQL Lists are EOL. Please join:

List:General Discussion« Previous MessageNext Message »
From:lists.mysql-users Date:August 29 2005 8:48pm
Subject:Re: Mark a single row?
View as plain text  
Hallo Michael,

Op 29 Aug 05 schreef Michael Stassen aan lists.mysql-users@stripped:

 >>  >> 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 

Thank you very much!



--- GoldED+/LNX 1.1.5/050823
 * Origin: The Wizard is using MBSE/Linux (2:280/1018)
Mark a single row?lists.mysql-users29 Aug
  • Re: Mark a single row?Jasper Bryant-Greene29 Aug
Re: Mark a single row?lists.mysql-users29 Aug
  • Re: Mark a single row?Michael Stassen29 Aug
Re: Mark a single row?lists.mysql-users29 Aug