[RESOLVED]How to store and present Key Pair Values

I’ve hit a conundrum…

I have a table with Computer Devices. you can have different types eg. PC, Server, Printers so forth..

against each Type theres values that needed to be captured.

eg. PC – typeId 1 , have RAM, HDD, CPU

      Printer – typeid 2, have IsColour, IsDuplex 

Based on the user’s selection, I want to render a partial view which holds a form to input those attributes.

How is this achieved? or can it be done any other way?

alphabeatsco

Based on the user’s selection, I want to render a partial view which holds a form to input those attributes.

with Ajax call an action that returns the correct view.

there are two common sql approaches. make a table and for for each device, which is practical if there is a finite number and you need custom markup for each device. of use a meta table (name/value). 

for name value, you would create a table that defines the attributes for a device. (device id, field id,  sort order, field caption, field type). then the view would load the rows for the device, and create a form.

to store in sql, you create a values table (instanced, device, field id, value)

if you are use a table store database instead of sql, then you just store the name/value collection.

if you are using a json database, you just build a json object (though you’d probably use a json object to store the device definition).

Yeah, I’ve taken into consideration on both strategies.

Neither of it sound easy enough.

Easier approach out of them, would probably be the table created for each device.

actually a third sql approach is to use an xml column to store the defs and values.

Is it eassy enough to query?

Eg. I want to know all devices that have HDD greater than 300gb

Hi alphabeatsco,

alphabeatsco

Is it eassy enough to query?

Eg. I want to know all devices that have HDD greater than 300gb

For this scenario, you need to have the logic to do that.

Best Regards

Starain

Leave a Reply