简体   繁体   English

请求-答复数据库模型

[英]Request-Reply Database Model

I'm wondering about simple database model based on the interaction of requests and replies. 我想知道基于请求和答复交互的简单数据库模型。 The one request can have only one answer. 一个请求只能有一个答案。 There can be made another request based on the previous answer. 可以根据先前的答案提出另一个请求。 It is needed to be able to iterate the all history - from the first request to the last reply. 需要能够迭代所有历史记录-从第一个请求到最后一个答复。 I've done a sample model: 我已经完成了一个示例模型:

Requests:            Reply:
| int id       |     | int id      |
| int parentID |     | String text |
| String text  |
| int answerID |

How can I improve it and make it more usable? 我如何改善它并使其更有用?

I'm assuming a request can generate multiple replies. 我假设一个请求可以生成多个答复。

Request
-------
Request ID
Request timestamp
Request text

Request ID is the primary (clustering) key. 请求ID是主键(集群)。 It's an auto-incrementing integer or long. 它是一个自动递增的整数或长整数。

You also define a non-unique index on request timestamp, descending. 您还可以根据请求时间戳定义一个非唯一索引,降序。

Reply
-----
Reply ID
Request ID
Reply timestamp
Reply text

Reply ID is the primary (clustering) key. 回复ID是主键(集群)。 It's an auto-incrementing integer or long. 它是一个自动递增的整数或长整数。

You also define a non-unique index on (Request ID, Reply timestamp descending). 您还定义了一个非唯一索引(请求ID,回复时间戳降序)。 You may also define a non-unique index on (Reply timestamp descending, Request ID). 您还可以在(回复时间戳降序,请求ID)上定义非唯一索引。 The first index is for all the replies for a request. 第一个索引用于请求的所有答复。 The second index is for all the replies in a time period (week , month). 第二个索引是一个时间段(周,月)中所有答复的索引。

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

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