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
https://forums.phpfreaks.com/topic/85141-mysql-structure-and-efficiency-question/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.