I'm creating a multiple catalogue database that will serve multiple sites, each site being assigned the id of the catalogue it will use.
For the categories in each catalogue I'm using the id / parent id scheme that Drawmack showed me about a year ago (and have used loads since)
id pid name
9 0 electricals
11 9 fridges
Which is fine for one catalogue because when you display the top level you just check for all categories with a pid of zero.
To adapt this to a multi-catalogue scheme I've got two choices - add an extra field to the categories table saying which catalogue it belongs to, then on entry search for all categories for this catalogue with a pid of zero - thing is, the catalogue field isn't really necessary after that as you travel down the category tree.
Option two, when a new catalogue is added, create a category that will be the top level for that catalogue and assign that to the catalogue. Then all its top level categories would use that as their parent.
Catalogues
id name toplevelcat
3 site1 883
I know bulking the table with the extra field won't be that expensive, as I can't see there being more than a few thousand categories. Plus having the extra field would be useful for tracking orphaned entries if errors happen due to corruption. But I'm a swine for the optimisation, so would like a few oppinions on this.
Cheers.