数据库中的两阶段数据编辑
出于该问题的目的,让我们假设我有一个博客应用程序,其中包含博客和与博客相关的博客子条目。我的数据存储在数据库中的两个单独的表中:Blog 和 BlobSubEntries,并且我在 Blog 上的 BlogSubEntries 中有一个外键。这两个表都包含可以编辑的数据。
现在我的网站查询该数据库以显示博客。我还有一个 cms 来编辑博客条目。我不想在 cms 中放置保存按钮,因此我想将所有编辑发送到服务器,但不希望在博主实际决定发布作品之前这些数据可供网站使用。
这里有一些需要考虑的事情:
- 我不想对数据库进行数百万次查询。
- 我希望旧数据在编辑期间可用。
- 我正在将 django 与关系数据库一起使用
在这个冗长的介绍之后,这里是我的问题:
- 您将如何处理数据的两步暂存(考虑有两个模型彼此相关的事实)?
- 如果我想将这个暂存过程发展为版本控制怎么办?
- 我最近读了一些关于 CouchDB 的文章,文档数据库会简化此类问题吗?如果是这样怎么办?
感谢您抽出时间。
For the purpose of the question, let's imagine that I have a blogging application which consists of blogs and blog sub-entries related to the blog. My data is stored in a database in two separate tables: Blog and BlobSubEntries and I have a foreign key in BlogSubEntries on Blog. Both of these tables contain data that can be edited.
Now my web site query this database to display the blogs. I also have a cms to edit the blog entries. I don't want to put a save button in the cms so I want to send every edits to the server but don't want this data to be available to the web site before the blogger actually decides to publish the work.
Here's some things to consider:
- I don't want to have millions of queries on the database.
- I want the old data to be available during the edits.
- I'm using django with a relational database
After this lengthy intro, here are my questions:
- How would you handle this two step staging of data(consider the fact that there's two models related to each other)?
- What if I wanted to evolve this staging process into versioning ?
- I've recently read some on CouchDB, would a document database simplify this kind of problem ? If so how ?
Thanks for your time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一个快速的答案是拥有一个像这样的模型:
如果你想做版本控制,那么你就会有这样的东西:
我不认为文档存储引擎会有多大区别。您仍然需要跟踪哪个版本的内容属于给定条目(或博客,或其他)。当然,除非您使用的系统已经提供版本控制。
现在我想了一下,您也可以在一张表中完成此操作:
A quick answer would be to have a model like:
If you want to do versioning, then you would have something like:
I don't think a document-storage engine would make much difference. You would still need to keep track of which version of content belongs to a given entry (or blog, or whatever). Unless, of course, the system you used already provided versioning.
Now that I think about it, you could also do it in one single table: