私は質問が完全に答えられたとは思わない。彼らは、プロパティテーブルのフィールド「名前」を編集する場合
...あなたは、プロパティ名の列を追加し、TestPropertyマッピングテーブルをドロップすることによって、テストテーブルのデザインを変更しませんか?
間違いなく。それは目的のために大規模な複製を追加するでしょう。
テスト時にデータの完全性(プロパティ)を維持する必要がある場合、正しい(データベース)メソッドは履歴テーブルを実装することです。これは、ソース表の正確なコピーと、1つの項目でなければなりません。TIMESTAMP列またはDATETIME列がPKに追加されます。
PropertyHistory
PropertyId AUTONUMBER,
Name CHAR
CONSTRAINT PRIMARY KEY CLUSTERED UC_PK (PropertyId)
PropertyHistory
PropertyId INT,
AuditedDtm DATETIME,
Name CHAR
CONSTRAINT PRIMARY KEY CLUSTERED UC_PK (PropertyId, AuditedDtm)
For this to be meaningful and useable, the Test table needs a timestamp as well, to identify which version of ProperyHistory to reference:
TestProperty
TestId
PropertyId
TestDtm DATETIME
The property names column would have to be something like a delimited list of strings.
That would break basic design rules as well as Database Normalisation rules, and prevent you from performing ordinary Relational operations on it. Never store more than one data value in a single column.
... or drop a row in the Property table
Deletion is something different again. If it is a "database" then it has Integrity. Therfore you cannot delete a parent row if it has child rows in some other table (and you can delete it if it does not have children). This is usually implemented as a "soft delete", an Indicator such as IsObsolete
が追加されました。これは、さまざまなSELECTSで使用されている行を除外して(新しい子を追加するために)参照されますが、既存の子の親として使用できます。
ローを非アクティブにするとは思わなかった。これは素晴らしいアイデアです。 –
また、ユーザーがプロパティ名を更新するたびにプロパティコピーを作成する場合、プロパティのすべての値をコピーする必要があります。 また、多対多の関係であるため、他のすべてのテストで新しいプロパティ名を使用するように設定する必要があります。 この場合、古いプロパティIDを持つすべてのエントリを複製し、新しいプロパティIDを使用するように複製を設定することによって、TestPropertyの他のすべてのエントリを更新する必要があります。 –