nosql

MongoDB(1)----基础概念

爱⌒轻易说出口 提交于 2020-02-07 21:36:14
1.什么是MongoDB?   MongoDB是由C++语言实现的一个基于分布式文件存储的开源数据库。旨在为Web应用提供可扩展的高性能数据存储解决方法。它介于关系型数据库(Sql)和非关系型数据库(NoSql)之间。 2.MongoDB数据存储结构?   MongoDB将数据存储为一个文档,以键值对的形式(Key:Value结构)作为其数据结构。如下图所示: 3.MongoDB优缺点? 优点: 1)可以非常方便的为数据建立索引 2)可以通过网络或者本地创建数据镜像 ,使得MongoDB具有更强的扩展性 3)数据面向文档进行存储,操作起来简单 4)不存在Sql注入问题 5)支持大容量的数据存储 6)内置Sharding,分片简单 7)支持故障恢复 缺点: 1)不支持事务 2)复杂的聚合操作通过mapreduce创建,速度慢 3)无法进行关联表查询,不适合关系多的数据、 4)删除数据集合后不会自动释放空间 4.MongoDB的应用场景?   当传统的关系型数据库无法满足 高并发、海量数据存储访问、灵活扩展、 等需求的时候,就可以将MongoDB作为一种解决方案。 总结: 1)程序有大量数据存储(TB甚至PB级别) 2)程序发展速度较快,要求具有快速扩展的能力 3)程序需要3000以上的QPS 4)数据模型暂时无法确定 5)数据价值较低,不需要事务支持和复杂的join操作  

Complexity of finding total records count with partition key in nosql dynamodb table?

五迷三道 提交于 2020-02-07 01:28:23
问题 I am designing a DynamoDB database tables. In one table, say test_table , I have defined a composite key with the combination of a partition key , say partition_id and a sort key, say sort_id . Both partition_id and sort_id may be have some duplicate values in their entries but the combination of both partition_id and sort_id together will always be unique. I am interested to know, how efficient is the retrieval of total records having some partition_id , say partition_id = x ? 回答1: The

How to use findOneAndUpdate using an aggregated query in mongoDB?

