I am scraping a website and basically, I have a table called games and a table called publisher. A game has_one :publisher.
When I find a game, say, Starcraft (with publisher Blizzard), I create a game with title Starcraft, and a publisher with name Blizzard. The problem this:
When I find another game by Blizzard, say Diablo, I create a new game with title Diablo and new publisher with name Blizzard. Now I have two publishers with name Blizzard. How can I ensure that both Starcraft and Diablo both point to the one and only Blizzard?
I though of searching through the database before creating a game, finding if a publisher exists and using that, and if it doesn’t exist then create one and then use it. But is this the normal/best way to do this?
Thanks
Yes, you find it first and if it does not exist, then create it: