views:

21

answers:

1

I had following business logic. In this Op1 and Op2 represents some operation. And param1,param2,... represents parameters required for executing these operations

Op1=param1, param2 Op2=param1, param2, param3

Now in UI I had a drop down list containing "Op1" and "Op2". Following should happen based on my business logic 1) If I select operation as "Op1" there should be 2 text fields enabled on UI corresponding to param1 and param2. Similarly for "Op2" there should be 3 text fields

Now once user enters data I need to persist the data hence in my DB 1) Corresponding to "Op1" I should store value of param1 and param2 2) Corresponding to "Op2" I should store values of param1, param2 and param3

Please guide me how can I achieve this?

A: 

Well I'm no db expert, but probably you would have a table for Ops with whatever pertinent info

OpId    OpName    Permissions....
0001    doStuff   001001001...

And you'd have a table for params

ParamId    ParamName    Desc...
0001       param1       whatever...
0002       param2

And finally a many-many relation table

OpId    ParamId    ParamValue
0001    0001       value1
0001    0002       value2

This would work if you have a common set of Operation, and parameters. However, it maybe overkill. Also, if you're params are never reused (ie. param1 for op1 doesn't mean the same thing as param1 for op2, then you wouldn't store them in a separate table.

Java Drinker