I have a games table which holds the data about a game.
Then another table which holds the data about news.
So far so good.
First I thought about creating a junction table for game_news so I could relate news to games.
This way works as intended when the game exists. So whenever I insert a news I can relate it to a game using the junction table.
However there are cases when there is news about game but the game isn’t published and it doesn’t exists.
So my question would be; is there a way to relate these news to a particular game when the game record is created.
What is the best way to do this? Any ideas?
The junction table is the way to go. If a news article is about more than one game, then you need it. To handle games that do not exist yet, just insert a row for them, include all the info you currently know about it (possibly from the news article) and have a status column that marks it as not released yet. You can display this game as not released yet or rumor, etc.
set the tables up something like this:
With this setup you can have multiple games related to a single News item. Just insert all the proper GameNews rows to link each game to the News row.
If a game has not been published yet, you can still link it to news by creating the Games row with the status “N” or “R” (or something like that) and using the GameNews table just as you would for a published game. You could populate all the fields within Games with as much info as possible and update it as you find out more. in the end you would have complete game info in the Games row (after the game is published) and it would link to the all the News rows, even when it was just a rumor in the news.
To give you an idea about what I’m talking about, here is a sample of what the data for a “rumored” game would look like over time (this is a simplified example and without multiple Games per News rows):
if on 1/1/2012 you were to look at News.NewsID=543 you would see that it links to the complete and reviewed Games.GameID=1234, even though the News.NewsID=543 article is about a “rumored” upcoming version of God of War. And all this was done without making any changes to the old News or GameNews rows.