954,597 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

db design question

Hi all!
I need to allow a user to select a value from a few available options, and to store his selection in the "users" table. So far so easy. My problem is that I need to allow him also to select "other", and then he enters free text, that also should be stored. How should I design the tables and the querys to enable this?
Thanks a lot!
Daniel

dbrgdbrg
Newbie Poster
1 post since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

Create a table ("Options" or whatever) that contains a key, and a character column. Populate the table with the allowable values, including "Other".

Create a table ("Users") that contains (in addition to keys and other columns of interest) a number (not nullable, foreign key to the "Options" table) and a character column (nullable) to hold any typed text.

In your program (not your database design) populate a combo box that allows him to select values. Also in your program, write some code that tests the selected value from the combo box and get the key value from the "Options" table, and display another window/dialog to solicit some text for "Other" if necessary.

Store in your "Users" table the key of the option selected (including "Other") and the text if he typed any...null otherwise. Easy as pie.

BitBlt
Master Poster
711 posts since Feb 2011
Reputation Points: 367
Solved Threads: 109
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You