通知管理应用程序的 NoSQL 数据库设计问题?
我正在尝试在 NoSQL 中创建一个数据库用于学习目的
它是一个简单的 PHP 通知管理(从通知栏添加/编辑/删除通知)应用程序。
我有 Memcached(实际上是 Membase),我可以将数据存储为键值对。
为了添加通知,我生成一个唯一的 ID {使用 uniqueid()function} 并在其中存储通知详细信息。但问题是, 1.如何列出所有通知?
我还想在通知中添加序列号。为此,我需要知道最后插入数据的序列号。 2.我如何找出最后插入的通知?
如果发现这个问题不合适,因为这有点关系数据模型(或者你可能会说,它应该在关系数据库中实现),请让我知道任何用途我可以使用 NoSQL 来了解更多信息的案例场景。
I am trying to make a database in NoSQL for learning purpose
Its a simple Notice management (Add/ edit/ Delete notice from notice borad) application in PHP.
I have Memcached (Membase actually) where I can store data as key value pair.
For adding a notice, I am generating a unique id {using uniqueid()function} and storing notice detail in it. But the problem is,
1. How to list all the notices?
I also want to add serial key to Notices. To do that, I need to know the serial key of last inserted data. 2. How do I find out the last inserted Notice?
If find this question inappropriate, cuz this is somewhat relational datamodel (or you may say, it should be implemented in relational database), please let me know any use case scenario where I can use NoSQL to learn more about it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
实体之间的自然连接是相关的 - 因此每个数据模型都是使用关系模式精心设计的。几乎每个 nosql 模式都可以用关系数据模型表示。
当使用标准关系模型不方便时(例如,当外部组件需要添加自己的数据而您事先不知道时)或者您需要更好的性能和扩展时,您可以使用 NoSQL - 然后您可以在 NoSQL 模式中对数据进行非规范化。
MongoDB (http://www.mongodb.org/) 是 NoSQL 数据的一个很好的起点,因为它允许您将非规范化模式与(几乎)关系设计混合在一起。
很好的用例是实现自定义表单数据存储的数据模型 - 其中字段的数量和字段的类型预先未知
关于你的问题:
Natural connections between entities are relational - so every data model is well designed using relational schema. Almost every nosql schema could be represented in relational data model.
You use NoSQL where using standard relational model is not comfortable (for example when foreign components need to add their own data and you don't know it in advance) or you need better performance and scaling - then you denormalize your data in NoSQL schema.
MongoDB (http://www.mongodb.org/) is a good start point in NoSQL data because it allows you to mix denormalized schema with (almost) relational design.
Nice use case is to implement data model for custom form data storing - where number of fields and type of fields isn't known upfront
And about your questions:
关于 NoSQL 首先要了解的是,市面上有很多具有不同功能的 NoSQL 解决方案。您需要选择最合适的一个。在这种情况下,Redis 将通过您选择的设计让您的生活变得更加轻松。
问题的核心是CAP 定理。许多 NoSQL 解决方案故意选择不保证一致性。一旦你把它扔掉,你就不能保证同一个身份证不会被发放两次。因此,使用时间戳或使用其他东西(例如 Redis)来生成可以存储在任何地方的唯一 ID 是有意义的。
The first thing to learn about NoSQL is that there are a lot of NoSQL solutions out there, with different capabilities. You need to pick the one that is most appropriate. In this case Redis will make your life a lot easier with the design that you've chosen.
The heart of the issue is the CAP theorem. Many NoSQL solutions deliberately choose to not guarantee consistency. Once you have thrown that away, you can't guarantee that the same ID is not handed out twice. Therefore it makes sense to either use timestamps, or use something else (like Redis) to generate the unique ids which you can store wherever you want.