Database design for multiple similar types? -


say have 2 question types: multiple choice , range. range question allows users answer specifying range of values in answer (1-10 or 2-4 example).

i inherited database answers these question types stored in same table structured so:

answers ------- id questionid choice range_from range_to 

this results in data below:

1   1   null   1     10 2   1   null   2     4 3   2   pants  null  null 4   2   hat    null  null 

does make sense include columns every answer type in answer table? or should broken out separate tables?

this slimmed-down version of real database. in reality there 8 question types, every answer there several columns left unused.

does make sense include columns every answer type in answer table?

this "all classess in same table" strategy implementing inheritance, suitable small number of classes. number of classes grows, might consider 1 of other strategies. there no predefined "cut-off point" - you'll have measure , decide yourself.

the alternative eav-like system as proposed blotto, shift enforcement of data consistency away dbms. valid solution if don't know structure of data @ design-time , want avoid dml @ run-time, if know structire of data @ design-time better stick inheritance.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -