alexobenauer Posted July 25, 2008 Share Posted July 25, 2008 I know my PHP but I am new at databases. I wanted to know how you would organize a database of users for an app that is supposed to hold a lot of information per user. For example, if every user has a bunch of clusters of data that need to be stored, and they can always add more so it needs to be dynamic. What would your organization be for this? Is this correct? A table holds all users, and every user gets a table of their clusters? Quote Link to comment Share on other sites More sharing options...
rawb Posted July 26, 2008 Share Posted July 26, 2008 A table holds all users, a table holds each 'cluster' item, and a table holds the associations. I.E. table users: id name 1 john 2 rob 3 matt table foods: id name 1 pizza 2 burgers 3 chicken table users_foods: user food 1 1 1 2 2 3 3 1 3 2 3 3 john likes pizza and burgers rob likes chicken and matt likes all three That's how I would do it, but I've also seen the associations stored in a text field with some type of separator (and this is probably faster because there are less queries/joins involved - I'm pretty sure I've seen this in phpbb's database design). For example 1:2:3 for matt and 1:2 for john above. Can anyone with more mysql expertise advise as to which method would be most logical and why, or present a better solution? Quote Link to comment 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.