nosql

Improve performance in Cassandra and java collections

蹲街弑〆低调 提交于 2019-12-23 03:07:06
问题 We are using NoSQL (Cassandra) in our project. We have a Table A (5000 records) which is a master table. We have another Table B (2000 records). Table B have 4 columns and Table A have 25 columns. We exposed a REST service to get all records from B; like /service/getB. This service will return 6 columns in response as – { "result": [ { "col1FromB": "1B", "col2FromB": "2B", "col3FromB": "3B", "col4FromB": "4B", "col1FromA": "1A", "col2FromA": "2A" }, { "col1FromB": "11B", "col2FromB": "12B",

Migrate RDBMS to Cassandra

断了今生、忘了曾经 提交于 2019-12-23 02:36:45
问题 I have a RDBMS database with the following tables: Airport ( iata PK , airport, city, state, country, lat, long) cancellation_cause ( cod_cancellation PK , description) Manufaturer (id_manufacturer PK , manufacturer_name) Model (id_model PK , model_name, id_manufacturer FK ) Airline ( airline_code PK , description) airplane_type (id_AirplaneType PK , airplane_type) engine_type (id_engine PK , engine_type) Aircraft_type (id_aircraft PK , aircraft_type) Airplane (TailNumber PK , id_model FK, id

Storing country state city in MongoDB

我怕爱的太早我们不能终老 提交于 2019-12-23 02:32:56
问题 I am currently working on building database to store country-state-city information which is later to be used from drop down menus in our website. I wanted to get few suggestions on the schema that I have decided as to how efficiently it will work. I am using MongoDB to store the data. The schema that I have designed is as follows: { _id: "XXXX", country_name: "XXXX", some more fields state_list:[ { state_name: "XXXX", some more fields city_list:[ { city_name : "XXXX", some more fields }, {

Best way to store huge log data

走远了吗. 提交于 2019-12-23 01:53:35
问题 I need an advice on optimal approach to store statistical data. There is a project on Django, which has a database (mysql) of 30 000 online games. Each game has three statistical parameters: number of views, number of plays, number of likes Now I need to store historical data for these three parameters on a daily basis, so I was thinking on creating a single database which will has five columns: gameid, number of views, plays, likes, date (day-month-year data). So in the end, every day for

Mongoose positional operator errors

心不动则不痛 提交于 2019-12-22 23:22:06
问题 I am trying to run a command like this in mongoose: Song.update({url: s.url, "playlist.playlist_id": pl._id}, {$set: {"playlist.$.position": 505050}}, function(er, da) { console.log("song on playlist lets change position"); console.log(er); console.log(da); }); however I get the error: [TypeError: Cannot call method 'path' of undefined] I am guessing it has to do with mongoose and $ operator because it works in the mongodb console. Any ideas? 回答1: I had similar issue with mongoose also, maybe

Mongoose positional operator errors

江枫思渺然 提交于 2019-12-22 23:21:54
问题 I am trying to run a command like this in mongoose: Song.update({url: s.url, "playlist.playlist_id": pl._id}, {$set: {"playlist.$.position": 505050}}, function(er, da) { console.log("song on playlist lets change position"); console.log(er); console.log(da); }); however I get the error: [TypeError: Cannot call method 'path' of undefined] I am guessing it has to do with mongoose and $ operator because it works in the mongodb console. Any ideas? 回答1: I had similar issue with mongoose also, maybe

关系型和非关系型数据库的区别?

佐手、 提交于 2019-12-22 21:29:01
当前主流的关系型 数据库 有 Oracle 、DB2、Microsoft SQL Server、Microsoft Access、 MySQL 等。 非关系型数据库有 NoSql、Cloudant。 nosql和关系型数据库比较? 优点: 1)成本:nosql数据库简单易部署,基本都是开源软件,不需要像使用oracle那样花费大量成本购买使用,相比关系型数据库价格便宜。 2)查询速度:nosql数据库将数据存储于缓存之中,关系型数据库将数据存储在硬盘中,自然查询速度远不及nosql数据库。 3)存储数据的格式:nosql的存储格式是key,value形式、文档形式、图片形式等等,所以可以存储基础类型以及对象或者是集合等各种格式,而数据库则只支持基础类型。 4)扩展性:关系型数据库有类似join这样的多表查询机制的限制导致扩展很艰难。 缺点: 1)维护的工具和资料有限,因为nosql是属于新的技术,不能和关系型数据库10几年的技术同日而语。 2)不提供对sql的支持,如果不支持sql这样的工业标准,将产生一定用户的学习和使用成本。 3)不提供关系型数据库对事物的处理。 非关系型数据库的优势:1. 性能NOSQL是基于键值对的,可以想象成表中的主键和值的对应关系,而且不需要经过SQL层的解析,所以性能非常高。2. 可扩展性同样也是因为基于键值对,数据之间没有耦合性,所以非常容易水平扩展

mongodb应用

大憨熊 提交于 2019-12-22 21:28:33
首先我们来分析下mysql 与mongodb的特点与优劣。 下面是我以前做的ppt的部分截图。 再来分析下应用场景, a.如果需要将mongodb作为后端db来代替mysql使用,即这里mysql与mongodb 属于平行级别,那么,这样的使用可能有以下几种情况的考量: (1)mongodb所负责部分以文档形式存储,能够有较好的代码亲和性,json格式的直接写入方便。(如日志之类) (2)从data models设计阶段就将原子性考虑于其中,无需事务之类的辅助。开发用如nodejs之类的语言来进行开发,对开发比较方便。 (3)mongodb本身的failover机制,无需使用如MHA之类的方式实现。 这种情况也是不少的,我手上的游戏就是有nodejs+mongodb的,用户总量也是千万级别的,流水什么还不错。 b.将mongodb作为类似redis ,memcache来做缓存db,为mysql提供服务,或是后端日志收集分析。 考虑到mongodb属于nosql型数据库,sql语句与数据结构不如mysql那么亲和 ,也会有很多时候将mongodb做为辅助mysql而使用的类redis memcache 之类的缓存db来使用。 亦或是仅作日志收集分析。 问题2: 楼主可能没有观察仔细。 我做了下实验。例子如下: > db.a.save({"a":3}); > db.a.save({"a

query documents that depend on values of other documents in mongodb

亡梦爱人 提交于 2019-12-22 17:51:45
问题 Imagine following mongoose model: const UserSchema = Schema({ //_id: ObjectId, //more fields, blockedIds: [{ type: ObjectId, ref: 'User' }] }) What is the most efficient way to get all users that don't match the blockedIds of an user with a certain _id? A naive way would be to to perform two queries: User.findById(id).then(user => { return User.find({_id: {$nin: user.blockedIds}}) }) Is it possible to use the aggregation framework and $facets to accomplish that in one query? 回答1: Try non

Rethinkdb removing data from documents

天大地大妈咪最大 提交于 2019-12-22 12:44:10
问题 I'm trying to remove some portions of data from documents with given fairly simple structure, which will get much deeper and heavier than this as the project goes: { id: "...", name: "...", phone: "...", data: { key1: "val1", ... } ... } I'm aware that there is no way of updating/removing sections from the nested parts other than replacing the whole tree with updated tree. For example, if I want to delete key1 from document data, I need to update the documents data section with a copy of it