在数据库上保留版本的最佳方式是什么? [英] What is the best way yo keep version on database?

查看:129
本文介绍了在数据库上保留版本的最佳方式是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要开发一个Web应用程序。
一个在不同地区销售不同产品的网路商店...

I need to develop a web application. A web shop that sell different product in different package in different region ...

管理员需要修改包裹,而最终用户无法看到他的修改。最终用户只能在管理员发布更改时才能看到这些修改。

The admin need to modify thoses packages while end users wont be able to see his modifications. end user will be able to see those modifications only when the admin will publish the change.

我的问题是我如何设计数据库(或webapp),以便管理员将能够看到应用程序的不同版本(工作版本),而最终用户会看到另一个版本(发布版本)?

my question is how can i design the database(or the webapp) so the admin will be able to see a different version (working version) of the application, while the end user will see another version (release version) ?

我正在考虑添加一个每个表上的字段version_id。
任何想法?咨询?链接?

i was thinking of adding a field 'version_id' on each table. Any idea? advice? link?

推荐答案

我会将预发布版本存储在一个单独的表中,然后更新live表,当管理员发布它。

I'd store the pre-publish versions in a separate table and then update the "live" table when the admin publishes it.

这样,您可以将表中的行数保持在常规读取(活动表)中,这将减少开销 - 如果是一个网络商店,每当有人访问该页面时,实时表将被读取。

This way you can keep the number of rows down in the table that's often read (the live table) which will cut down on the overhead - if it's a web shop the live table will be being read whenever someone visits that page.

如果您使用的是MySQL,您还可以优化两个表格,使现场版本使用MyISAM(松散地)更好地进行重读操作,并将管理员预发布表作为InnoDB表; InnoDB(再次松散地说)在较大的写入操作上表现更好。该发布前的表格一次只能被很少(甚至一个)用户访问(管理员),但是在发布之前可能会频繁更新用户,因为他们意识到他们错过了某些内容并进行了更改。

If you're using MySQL you could also optimise the two tables so that the live version is using MyISAM which is (loosely speaking) better for heavy read operations and have the admin pre-publish table as an InnoDB table; InnoDB is (again loosely speaking) better performing on heavy write operations. That pre-publish table will only be accessed by very few (or even one) users at a time (the admin/s) but it may be updated frequently before publish as they realise they've misspelt something and change it.

如果要整合完整版本的历史记录,您绝对需要一个单独的表格,因为您将最终会出现许多更多的预发布版本桌子比活的。

If you want to incorporate a full version history you definitely want a separate table as you're going to end up with many more pre-publish versions in the table than live ones.

这篇关于在数据库上保留版本的最佳方式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