用户数据的版本控制存储库
关于如何对 mysql 模式进行建模以在版本控制下存储用户内容的工具或指南是什么?与 svn 存储库类似,但我需要对所有用户对象进行版本控制,而不是代码。比如用户两年前的这个日期有哪些照片。他有什么设置等等。是的,我可以在表中存储备份副本,但问题是由于不同类型的对象而涉及数百个表。我现在每天都会拍摄照片,并计划在以后的每次编辑中实现它。所以基本上我想知道 svn 存储库如何在数据库中存储内容,或者 Windows 如何在某些数据库中存储恢复点,以便我可以模仿用户数据的模型。对我来说唯一的要求是我需要使用 mysql 作为主数据库。我的看法是:
活动数据和历史数据。活动数据具有当前副本。历史数据按日期/时间索引。但仍然每天为每个用户维护数百个表数据,这意味着我需要版本控制 365 x 用户数 x 表行数。我不知道 3NF 中的 mysql 中的 moeling 是否是最好的方法?
What tools or any guides on how to model my mysql schema to store user content under version control? Similar to a svn repository but instead of code i need to version all user objects. Like what photos did the user have 2 yrs ago on this date. What settings did he have, etc. Yes i can store backup copies in tables but the problem is there are hundreds and hundreds of tables involved due to different kinds of objects. And i will be taking shanpshots each day for now and plan to implement it with each edit later. So basically I am wondering how svn repository store content in the databse or how does windows store restore points in some database so i can mimic that model for user data. Only requirement for me is i need to use mysql for the main database. the way i see it is:
Active data and Historical data. Active data has current copy. Historical data is indexed by date/time. But still to maintain hundreds of table data for each user each day that mean 365 x number of users x number of table rows i need to version. i dont know if moeling it in mysql in 3NF is the best way to go?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以简单地在每个数据库条目中添加一个时间戳字段。然后进行延迟删除而不是删除数据,即有一个“已删除”字段,该字段再次可以存储删除的时间戳。这些结合起来将允许您进行历史查询。
当您从历史快照中实现这一点时,您可以根据您看到的第一个/最后一个快照来估计时间戳,并相应地修改数据库条目。
You could simply have a timpstamp field along with every database entry. Then do lazy deletion instead of deleting the data, i.e. have a "deleted" field which again can store a timestamp of the deletion. These combined will allow you to do historical queries.
When you get to implementing this from historic snapshots, you can estimate a timestamp based on the first/last snapshot you see an entry in and ammend the database entries accordingly.
版本控制是一个不小的问题。人们已经通过多种方式解决了这个问题,但自己正确地重做却绝非易事。 Eric Sink 写了一篇关于他自己的版本控制软件开发的非常好的博客,其中对复杂性有一些了解
您的具体问题将是数据量,因为您的许多文件都是二进制文件,VC 系统无法有效地存储这些文件,因为它们主要设计用于处理文本。除非你有一个非常好的差异引擎,否则很快你就会得到太多的数据需要处理。
我的建议是集中精力将您的软件与已经有人完成艰苦工作的东西(例如 Subversion、Git、Mercurial 或其他可用的优秀源代码控制工具之一)连接起来。您可以使用它们作为存储库来存储所有文件并对其进行版本控制,并在其上构建您的软件以理解这一切。
要构建高效的版本控制系统,您需要真正了解自己在做什么,为什么不重用专家创建的内容。
如果你仍然热衷于自己做这件事,你可能会做得比Eric Sinks Source Control How-To<更糟糕/a>
Version control is a non-trivial problem. It has been solved in numerous ways but redoing it yourself correctly is far from trivial. Eric Sink writes a very good blog on the development of his own version control software which gives some little idea of the complexity
Your particular problem will be volume of data, as many of your files will be binary which are not stored as efficiently by VC systems since they are designed primarily to deal with text. Very quickly unless you have a very good diff engine you will end up with too much data to be work with.
My suggestion would be to concentrate on interfacing your software with something where someone has already done the hard work such as Subversion, Git, Mercurial or one of the other excellent source control tools available. You could use those as your repository to store and version all the files and build your software ontop to make sense of it all.
To build an efficient version control system you need to really know what your doing, why not reuse what the experts have created.
If you are still gung ho on doing it yourself you could do worse than Eric Sinks Source Control How-To