Jump to content

organization


nitch

Recommended Posts

simple question.  i am creating a site with a user system.  Each user will have their own page and be able to create their own information in different categories that will be stored on the database.  the only way i can think of to organize it is to have a separate table for each category and put every user's information into the table.  My question is a) could this cause significantly high load times as many users join and add information and b) if so is there a better solution?

 

sorry if thats confusing thanks for any help

Link to comment
Share on other sites

I would start with a structure like this:

 

Table users

user_id - integer, automatically incrementing

user_name - varchar

email - varchar

etc etc .. with all other information you want to keep for the user

 

Table categories

category_id - integer, automatically incrementing

category_name - varchar

and other information for each category

 

Table content

content_id - integer, automatically incrementing

user_id - owner of content

category_id - category of content

content - varchar

and other information regarding a piece of content

 

 

That structure makes it easy to add categories and users without creating new tables.

Link to comment
Share on other sites

hmm i dont think i explained my question very well.  That is the structure i have come up with.  Say i have a users table filled with users then i have 3 content tables content1, content2, and content3.  Each user will be able to add information to their account which add a row to one of the content tables.  If i had a large number of users with each user adding multiple rows to each of the content tables would this cause the script to slow down significantly? and is there a better solution?

Link to comment
Share on other sites

In time, it would of course slow down.  However, imo, (though I'm not some databse structure guru)  your structure looks decent enough.  The more you can spread the information into other tables, the better off you are going to be with load times if you are only accessing certain tables at a time and not all of them.

Link to comment
Share on other sites

I doubt you will see any slowdown unless you have hundreds or thousands of users creating content simultaneously.  I imagine any one user could not produce more than 1 piece of content every minute, and even that's being optimistic.

 

The structure I am suggesting is not the same as yours.  I am suggesting both a categories table AND a content table, but no others.  Instead of content1, content2 and content3 tables, I am suggesting a categories table containing the identifiers 1, 2 and 3, and a single content table containing all content.  My suggestion is more flexible, but yours may well be faster.  Seperating tables often gives speed benefits, at the cost of flexibility.

 

Can I clarify that your content1, content2 and content3 tables store different kinds of content?  Or are they a kind of load balancing system to store the same kind of content in seperate tables?

Link to comment
Share on other sites

ah sorry, i didnt understand your structure at first.  you are correct that the tables store different content.  In this case there would only be 3 or 4 different content tables that a user would be able to add information to so i don't believe having a separate categories table would provide a significant advantage.  it would definitely be nice if this site was producing a large enough userbase to have hundreds trying to access at once but that is definitely optimistic.  i suppose i could create a table of content for every user that joins but that seems unnecessary.

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.