design
のintention
になります。ここではいくつかは---多く---多くの外で取るアプローチ:
あなたは履歴テーブルを使用することができます。
-- stores info re:reason for the last update of a subscription
CREATE TABLE subscription_history (
subscription_id INT
, change_date DATETIME
, change_reason VARCHAR(255)
)
または参照と一緒に履歴テーブル:
-- stores info re:reason for the last update of a subscription
-- but links to a change_reason table for reason id lookups
CREATE TABLE subscription_history_L (
subscription_id INT
, change_date DATETIME
, change_reason_id INT
)
-- lookup table containing change reasons
CREATE TABLE change_reason (
change_reason_id INT
, change_reason VARCHAR(255)
)
または監査テーブルV1:
-- contains all columns in your subscription table plus audit fields
CREATE TABLE subscription_audit (
subscription_audit_id INT
-- All the fields from your `subscriptions` table
, audit_date DATETIME
, audit_reason VARCHAR(255)
, audit_by VARCHAR(255) -- example
-- etc etc whatever other information that is pertinent to the change
)
または監査テーブルV2:
-- this could also act like a history table, so you can change the table name/purpose
CREATE TABLE subscription_audit (
subscription_id INT
, modified_column VARCHAR(255)
, value_old VARCHAR(255)
, value_new VARCHAR(255)
, modified_date DATETIME
) -- Drawback here is that you'll have one audit record per column
-- , and you may have to add extra columns for other data types
-- , or convert your values to varchar or something else.. which isn't
-- a really good idea! I just want to present this in case you can
-- develop the idea you find interesting further
私はあなたのRDBMSを知らないが、これはほぼこれでは十分な柔軟性がありません
ありがとうございました。サブスクリプションのステータスを確認するには(たとえば、ログインしようとしているときなど)、SUBSCRIPTION_EVENT_MAPの最新の関連レコードをクエリしますか? – eoinoc
@eoinocはい、タイムスタンプによる最新のレコードです。 – Glenn