<legend id='8ebU7'><style id='8ebU7'><dir id='8ebU7'><q id='8ebU7'></q></dir></style></legend>
  • <tfoot id='8ebU7'></tfoot>
      <bdo id='8ebU7'></bdo><ul id='8ebU7'></ul>

        <small id='8ebU7'></small><noframes id='8ebU7'>

        <i id='8ebU7'><tr id='8ebU7'><dt id='8ebU7'><q id='8ebU7'><span id='8ebU7'><b id='8ebU7'><form id='8ebU7'><ins id='8ebU7'></ins><ul id='8ebU7'></ul><sub id='8ebU7'></sub></form><legend id='8ebU7'></legend><bdo id='8ebU7'><pre id='8ebU7'><center id='8ebU7'></center></pre></bdo></b><th id='8ebU7'></th></span></q></dt></tr></i><div id='8ebU7'><tfoot id='8ebU7'></tfoot><dl id='8ebU7'><fieldset id='8ebU7'></fieldset></dl></div>

        为高度非规范化的 NoSQL 数据库设计唯一键(主键

        时间:2023-09-28
          <tbody id='sPT1s'></tbody>

          <bdo id='sPT1s'></bdo><ul id='sPT1s'></ul>
          <tfoot id='sPT1s'></tfoot>
        • <legend id='sPT1s'><style id='sPT1s'><dir id='sPT1s'><q id='sPT1s'></q></dir></style></legend>
          <i id='sPT1s'><tr id='sPT1s'><dt id='sPT1s'><q id='sPT1s'><span id='sPT1s'><b id='sPT1s'><form id='sPT1s'><ins id='sPT1s'></ins><ul id='sPT1s'></ul><sub id='sPT1s'></sub></form><legend id='sPT1s'></legend><bdo id='sPT1s'><pre id='sPT1s'><center id='sPT1s'></center></pre></bdo></b><th id='sPT1s'></th></span></q></dt></tr></i><div id='sPT1s'><tfoot id='sPT1s'></tfoot><dl id='sPT1s'><fieldset id='sPT1s'></fieldset></dl></div>

        • <small id='sPT1s'></small><noframes id='sPT1s'>

                • 本文介绍了为高度非规范化的 NoSQL 数据库设计唯一键(主键)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在使用 Java 和 Cassandra 数据库开发与论坛相关的 Web 应用程序.

                  I am working on a web application related to Discussion forums using Java and Cassandra database.

                  我需要为存储用户详细信息的行和 &另一组存储用户发布的内容的行.

                  I need to construct 'keys' for the rows storing the user's details and & another set of rows storing the content posted by the user.

                  一种选择是获取 Java 语言提供的随机生成的 UUID,但这些都是 16 字节长.由于 NoSQL 数据库涉及大量的非规范化,我担心如果可以生成更小的密钥,是否会浪费大量磁盘空间、RAM 和其他资源.

                  One option is to get the randomly generated UUID provided by Java language, but these are 16 bytes long. and since NoSQL database involves heavy denormalization, I am concerned whether I would be wasting lots of disk space, RAM and other resources if the key could be generated in smaller sizes.

                  我需要生成两种类型的密钥,一种用于用户和其他用于用户发布的内容.

                  I need to generate two types of keys, one for the Users & other for Content Posted by Users.

                  对于用户发布的内容,timestamp+userId 会是一个很好的键.其中 timestamp 是发布内容的服务器时间,userId 是指用户行的键.

                  For the Content posted by users, would timestamp+userId be a good key. where timestamp is the server time at which content was posted and userId refers to key of user row.

                  任何建议,意见表示赞赏..

                  Any suggestions, comments appreciated ..

                  谢谢马科斯

                  推荐答案

                  这是分布式应用吗?

                  然后您可以使用一个简单的同步计数器,并在启动时使用下一个可用 id 对其进行初始化.

                  Then you could use a simple synchronized counter and initialize it on startup with the next available id.

                  另一方面,数据库应该能够处理由 java 创建的 UUID 哈希.这是创建诸如 sessionIds 之类的东西的标准,它需要是唯一的.您的问题有些相似,因为您上下文中的会话将代表一组用户输入.

                  On the other hand a database should be able to handle the UUID hashes as created by java. This is a standard for creating things like sessionIds, that need to be unique. Your problem is somewhat similar since a session in your context would represent a set of user input.

                  这篇关于为高度非规范化的 NoSQL 数据库设计唯一键(主键)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Jackson 使用 mixins 序列化具有动态不同名称的属性 下一篇:在 MySQL 上使用 NoSQL 数据库

                  相关文章

                  最新文章

                  <small id='QaUI7'></small><noframes id='QaUI7'>

                • <legend id='QaUI7'><style id='QaUI7'><dir id='QaUI7'><q id='QaUI7'></q></dir></style></legend>

                        <bdo id='QaUI7'></bdo><ul id='QaUI7'></ul>

                      <i id='QaUI7'><tr id='QaUI7'><dt id='QaUI7'><q id='QaUI7'><span id='QaUI7'><b id='QaUI7'><form id='QaUI7'><ins id='QaUI7'></ins><ul id='QaUI7'></ul><sub id='QaUI7'></sub></form><legend id='QaUI7'></legend><bdo id='QaUI7'><pre id='QaUI7'><center id='QaUI7'></center></pre></bdo></b><th id='QaUI7'></th></span></q></dt></tr></i><div id='QaUI7'><tfoot id='QaUI7'></tfoot><dl id='QaUI7'><fieldset id='QaUI7'></fieldset></dl></div>
                      <tfoot id='QaUI7'></tfoot>