Is it acceptable to use id
in HTML forms and subsequent code processing (controller, view, model, repository layers)?
For example I need to show something like this on a web page:
Select Motor Choice:
* 460/50/3
* 380/50/3
* 460/60/3
In HTML this can be done with a radio
control, where each line has a value
attribute, which is not shown, and text
, which is shown on the screen.
I have above encoded in the database like so:
id, motor_description
1, "460/50/3"
2, "380/50/3"
3, "460/60/3"
I can use the id
for the value
in HTML radio
control, and i can use that id
internally as well in my Controller where I process the input to do lookup on the motor.
But since id
is a surrogate key, and it doesn't mean anything, will I do better instead to avoid using it, and instead to perhaps use more user-meaningful information, such as the motor_description
field to look up the data in the table and do other processing related to my business needs?
My concern here is ... even though I am using surrogate key in the database table, do I continue using it as well in the rest of my application, or is it best to avoid doing so?
In other words, do I let the database's surrogate key "spill out" into other aspects of my code, or do I avoid doing so?