依然范特西╮ 提交于 2020-02-06 08:01:08
问题 I am using nestJS as a backend connected with MongoDB. I am able to access a nested array in my schema which is: { "id": "productId", "name": "productName", "price": "productPrice", "Categories": [ { "_id": "catId", "name": "catName", "Subcategories": [ { "_id": "subcatId", "name": "subcatName" }, { "_id": "subcatId", "name": "subcatName" }, ] }, { "_id": "catId", "name": "catName", "Subcategories": [ { "_id": "subcatId", "name": "subcatName" }, { "_id": "subcatId", "name": "subcatName" }, ]

How to store social network's actions in NEO4J?

喜夏-厌秋 提交于 2020-02-06 05:06:26
问题 We are going to use NEO4J for our social network database and we have common social networks actions such as following, link, comment, posts and so on... . Now I want to know is this correct, we are doing: Comment: user_comment is a node and has a relation with post node, relation name is comment Like: Like is a relation, the relation name is like and a post has a relation with a user, the relation name is like Location: Each post can have a location, then post node has a where relation with

What is MongoDB and For What?

假装没事ソ 提交于 2020-02-04 22:31:15
1、MongoDB是什么? MongoDB是一款为web应用程序和互联网基础设施设计的数据库管理系统。没错MongoDB就是数据库,是NoSQL类型的数据库 2、为什么要用MongoDB? (1)MongoDB提出的是文档、集合的概念,使用BSON(类JSON)作为其数据模型结构,其结构是面向对象的而不是二维表,存储一个用户在MongoDB中是这样子的。 { username:'123', password:'123' } 使用这样的数据模型,使得MongoDB能在生产环境中提供高读写的能力,吞吐量较于mysql等SQL数据库大大增强。 (2)易伸缩,自动故障转移。易伸缩指的是提供了分片能力,能对数据集进行分片,数据的存储压力分摊给多台服务器。自动故障转移是副本集的概念,MongoDB能检测主节点是否存活,当失活时能自动提升从节点为主节点,达到故障转移。 (3)数据模型因为是面向对象的,所以可以表示丰富的、有层级的数据结构,比如博客系统中能把“评论”直接怼到“文章“的文档中,而不必像myqsl一样创建三张表来描述这样的关系。 3、主要特性 (1)文档数据类型 SQL类型的数据库是正规化的,可以通过主键或者外键的约束保证数据的完整性与唯一性,所以SQL类型的数据库常用于对数据完整性较高的系统。MongoDB在这一方面是不如SQL类型的数据库,且MongoDB没有固定的Schema

NoSQL数据库种类

别等时光非礼了梦想. 提交于 2020-02-03 14:09:38
NoSQL数据库的四大分类 键值(Key-Value)存储数据库    这一类数据库主要会使用到一个哈希表,这个表中有一个特定的键和一个指针指向特定的数据。Key/value模型对于IT系统来说的优势在于简单、易部署。但是如果DBA只对部分值进行查询或更新的时候,Key/value就显得效率低下了。举例如:Tokyo Cabinet/Tyrant, Redis, Voldemort, Oracle BDB. 列存储数据库   这部分数据库通常是用来应对分布式存储的海量数据。键仍然存在,但是它们的特点是指向了多个列。这些列是由列家族来安排的。如:Cassandra, HBase, Riak. 文档型数据库   文档型数据库的灵感是来自于Lotus Notes办公软件的,而且它同第一种键值存储相类似。该类型的数据模型是版本化的文档,半结构化的文档以特定的格式存储,比如JSON。文档型数据库可 以看作是键值数据库的升级版,允许之间嵌套键值。而且文档型数据库比键值数据库的查询效率更高。如:CouchDB, MongoDb. 国内也有文档型数据库SequoiaDB,已经开源。 图形(Graph)数据库   图形结构的数据库同其他行列以及刚性结构的SQL数据库不同,它是使用灵活的图形模型,并且能够扩展到多个服务器上。NoSQL数据库没有标准的查询语言(SQL)

MongoDB入门

橙三吉。 提交于 2020-02-03 09:02:53
概念 MongoDB:是一个数据库 ,高性能、无模式、文档性,目前 nosql 中最热门的数据库,开源 产品,基于 c++开发。是 nosql 数据库中功能最丰富,最像关系数据库的。 MongoDB与mysql的概念关系对比 MongoDB 的应用已经渗透到各个领域,比如游戏、物流、电商、内容管理、社交、物联网、 视频直播等,以下是几个实际的 应用案例: 游戏场景,使用 MongoDB 存储游戏用户信息,用户的装备、积分等直接以内嵌文档 的形式存储,方便查询、更新 物流场景,使用 MongoDB 存储订单信息,订单状态在运送过程中会不断更新,以 MongoDB 内嵌数组的形式来存储,一次查询就能将订单所有的变更读取出来。 社交场景,使用 MongoDB 存储存储用户信息,以及用户发表的朋友圈信息,通过地 理位置索引实现附近的人、地点等功能 物联网场景,使用 MongoDB 存储所有接入的智能设备信息,以及设备汇报的日志信 息,并对这些信息进行多维度的分析 视频直播,使用 MongoDB 存储用户信息、礼物信息等 不使用 MongoDB 的场景 高度事务性系统:例如银行、财务等系统。MongoDB 对事物的支持较弱; 传统的商业智能应用:特定问题的数据分析,多数据实体关联,涉及到复杂的、高度优 化的查询方式; 使用 sql 方便的时候;数据结构相对固定,使用 sql

Using MongoDB shell commands on MongoDB 10Gen's driver

ε祈祈猫儿з 提交于 2020-02-03 05:39:05
问题 I want to simply execute pure MongoDB queries via MongoDb 10Gen's .net(c#) driver. For example . I want to use below command on driver db.people.update( { name:"Joe" }, { $inc: { n : 1 } } ); I am not sure how can i do this. I am not interested in how to do via high level api classes. 回答1: The C# driver (or any other driver) is not intended to "directly" run mongo shell commands. That's what the shell is for. What you need to do is translate the mongo shell commands into the equivalent C#

Fastest way to get the average of a specific field in MongoDB

▼魔方 西西 提交于 2020-02-03 05:22:51
问题 Let's say I have a dataset like the following: { "_id" : ObjectId("4dd51c0a3f42cc01ab0e6506"), "views" : 1000, "status" : 1 } { "_id" : ObjectId("4dd51c0e3f42cc01ab0e6507"), "views" : 2000, "status" : 1 } { "_id" : ObjectId("4dd51c113f42cc01ab0e6508"), "views" : 3000, "status" : 1 } { "_id" : ObjectId("4dd51c113f42cc01ab0e6508"), "views" : 4000, "status" : 0 } What is the fastest way (performance-wise) to get the average number of views for all documents with a status of 1? Is Map/Reduce

Is this an appropriate use-case for Amazon DynamoDB / NoSQL?

廉价感情. 提交于 2020-02-02 15:54:32
问题 I'm working on a web application that uses a bunch of Amazon Web Services. I'd like to use DynamoDB for a particular part of the application but I'm not sure if it's an appropriate use-case. When a registered user on the site performs a "job", an entry is recorded and stored for that job. The job has a bunch of details associated with it, but the most relevant thing is that each job has a unique identifier and an associated username. Usernames are unique too, but there can of course be