I'm creating an app that will import products from several XML feeds. In
the XML there is a category specified, like T-Shirt for instance. The
problem is that different resellers specify the categories differently. For
instance, what one reseller calls "T-Shirts" another may call "T-Shirt", a
third "short sleeved shirts" and so on.
I want to somehow map these categories to the categories I have myself. So
I need some tips on how I should create my database.
The idea I have is to create a "raw_categories" table which contains the
name of the resellers category and a "category_id" which has a belongs_to
relationship to my own "categories" table. Then when I import I simply try
to find a raw_category which has a matching name and if there is one, pick
it, otherwise add a new one. This new one I can then manually relate to one
of my own categories.
Do you understand how I mean, and is it a good approach? Is there a
better/more efficient way?
- If this is a good idea. How do I do it in Rails? Should I use something
like this (I think I've seen something like this in the API doc):
# products model
has_one :category, :through => :raw_categories
I estimate that there will be about 40k to 100k products in the database.
Regards
Linus
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/zGGWZr75nPMJ.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.