SQL design: many attributes for each row -
i've seen couple of other questions asking similar (notable this one), i'm after more focused advice on pros/cons of 2 options. i'd find useful if has had experience situation , through experience found 1 of these solutions better other.
i'm trying store data on set of events , attributes, each event has multiple attributes, , set of attributes open increase time goes on. we're talking 100+ attributes here. see 2 options here:
1) single table many columns
an 'eventtable' 1 column each attribute. example, columns be: eventid, eventname; , attribute columns example waseventgood, dideventfinish, peopleatevent, etc. if add attributes can add columns table.
pros: nice view of event , attributes on 1 row. simpler?
cons: i've read having many columns in table sign of bad design. insert statement many columns awkward?
2) 'tree' type design multiple tables linked
so example:
eventtable columns: eventid, eventname
attributetable columns: attributeid, attributename
eventattributetable columns: eventid, attributeid, attributevalue
so 4 different attributes , 5 events, have 5 rows in eventtable, 4 rows in attributetable, , 5*4=20 rows in eventattributetable
pros: seems more logical design, tables many rows 'cleaner' many columns?
cons: difficult replicate view option 1 gives me (1 row per event attributes separate columns) without hand coding messy view. simple inner join not result in 1 row per event here.
so, question is: has else encountered problem , gone 1 of solutions? analysis correct? appreciate if benefit of experience let me know of options found easiest work with. seems design choice common.
Comments
Post a Comment