一个简单的数据库版本控制
如果您有一个存储问题和答案的表,例如使用名为“Parent”之类的额外列。因此,如果一个问题在父级中没有值,那么它就是一个问题,如果有,那么它就是一个答复,那么您将如何对此进行版本控制呢?
If you have a table which stores questions and answers, for example using an extra column called something such as Parent. So if a question doesn't have a value in parent, it's a question and if it does, its a reply, so how would you do version control for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有关如何保留文本过去修订版本的完善示例,您可以查看 MediaWiki 数据库布局。这是 MediaWiki 软件使用的数据库布局,许多 wiki(尤其是维基百科)都在该软件上运行。具体来说,
page
、revision
和text
表是涉及跟踪历史更改的主要表。For a well-developed example of how to keep past revisions of text, you could look at the MediaWiki database layout. This is the database layout used by the MediaWiki software, which many wikis (notably Wikipedia) run on. Specifically, the
page
,revision
, andtext
tables are the primary tables involved with keeping track of historic changes.有一个表用于问题,另一个表用于答案:
这是 SQLite 中的一个示例
问题表应包含问题的文本和要连接的 id 字段:
答案应包含修订号或日期、问题的文本答案,一个字段,用于指示向哪个用户询问该问题(如果需要),以及作为答案的问题的 ID。
现在查询两个数据库,确保:仅选择最新版本(GROUP 和 MAX),并且包含未回答的问题(LEFT JOIN)
您可以创建一些其他查询来列出给定问题/用户的过去答案,并列出用户未回答的问题。
Have one table for questions, and a separate one for answers:
Here's an example in SQLite
The questions table should contain the text of the question and an id field to join on:
The answers should contain a revision number or date, the text of the answer, a field to indicate which user is asked the question (if necessary), and the id of the question to which it is an answer.
Now query on the two databases, making sure that: only the most recent revision is selected (GROUP and MAX), and unanswered questions are included (LEFT JOIN)
You can create some other queries to list past answers for a given question/user, and to list unanswered questions by user.