レコードごとに、「これはどのくらいユニークですか?」と尋ねます。次に、それに基づいて論理的に分解し始めます...
状態: 大量重複の可能性がある低固有のデータセット。ID 列を含む [State] テーブルを作成し、可能であればすべての可能な値を事前に入力して、非クラスター化インデックスのインデックスの断片化を減らします。
Create Table [dbo].[State] (StateID Int Identity, StateName Varchar(32))
Create Unique Clustered Index ix_stateID On [dbo].[State] (StateID)
Create Unique NonClustered Index ix_SN On [dbo].[State] (StateName)
ZipCode: 中程度の固有のデータセットであり、重複の可能性は十分にありますが、すべての ZipCode は単一の州に関連付けられています。繰り返しますが、これを事前に入力すると、進行性のインデックスの断片化を回避するのに役立ちますが、これがどれだけ速く成長すると予想されるかによっては、それがいっぱいになるのを待ち、定期的にインデックスを再作成するのが理にかなっている場合があります。米国の住所のみを追跡する場合は、最初の 5 桁のみを事前入力するだけで問題ありません (これを行う場合は、ZipCode 列を Int に変更します)。
Create Table [dbo].[ZipCode] (ZipCodeID Int Identity, StateID Int, ZipCode Varchar(16))
Create Unique Clustered Index ix_zipcodeID On [dbo].[ZipCode] (ZipCodeID)
Create Unique NonClustered Index ix_stateID_ZC On [dbo].[ZipCode] (StateID, ZipCode)
都市: このテーブルにはかなり大きなデータセットがありますが、まだ大量の重複の可能性があるため、もう一度 ID 値を作成しますが、今回は間違いなく事前入力しません。
Create Table [dbo].[City] (CityID Int Identity, ZipCodeID Int, CityName Varchar(64))
Create Unique Clustered Index ix_cityID On [dbo].[City] (CityID)
Create Unique NonClustered Index ix_zipcodeID_C On [dbo].[City] (ZipCodeID, City)
StreetAddress: これはアドレスを使用しない場合と同じように選択的ですが、同じアドレスから大量のメールを受け取る可能性があるため、ID 列を作成する必要があります。
Create Table [dbo].[StreetAddress] (StreetAddressID Int Identity, CityID Int, StreetAddress Varchar(256))
Create Unique Clustered Index ix_streetaddressID On [dbo].[StreetAddress] (StreetAddressID)
Create Unique NonClustered Index ix_cityID_SA On [dbo].[StreetAddress] (CityID, StreetAddress)
電話番号については、おそらく [AreaCode] と [PhoneNumber] で分けるので...
Create Table [dbo].[AreaCode] (AreaCodeID Int Identity, AreaCode Int)
Create Unique Clustered Index ix_areacodeID On [dbo].[AreaCode] (AreaCodeID)
Create Unique NonClustered Index ix_AC On [dbo].[AreaCode] (AreaCode)
Create Table [dbo].[PhoneNumber] (PhoneNumberID Int Identity, AreaCodeID Int, PhoneNumber Int)
Create Unique Clustered Index ix_phonenumberID On [dbo].[PhoneNumber] (PhoneNumberID)
Create Unique NonClustered Index ix_acID_PN On [dbo].[PhoneNumber] (AreaCodeID, PhoneNumber)
それから残りのために、単一の深さのルックアップ テーブル (サイズ、色、フォントなど) を作成します。
Create Table [dbo].[Characteristic] (CharacteristicID Int Identity, Characteristic AppropriateDataType)
Create Unique Clustered Index ix_characteristicID On [dbo].[Characteristic] (CharacteristicID)
Create Unique NonClustered Index ix_abrevCharact On [dbo].[Characteristic] (Characteristic)
最後に、あなたの最もユニークなアイテムである郵便物を手に入れましょう...
Create Table [dbo].[Letter] (LetterID Int Identity, Received DateTime, StreetAddressID Int, PhoneNumberID Int, CharacteristicIDs ...)
最も頻繁に実行するクエリに基づいて、[dbo].[Letter] テーブルで意味のあるインデックスを見つけます。効率的なクエリは、必要な結合とロジックを使用して適切なクエリを記述するのと同じくらい簡単です。:)
それが私の2セントです。