Jump to content

Organization for Scalable app


alexobenauer

Recommended Posts

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?

Link to comment
Share on other sites

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?

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.