I am building an eCommerce website and there is a Category table in my MongoDB database which has a field called path. This field is used to store category hierarchy e.g Boots category will have /women/shoes/boots as the value in the path. I have a similar field in ElasticSearch as well. The path field helps me retrieve all the ads of a category and all of its child categories efficiently using regex. This design is based on Materialized Path Category Hierarchy approach described here: http://learnmongodbthehardway.com/schema/categoryhierarchy/
My question is is it a good approach while designing an eCommerce application to use category names in the path as apposed to category IDs. My concern is category names can change in future which will force me to change the path for all the ads that were created against those categories in ElasticSearch as well as in MongoDB. I am thinking instead of names /women/shoes/boots I use category ids to form the path like /1/13/209 but I am not sure if this could be a problem later on.
The other thing is what do I do when a category is deleted. I want to know what others do. Should I modify all ads or is there a better way to update ads with deleted/modified categories.
Thanks,