thewood68 Posted January 29, 2008 Share Posted January 29, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/88421-best-way-to-store-this/ Share on other sites More sharing options...
Barand Posted January 29, 2008 Share Posted January 29, 2008 i'd use [pre] utensil utensil_usage usage -------- ------------ ----------- utensilID --+ id +----- usageID utensil +---< utensilID | usage usageID >------+ usercount Quote Link to comment https://forums.phpfreaks.com/topic/88421-best-way-to-store-this/#findComment-452715 Share on other sites More sharing options...
thewood68 Posted January 29, 2008 Author Share Posted January 29, 2008 think you could dumb that down for me? Quote Link to comment https://forums.phpfreaks.com/topic/88421-best-way-to-store-this/#findComment-452804 Share on other sites More sharing options...
Barand Posted January 29, 2008 Share Posted January 29, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/88421-best-way-to-store-this/#findComment-452964 Share on other sites More sharing options...
thewood68 Posted January 30, 2008 Author Share Posted January 30, 2008 i havent ever used interacting tables so would there be anything extra other than setting assinging identical field names? Quote Link to comment https://forums.phpfreaks.com/topic/88421-best-way-to-store-this/#findComment-453054 Share on other sites More sharing options...
Barand Posted January 30, 2008 Share Posted January 30, 2008 see http://www.w3schools.com/sql/sql_join.asp Quote Link to comment https://forums.phpfreaks.com/topic/88421-best-way-to-store-this/#findComment-453209 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.