如何保存待定更改?

huangapple go评论62阅读模式
英文:

How can I save Pending Changes?

问题

我有一个 SQL 表格 Infos,用于存储一些用户信息,用户可以更新他的数据,但需要管理员首先验证,Infos 的主键在其他一些表格中被引用了很多次。

我的问题是应该在哪里存储需要验证的待定信息?

将它们存储为 JSON 列是一个好主意吗?

英文:

I have a SQL table Infos that stores some user information, the user can update his data but needs Administrator validation first,
the primary key of Infos is the referenced a lot in some others tables

Wy question is where chould I store the pending information that need validation ?

Is it a good idea to store them as JSON in a column ?

答案1

得分: 1

将此视为数据建模问题。如果用户信息在应用程序中使用之前需要验证,请引入一个名为Infos_UpdateRequest或类似的表,管理员可以使用该表,如果经批准,将值从该表复制到Infos。

英文:

Treat this as a data modeling question. If the user information requires validation before it can be used in the application, introduce a Infos_UpdateRequest table or somesuch, that the administrator can use, and if approved copy the values from there to Infos.

答案2

得分: 0

你可以创建一个与 "Infos" 具有相同模式的 "Infos_Pending" 表,并且主键也是对 "Infos" 的外键。这样,您的管理员可以加载待处理的记录:

  • 批准首先会使用 "Infos_Pending" 的值来更新 "Infos" 记录,然后删除 "Infos_Pending" 记录。
  • 拒绝只需删除 "Infos_Pending" 记录。
英文:

You could create an Infos_Pending table with the same schema as Infos and the primary key being also a foreign key to Infos. So, your admins could load the pending records:

  • approval would first update the Infos record with the Infos_Pending values and then delete the Infos_Pending record
  • rejection would simply remove the Infos_Pending record

答案3

得分: 0

我会考虑在您的表格中添加一个"待批准"和"是否激活"的列。这样可以很容易识别应该显示哪些行。您甚至可以保留旧的行以供撤销/历史记录之用。但这意味着您需要对显示层使用的存储过程/代码进行更改。除非您始终打算更改其中包含的整个值集,否则我建议不要使用json或xml。

英文:

I would look at adding a pending approval and is active column to your table.
It would then be easy to identify which of your rows should be displayed. You could even keep older rows around for undo/history purposes.
This would mean you'd need to make changes to the sprocs/code used at your display layer, though.
I would suggest not using json or xml unless it's a situation where you always intend to chnage the entire set of values in contains.

huangapple
  • 本文由 发表于 2023年1月9日 02:34:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/75050368.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定