数据模型设计模式,保存数据更改直到得到另一个用户的授权

发布于 2024-11-05 15:31:52 字数 204 浏览 0 评论 0原文

在为需要数据更改经过授权级别的银行应用程序构建数据模型时,是否需要考虑某种设计模式?

例如,如果 admin1 更改了 customer1 的电话号码,则只有在 admin2 授权后,更改才会生效。

我们计划实现的解决方案是使用一个临时表来保存更改后的记录和更改后的值,一旦授权者批准更改,我们就会更新主表。当您的表很少时,这很有效,但随着表的增加,这会很麻烦。

Is there a design pattern to consider when building a data model for a banking application that requires data changes to go through an authorization level?

For example, if admin1 changes the telephone number for customer1, the change should not be effective until admin2 authorizes it.

The solution we plan to implement is to have a temp table to hold the changed record with the changed values and once the authorizer approves the change, then we update the main table. This works fine when you have few tables, but would be cumbersome as tables increase.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

不回头走下去 2024-11-12 15:31:52

我不知道任何设计模式,但我想我可能有另一个想法给你-
只有一张名为 'Pending_Changes' 的表,其中包含 'Table_Identifier''Column_Identifier' 'Record_Identifier' 列和“New_Value”
每行将代表某个表中某个记录的单列更改。
例如,值为 ('Customers', 'Phone_Number', '12345', '077-4453432') 的行将用于表示客户 12345 的电话号码的更改。< br>
这种方法的两个缺点是 -
1. 所有表都必须有一个 ID 字段
2. 对单个记录的更改可以跨越 PendingChanges 表中的多行,因为它为每个更改的列值保留一行。

从好的方面来说,它具有相当的可扩展性并且相当容易维护。

I'm not aware of any design pattern, but I think I might have another idea for you-
have just one other table, called 'Pending_Changes' with columns 'Table_Identifier', 'Column_Identifier' 'Record_Identifier' and 'New_Value'.
Each row will represent a single column change to some record at some table.
For example- a row with values of ('Customers', 'Phone_Number', '12345', '077-4453432') would be used to represent a change in the phone number of customer 12345.
The couple of downsides of this method is that-
1. all your tables must have a single ID field
2. a change to a single record can span multiple rows in the PendingChanges table, since it keeps a row for every changed column value.

On the upside- it's quite extensible and fairly easy to maintain.

橘味果▽酱 2024-11-12 15:31:52

当你的表很少时,这可以很好地工作,但随着表的增加,这会很麻烦

不一定。如果设计得当,它可以很好地处理大量表格。您可以构建一个漂亮且小型的数据模型来保存更改。它不需要您创建每个表的副本。

例如,您可以拥有如下表:AuditTables、AuditColumns、AuditChanges、AuditChangesDetails 等,并且您可以在该模型中存储所需的所有更改,而不是创建与“实时”表相对应的临时表。

This works fine when you have few tables, but would be cumbersome as tables increase

Not necessarily. It will work fine with a large amount of tables if you design it properly. You can build a nice and small data model just to hold the changes. It doesn't require you to create a copy of each table.

e.g. You can have a tables like: AuditTables, AuditColumns, AuditChanges, AuditChangesDetails etc. and you can store all changes you need in that model, rather than create a temp table which corresponds with the "live" table.

国产ˉ祖宗 2024-11-12 15:31:52

我设计了类似的东西,这就是它的要点;

  1. 我为每个想要进行行级版本控制的表创建镜像表。假设您有 CUSTOMER 表。您的镜像版本控制表将为 VER_CUSTOMER
    我想要进行行级版本控制的每个表都有一个名为 RECORD_ID (GUID) 的列。
  2. 当将记录插入该表时,我会生成新的 GUID 并填充该字段。新记录也插入到 VER_CUSTOMER 表中,其中 RECORD_ID 添加到表的自然 PK 中。
    当记录更新时,我再次生成新的 GUID。使用这个新的 GUID 填充 RECORD_ID。更新的记录也会进入 VER_CUSTOMER 表。
  3. 当记录被删除时,我将 CUSTOMER 表上的记录标记为 DELETED (不是物理删除记录)。我在每个表上都有 IS_DELETED 列。当尝试删除记录时,我将该列设置为 TRUE。同样,已删除记录的副本也会进入 VER_CUSTOMER 表。
  4. 因此,该表上的每笔交易都会在 VER_CUSTOMER 表中具有相应的记录,其中 RECORD_ID 和表的自然 PK 为 PK。例如,如果 CUSTOMER 表的 PK 是 CUST_ID。 VER_CUSTOMER 的 PK 将是 CUST_ID 和 RECORD_ID 的复合。

希望这有帮助...

I designed something like this and here's the gist of it;

  1. I create mirror table for every table that I want to have row level version control. Let's say you have CUSTOMER table. Your mirror version control table will be VER_CUSTOMER
    Every table that I want to have row level version control has a column called RECORD_ID (GUID)
  2. When a record inserted to that table, I generate new GUID and populate that field. New record also inserted into VER_CUSTOMER table with RECORD_ID as added to table's natural PK.
    When record is updated, I generate new GUID again. Populate RECORD_ID with this new GUID. Updated record also goes to VER_CUSTOMER table.
  3. When record is deleted, I mark record on CUSTOMER table as DELETED (not physically delete the record). I have IS_DELETED column on every table. I set that column to TRUE when record is attempted to be deleted. Again copy of the deleted record also goes into VER_CUSTOMER table.
  4. So every transaction that you have on that table, you have a corresponding record in VER_CUSTOMER table with RECORD_ID and table's natural PK as PK. For example if CUSTOMER table's PK is CUST_ID. PK of VER_CUSTOMER will be composite CUST_ID and RECORD_ID.

Hope this helps...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文