Jump to content

MySQL structure and efficiency question


ViaoV

Recommended Posts

I have a question about keeping things efficient, as far as a database structure goes. I need to set up a page which will list several items orginized by catagory/sub catagory.  The logical idea would be to setup 3 tables as follows:

 

catagoryTable
-catagoryId
-catagoryName
-parent catagory (could be 0 if its a toplevel catagory)

itemTable
itemName
catagoryId

 

However all items are going to be displayed at the same time. So to accomplish this I'm going to have to make a call to get a list of parent categories, call each one to get a list of subcategories, then call each sub category to get a list of items. The categories have to be editable and the items have to be printed out by category. I have been trying to think of something like using DISTINCT somehow to not have to loop through so many queries. The category numbers are small like 10 parent, 1-5 sub in each, 1-15 items in each. The page will get slightly heavy use though so I was wondering if anyone knows a way to make something like that more efficient.

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.