sql - 80 3 column rows, or 1 81 column rows -


i have data store,

i must store data every user,

the data more or less

key: 0   value: 107,  key: 1   value 213 

there 80 key/value sets per user

so question is,

do have 1 row basically

user_id key1, key2... key80 

or have 80 rows of

user_id, key, value 


data must store:
can see actual data must store here: http://219.89.41.169/reachapi/?gt=the%20hailwood

i cant copy/paste approx 8mb of data, page may take while load.

but can see given data in format, hence why must store way.

i'd cringe @ thought of 81 columns in table. however, if:

  • the number of keys/fields unlikely change, and
  • all of fields relate directly user, , apply every user, and/or
  • you're need query more 1 key @ time given user,

then makes more sense have many columns store each user/key combo own row. type safety, ability constrain , index data better, , query user's stats without needing dozen joins (or getting bunch of rows have assemble data structure).

if number of fields in flux, or fields don't apply (ie: users have different numbers of fields), or never want know more user 3225's value field 53, user/key/value table makes more sense. it'll pain in ass keep correct, updates take forever (because indexes need redone, , you need indexes), , queries hideous if ever need more 1 or maybe 2 fields @ time.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -