gpt4 book ai didi

database-design - 具有范围查询的 NoSQL 数据库

转载 作者:行者123 更新时间:2023-12-04 06:53:04 26 4
gpt4 key购买 nike

我正在寻找一个 NoSQL 数据库,它允许查询返回指定范围内的记录。

我对 NoSQL 命名法不是很好(因为我仍然只研究它们可行的任何东西)所以我将解释我将如何在 SQL 中做到这一点。

我需要做的是搜索高于特定分数的记录(比如论坛帖子)。或多或少是这样的:SELECT * FROM posts WHERE score > 2 .

问题是,当我使用 PHP 时,是否可以使用任何 NoSQL 数据库(键值或宽列数据库)?如果不可能,哪些 NoSQL 数据库支持此类查询?

最佳答案

您可能想查看 MongoDB .它很流行1,并支持范围查询:

Unlike many other non-relational database solutions, any field can be queried at any time. MongoDB supports range queries, regular expression searches, and other special types of queries in addition to exactly matching fields. Queries can also include user-defined JavaScript functions (if the function returns true, the document matches).

From: Wikipedia - MongoDB Features



这是您的 SELECT * FROM posts WHERE score > 2查询在 Mongo 中看起来像:
db.posts.find( { score : {$gt: 2} } );

进一步阅读:
  • MongoDB Manual : Advanced Queries


  • 1 见: MongoDB : Production Deployments

    关于database-design - 具有范围查询的 NoSQL 数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3896158/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com