聯結表是要走的路。如果一篇新聞文章涉及多個遊戲,那麼你需要它。爲了處理尚不存在的遊戲,只需爲它們插入一行,包括目前所知道的所有信息(可能來自新聞報道),並且有一個狀態欄標記爲尚未發佈。有了這個設置
Games
GameID int not null auto increment PK
GameStatus char(1) not null "P"=published, "N"=not released yet, "R"=game is only a rumor
GameReleaseDate date null
GameName varchar(...) not null
GameDescription...
...
News
NewsID int not null auto increment PK
NewsTitle varchar(...) not null
...
GameNews
GameNewsID int auto increment PK
GameID int FK to Games.GameID
NewsID int FK to News.NewsID
你可以與單個新聞項的多個遊戲:可以顯示這個遊戲是沒有或謠言發佈等
的桌子了這樣的事情。只需插入所有適當的GameNews行,將每個遊戲鏈接到新聞行。
如果遊戲尚未發佈,您仍然可以通過創建狀態爲「N」或「R」的遊戲行(或類似的東西)並使用GameNews表格爲已發佈的遊戲。您可以使用盡可能多的信息填充遊戲內的所有字段,並在您瞭解詳情後進行更新。最後你會在遊戲行中有完整的遊戲信息(在遊戲發佈後),它會鏈接到所有的新聞行,即使它只是新聞中的傳聞。
爲了給你一個關於我在說什麼的想法,下面是一個「傳聞」遊戲的數據隨着時間的推移會是什麼樣子的示例(這是一個簡化的例子,沒有多個遊戲每行新聞) :
data as of 1/1/2010
Games GameID GameStatus GameReleaseDate GameName
1234 "R" 1/1/2012 "God of War 4"
News NewsID NewsTitle
543 "Future Of Games"
GameNews GameNewsID GameID NewsID
768 1234 543
data as of 4/1/2010
Games GameID GameStatus GameReleaseDate GameName
1234 "R" 1/1/2012 "God of War 4"
News NewsID NewsTitle
543 "Future Of Games"
544 "Interview with John Hight"
GameNews GameNewsID GameID NewsID
768 1234 543
769 1234 544
data as of 11/20/2010
Games GameID GameStatus GameReleaseDate GameName
1234 "N" 12/31/2011 "God of War IV"
News NewsID NewsTitle
543 "Future Of Games"
544 "Interview with John Hight"
545 "God of War Expected Next Year"
GameNews GameNewsID GameID NewsID
768 1234 543
769 1234 544
770 1234 545
data as of 8/15/2011
Games GameID GameStatus GameReleaseDate GameName
1234 "N" 12/01/2011 "God of War IV"
News NewsID NewsTitle
543 "Future Of Games"
544 "Interview with John Hight"
545 "God of War Expected Next Year"
546 "Retailers Get Ready For New Games"
GameNews GameNewsID GameID NewsID
768 1234 543
769 1234 544
770 1234 545
771 1234 546
data as of 1/1/2012
Games GameID GameStatus GameReleaseDate GameName
1234 "P" 12/01/2011 "God of War IV"
News NewsID NewsTitle
543 "Future Of Games"
544 "Interview with John Hight"
545 "God of War Expected Next Year"
546 "Retailers Get Ready For New Games"
547 "God of War IV Review"
GameNews GameNewsID GameID NewsID
768 1234 543
769 1234 544
770 1234 545
771 1234 546
772 1234 547
如果在1/1/2012你看News.NewsID = 543,你會看到,它鏈接到完成並審查Games.GameID = 1234,即使News.NewsID = 543文章是關於一個「傳聞」即將到來的版本的戰爭之神。所有這些都是在沒有對舊的新聞或GameNews行進行任何更改的情況下完成的。
我在考慮省略關係。這對我來說似乎是最好的方式。不過,假設我爲2年後創建的戰神4創造了許多新聞記錄。 現在遊戲發佈的年代將會創建,但我怎麼知道哪些記錄與遊戲相關?一些標籤系統可能?我真的不確定。 – Sinan 2010-04-16 14:53:18