son Posted June 15, 2009 Share Posted June 15, 2009 I have a form to upload photos with some basic info and would like to be able to select one or several main categories and/or sub-categories to place the image in. If photo is placed in sub-categories only it should also show in relevant main categories of chosen sub-categories later on in web page. How would it be best to set up the tables? Have a separate table for the photo-category combinations and then check in category table if it is a main category or sub-category? What would be best practise?Son Link to comment Share on other sites More sharing options...
justsomeguy Posted June 15, 2009 Share Posted June 15, 2009 Just have a field that holds the parent ID, so categories with a parent ID of 0 are top-level categories, and anything else should have the ID of an existing category as the parent ID to indicate that it's a child of that category. Link to comment Share on other sites More sharing options...
son Posted June 16, 2009 Author Share Posted June 16, 2009 Just have a field that holds the parent ID, so categories with a parent ID of 0 are top-level categories, and anything else should have the ID of an existing category as the parent ID to indicate that it's a child of that category.In the categories table and then have a photo_categories table to associate the photos with all relevant categories and sub-categories? Son Link to comment Share on other sites More sharing options...
justsomeguy Posted June 16, 2009 Share Posted June 16, 2009 If the photos can be in more than one category, yeah, you need another table for that. You need a photos table, a categories table, and a photo-categories table to hold the mapping. Link to comment Share on other sites More sharing options...
son Posted June 16, 2009 Author Share Posted June 16, 2009 If the photos can be in more than one category, yeah, you need another table for that. You need a photos table, a categories table, and a photo-categories table to hold the mapping.Cheers. Will have a go ...Son Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.