I have a bit of a problem with an application I am designing. I was hopping someone on the list might have a brilliant idea for a work around.<br><br><b>Overview<br></b>My application lets users enter data in the form of drop down boxes (html select). These are generated from a database table where the value of each option is the primary key of the table and the value displayed to the user is the name column. For example this is the table of brands.<br>
<br>brand_id           name<br>1                      Apple<br>2                      Dell<br>3                      Gateway<br>4                      IBM<br>etc...<br><br>This part is simple enough. The code reads the database and generates the html markup to make the drop down select. The problem is I want to add the option to select None or Other. I have tried a few solutions but none seem to work well.<br>
<br><b>Option #1<br></b>I could add none and other to my brands table like this:<br>brand_id (pk)     name<br>
1                      Apple<br>
2                      Dell<br>
3                      Gateway<br>
4                      IBM<br>5                      Other<br>6                      None<br><br>The problem with this approach is I always want None (if present) displayed first and Other (if present) displayed last. The only way I can figure to do this is with some overly complex SQL or some post database data reordering. More problematic though is with other tables I am going to have different values for None and Other (the primary key is an autonumber). These values need to be consistant so that client side javascript can promt the user for additional information if Other is selected.<br>
<br><b>Option #2<br></b>I could leave the table alone and add in None and Other before the data is presented to the user. I could then use constants like None =  2147483646 and Other = 2147483647 (values that will never resonably be reached).This aproach makes client side scripting easier however it also means storing invalid data as foriegn keys in my table. It also seems unelagent somehow. For example my computers table would look like this.<br>
<br>computer_id (pk)           brand_id (fk)              name<br>1                                  1                              Macbook<br>2                                  4                              Thinkpad<br>
3                                  2147483647              Homemade Computer<br><br>(assuming the user selected other as a brand for #3).<br><br><b>Option #3<br></b>Store None and Other as negative numbers. This would still mean invalid forigne keys but it has the added benifit that an additional table could be created for other values like this:<br>
<br>other_id                 name<br>1                           None<br>2                           Other<br>3                           Davids Workshop<br><br>On the client side when someone selected other from a drop down list javascript could be used to replace it with a text box and then whatever the user entered could be added to the others table and stored as a negative number in the computers table. That way any negitive forign key would be redirected to the others table. its a huge hack but i think ti would work though it would mean doing some things in PHP rather than SQL so preformance would probebly be limited (or very complex sql).<br>
<br>Any other ideas? I don&#39;t really like any of these solutions they are just what iv come up with so far.<br><br>David<br>