数据模型设计模式,保存数据更改直到得到另一个用户的授权
在为需要数据更改经过授权级别的银行应用程序构建数据模型时,是否需要考虑某种设计模式?
例如,如果 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不知道任何设计模式,但我想我可能有另一个想法给你-
只有一张名为
'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.
不一定。如果设计得当,它可以很好地处理大量表格。您可以构建一个漂亮且小型的数据模型来保存更改。它不需要您创建每个表的副本。
例如,您可以拥有如下表:AuditTables、AuditColumns、AuditChanges、AuditChangesDetails 等,并且您可以在该模型中存储所需的所有更改,而不是创建与“实时”表相对应的临时表。
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.
我设计了类似的东西,这就是它的要点;
我想要进行行级版本控制的每个表都有一个名为 RECORD_ID (GUID) 的列。
当记录更新时,我再次生成新的 GUID。使用这个新的 GUID 填充 RECORD_ID。更新的记录也会进入 VER_CUSTOMER 表。
希望这有帮助...
I designed something like this and here's the gist of it;
Every table that I want to have row level version control has a column called RECORD_ID (GUID)
When record is updated, I generate new GUID again. Populate RECORD_ID with this new GUID. Updated record also goes to VER_CUSTOMER table.
Hope this helps...