Jump to content

best way to store this?


thewood68

Recommended Posts

ok so lets say i have database that is storing different kinds of writing utencils (pens, markers, crayons, pencils etc...) and these are all user generated. after that they pick what they like using this utencil best for. example: crayons - coloring. pencils -math etc. but then someone else says they really like using pencils for drawing and ten people agree that they like using it for drawing but 100 say they like using it for math. i need to be able to store all the different uses for each item and how many agree with the use for that. whats the best way about doing that?

Link to comment
Share on other sites

i'd use

 

[pre]

utensil          utensil_usage          usage

--------          ------------            -----------

utensilID --+    id              +----- usageID

utensil    +---< utensilID        |      usage

                  usageID  >------+

                  usercount

Link to comment
Share on other sites

Sample data for each table

[pre]

utensil                          utensil_usage                            usage

----------+------------------+  +----+-----------+----------+-----------+  +-----------+------------------+

utensilID |  utensil        |  | id | utensilID |  usageID | usercount |  | usageID  |  usage          |

----------+------------------+  +----+-----------+----------+-----------+  +-----------+------------------+

    1    |  pencil          |  | 1  |    1    |    1    |    10    |  |    1    |  maths          |

    2    |  coloured pencil |  | 2  |    1    |    2    |    100    |  |    2    |  drawing        |

    3    |  crayon          |  | 3  |    3    |    3    |    50    |  |    3    |  blackmail note  |

    4    |  pen            |  | 4  |    4    |    4    |    200    |  |    4    |  writing        |

----------+------------------+  +----+-----------+----------+-----------+  +-----------+------------------+[/pre]

 

So 50 people like crayon for blackmail notes and 10 like pencil for maths

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.