I’m developing a real estate website and I liked to get your opinion/suggestion about the Url, SEO, Slug and how to show the items when using the id or slug.
The Url’s will be as follows:
http://www.site.com/region/ (displays all items in the region)
http://www.site.com/city/ (shows all items of the city)
http://www.site.com/category/ (displays all items in category)
http://www.site.com/child-category/ (shows all items of child-category)
http://www.site.com/region-or-city/category-or-child-category/item-title-34221/ (shows the item with id=34221)
At home page, I have a sidebar that has a list of regions and cities and the content has a list of all the categories with child-categories. When a user clicks a region, city, category or child-category, it will show the corresponding items.
For that I am sending a parameter through the Url to display the items (eg … ®ion = … / &city = … etc). All these parameters are ‘slug’ that are on the table items, where I have a field for each slug.
Here comes my first doubt, to do this, I had to add 5 extra fields to the table items, in order to do search. So my question is, should I continue this way, ie 5 extra fields in the table, where these fields contain slugs of the regions, city, category and child-category? Or should I switch to something like:
An extra table (eg. tbl_item_slugs) related with the table tbl_item and others if necessary, which will contain all items id and slugs and then use this id and/or slugs for search, eg:
tbl_item_slugs(item_id | region_id | region_slug | city_id | city_slug | …)
or something diffent like the user clicks on the region, city, category or child-category, then i save the id and/or the slug in the session, and in the list action, i get this values from session to search and show ?
Ofc, doing this keeping always in mind the performance/security of the application.