I'm looking for a solution to list and browse categories and subcategories and their records (classified ads), when you store category levels in separate tables. In the past I have worked with the adjacency model but I have to stick to this database setup now, and it is new to me. I'm using php and mysql.
The site is a classified ad site structured the common way: it has the main category list on its homepage, when you click one of the category links then only its subcategories are listed and the ads that belong to this category, and so on, at every level.
I'm a bit confused in the following areas:
How do you construct the category links when browsing categories in order for the script to know which table it should select categories from if I consider the below mysql structure? Do I need separate parameters at every category level I access like e.g: "mysite.com/?cat2=4" when accessing category "4" in the cat2 table and "mysite.com/?cat3=9" when accessing category "9" in cat3 table in order to identify category levels? If separate parameter not needed, then how can php and mysql tell what table you have to select the categories from?
And most importantly in this case, what is the best way to construct SEO friendly links? And how will mysql know which table to select categories from? I would like to use the most simplest solution that is possible like: mysite.com/electronics/television/sony. As far as I know, I have to include at least the cat_id somewhere in the link... where do I put it? and do I have to include the number of level as well? To complicate it more the category names are in foreign language with accented characters (though I created a function that changes accented characters into latin ones on the fly when generating category links) so I think it is best to select them by their ids.
How is a sample mysql select looks like that selects the child categories of a certain category?
How can I construct breadcrumb navigation?
MYSQL STRUCTURE:
Table "cat1" (main category):
cat1_id | cat1_name
Table "cat2" (subcategory):
cat2_id | cat1_id | cat2_name
Table "cat3" (subsubcategory):
cat3_id | cat2_id | cat3_name
Table "ads":
ad_id | cat1_id | cat2_id | cat3_id | ad_title | ad_description
Thanks and sorry for the long post.