I have to develop a web system. As every web system it has forms where the users will have to select one from many options, or many options altogether. They will also have a descriptive text and that data will be used in other parts within the system. So, it’s data to be stored in a database in an information system. However, I don’t know what’s the best practice regarding multiple options.
Let me give you an example. Suppose I have the following:
<select>
<option value="1">My first option</option>
<option value="2">My second option</option>
<option value="3">My third option</option>
</select>
This data is related to, say, a person. How do I represent this on my database? Should I use a separate table with the value id as the PK and a string with the description? Should I store the value only, the string only? I’m a bit lost here.
Thank you beforehand.
EDIT: My main concern is that creating an extra table will be a hassle. I’ll have to create a related object with its corresponding DAO that only one class will be using. However using other methods seems like it won’t escalate well and will create an overall mess.
Nevermind, I got my answer.
What I can do, instead of everything, and since I’m working in Java, is to use an
enuminstead. The data is unlikely to change in the long run, so this is my safest bet.