繁体   English   中英

数据库技术,用于编辑记录并确保在记录获得批准之前不更新记录

[英]Database technique for editing records and ensuring record is not updated until the record is approved

在以下情况下,您将如何处理情况?

您有一个包含客户记录的表,其中包含以下字段:

id, name, email, phone
1, John, john@example.com, 515-222-3333
2, Smith, smith@example.com, 515-333-444

约翰打开记录并更改他的电话号码。 但是,在管理员批准更改之前,不应更改客户的实际记录。

您将如何处理这种情况?

你会?

a. Create an exact replica of customer table called customer-temp
b. Copy the record of John into customer-temp
c. let the admin review the updated record in customer-temp
d. once approved, the record is replaced with the record of john in customer table and remove John's record from customer-temp

这是最好的解决方案还是有更好的方法来解决呢? 如果客户表中还有其他一些表,该怎么办?

专家建议,将不胜感激。 仅供参考,我使用Postgresql数据库。

-----更新格式-

对于每个需要审查的属性,我都会有一个附加属性。

在您的示例中,条目可能是:

id, name, name_tmp, email, email_tmp, phone, phone_tmp

name将包含批准的名称, name_tmp用户已编辑的名称。
批准后,将name_tmp的内容复制到name

这样,您在外键关系方面就不会有任何问题。

如果您确实不希望在主表中使用该属性,请像您建议的那样创建一个customer_temp表,其中id为主键,外键引用customer 缺点是您需要以这种方式在查询中添加更多联接。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM