2014-02-20 79 views
0

我想弄清楚如何正常化表中的一些數據。無論我如何嘗試,我仍然得到重複的團體!任何人可以爲我提供一些有關這些數據的指導嗎?從CSV數據規範化

這是我試圖標準化數據:

LANDLORD    LANDLORD GROUP     QUARTER YEAR ESTIMATED ACTUAL 
Housing Leeds   Yorkshire LL     3  2013 221   235 
Housing Leeds   Yorkshire LL     2  2014 206 
Manchester housing  Northwest housing associates 3  2012 134   130 
Liverpool properties Northwest housing associates 2  2012 539   592 
Liverpool properties Northwest housing associates 3  2014 567 
Manchester housing  Northwest housing associates 2  2013 157   157 
Liverpool properties Northwest housing associates 2  2014 527 
Housing Leeds   Yorkshire LL     3  2012 238   240 
Liverpool properties Northwest housing associates 4  2012 585   460 
Manchester housing  Northwest housing associates 1  2012 125   136 
Manchester housing  Northwest housing associates 3  2014 150 
Liverpool properties Northwest housing associates 3  2012 569   585 
Housing Leeds   Yorkshire LL     1  2013 195   214 
Manchester housing  Northwest housing associates 2  2012 132   140 
Manchester housing  Northwest housing associates 2  2014 152 
Liverpool properties Northwest housing associates 2  2013 555   577 
Housing Leeds   Yorkshire LL     3  2014 215 
Manchester housing  Northwest housing associates 4  2014 114 
Manchester housing  Northwest housing associates 1  2014 140 
Manchester housing  Northwest housing associates 3  2013 160   157 
Liverpool properties Northwest housing associates 3  2013 528   537 
Liverpool properties Northwest housing associates 1  2014 596 
Housing Leeds   Yorkshire LL     2  2012 226   231 
Manchester housing  Northwest housing associates 4  2013 111 
Manchester housing  Northwest housing associates 1  2013 135   136 
Housing Leeds   Yorkshire LL     1  2014 231 
Liverpool properties Northwest housing associates 4  2013 536 
Manchester housing  Northwest housing associates 4  2012 105   96 
Liverpool properties Northwest housing associates 1  2013 527   560 
Housing Leeds   Yorkshire LL     4  2013 226 
Housing Leeds   Yorkshire LL     2  2013 198   214 
Housing Leeds   Yorkshire LL     4  2014 235 
Liverpool properties Northwest housing associates 1  2012 494   536 
Housing Leeds   Yorkshire LL     4  2012 181   197 
Liverpool properties Northwest housing associates 4  2014 568 
Housing Leeds   Yorkshire LL     1  2012 201   209 

預先感謝任何幫助。

+1

到目前爲止您嘗試過什麼,以及您期望的結果是什麼?它看起來每行都是唯一的,你可以爲'Landlord'和'Landlord Group'創建一個查找表來節省一些空間。 –

+0

我認爲我通過嘗試過正常化而結束了複雜的事情。我創建了一個包含Quarter,Estimated和Actual的表格。然後我創建了季度和年份的另一張表格。我使用第一個表中的Quarter作爲外鍵。我想我正在努力減少季度和年度的重複。但是你使用查詢表的建議聽起來好多了。謝謝你的幫助。 – Durant

回答

0

正如Goat CO建議的那樣,您可以在這一個上創建兩個參考表,即LandlordLandLord Group。然後當然將它與主表聯繫起來。

所以,在這種情況下,你可以有三個表,即房東LandLordGroup,可能LandRental表。

你也許有這些TablesFields則:

Table : LandLord 
Fields : LandLordID, LandLordName 

Table : LandLordGroup 
Fields : LandLordGroupID, LandLordGroupName 

Table : LandRental 
Fields : LandRentalID, LandLordID, LandLordGroupID, Quarter, Year, Estimate 

不要隨便拿no repeating groups1NF(第一範式),這裏的規則,因爲這裏的重複的組現在從參考表中的所有foreign keys(即LandLord,LandLordGroup)。另外請注意,我現在在主表中添加了一個Primary Key(LandRentalID)(即LandRental)。

+1

謝謝你們的幫助。現在這個解決方案更簡單了。正如上面評論中提到的那樣,我正在過分複雜化。 – Durant