What's the best way to store changes to database records that require approval before being visible?

前端 未结 8 1686
说谎
说谎 2020-12-07 13:44

I need to store user entered changes to a particular table, but not show those changes until they have been viewed and approved by an administrative user. While those chang

相关标签:
8条回答
  • 2020-12-07 14:32

    Definitely store them in the main table with a column to indicate whether the data is approved or not.

    When the change is approved, no copying is required. The extra work to filter the unapproved data is the sort of thing databases are supposed to do, when you think about it. If you index the approved column, it shouldn't be too burdensome to do the right thing.

    0 讨论(0)
  • 2020-12-07 14:33

    I work in a banking domain and we have this need - that the changes done by one user must only be reflected after being approved by another. The design we use is as below

    1. Main Table A
    2. Another Table B that stores the changed record (and so is exactly similar to the first) + 2 additional columns (an FKey to C and a code to indicate the kind of change)
    3. A third table C that stores all such records that need approval
    4. A fourth table D that stores history (you probably don't need this).

    I recommend this approach. It handles all scenarios including updates and deletions very gracefully.

    0 讨论(0)
提交回复
热议问题