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
https://forums.phpfreaks.com/topic/88421-best-way-to-store-this/
Share on other sites

i'd use

 

[pre]

utensil          utensil_usage          usage

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

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

utensil    +---< utensilID        |      usage

                  usageID  >------+

                  usercount

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.