I am beginner in NoSql databases (I use mongodb), I need your help to translate my schema from relational to NoSql schema.
The main nosql concept is different from the traditional sql (relational ) model. It does not means that's you can't do relations between nosql entities but you should care about your use cases before choosing a nosql database.
In sql , relations are generally done by ids. You can achieve the same with a nosql database.
In nosql, an entry is often call a document. In a document, you could refer to an other doc by given it's id key for example ( as you do already with user_id, group_id .. ).
I suggest you to read the mongoDB doc about data modeling https://docs.mongodb.com/manual/core/data-modeling-introduction/
It could be a nice introduction to what you want to do
Related
Why is Riak TS considered as a NoSQL database when it needs a predefined schema for tables? This schema even cannot be changed! Source: documentation
I think that some people may think that when Riak TS is built on Riak KV, then it is a NoSQL database, but that each row maps to a key-value pair do not bring a NoSQL advantage. If the Riak TS is not schema-less, it should not be considered as a NoSQL database in my opinion.
Do I understand it wrong? Why is it officially considered as NoSQL?
SQL is not only about having a table schema. First the query language supported is only a tiny subset of SQL. Then, Riak TS doesn't provide things that you'd expect from other traditional SQL DB, like ACID, transactions, etc. Also, it's not really a normal DB as you can't update values.
So it doesn't make sense to define it as an "relational DB" or "SQL database". But it doesn't really make sense to define it as a "NoSQL DB" :) I think the best definition is a "TimeSeries distributed DB"
i have a question for the performance in meteorJS. Before i used meteorJS is always wrote my Applications in PHP and MySQL. In MySQL i always created a lot of tables with many connections betweens them.
For example:
Table User
id;login;password;email
Table User_Data
user_id;name;age
My questions is now how i have to design my MongoDB collections. Its nice that the collection are build like js objects so i dont have to predesign my tables and can always easy change the collumns. But is it better to combine all data to one collection or to several collections ?
For example:
Table User
_id;login;password;email;data:{name;age}
Is it better or worse for the performance ? Or is it the wrong pattern to design MongoDB Collections ?
The question mainly about MongoDB data modeling. What you'll learn applies to MongoDB used with Meteor or with anything else.
http://docs.mongodb.org/manual/data-modeling/ talks about data modeling with MongoDB and is a good introduction.
In your particular case, you can read more about how to avoid JOINs in MongoDB.
I'm new to MongoDB and NOSQL databases but have experience with relational database.
Due to the behavior of documents in a collection where a document can have different fields. How can I document the data models ? Anything like ER modeling in Relational Database?
Can you guys share how you do the documentation in your company ?
Thank you.
Edit:
I'll try to be more specific, in relational database we use Erwin to document the ER diagram, tables, name of columns, objects, etc...
But I'm having difficult to document the collections and documents in mongodb, mainly for the dynamic of fields in a document.
Q1. Why do people often prefer to use NoSQL over RDBMS for storing data like tweets?
Q2. Is there any NoSQL database that supports a SQL-like query syntax?
A sample table for the Q1 would be:
Status
UID
Status
Timestamp
Q1:
NoSQL products are primarily known for their ability to scale (sharding and replication) and their schema-less design. Twitter uses FlockDB (a graph DB) and not an RDBMS because of that, and because it makes more sense to use graphs to describe who follows who - not because the actual text messages.
Other benefits of NoSQL include advanced querying techniques (Map/Reduce): CouchDB and RavenDB are document-oriented DBs built on top of Lucene, and therefore can offer full-text search queries out-of-the-box, something you could never do efficiently with RDBMS.
Q2:
RavenDB queries are Linq expressions, which mimics SQL syntax, and is quite identical to it.
NoSQL databases, especially MongoDB, are often a good choice for storing things like tweets because they offer very quick write speeds, fast querying, and can easily distribute large data sets across a cluster of servers.
Many NoSQL databases have their own query syntax, but some such as Hive, a data warehouse product built on top of Hadoop, do have SQL-like query languages.
For unstructured data, or for data
whose structure is dynamic (i.e. if
stored in a RDBMS, the table
structure will continually be
changed). Imagine storing data about, say films, in a database. You start off with title and director, but before long you realise you also need to save all the actors/actresses, the year --> table structure change. You then want to store similar films --> another change. For such a scenario saving data in key/value pairs may well be easier, as you simply add the new data into the existing structure (though the example you give - basically a BLOB of text - doesn't really fit that description).
Orient supports SQL-similar syntax
I have an MSSQL database which I am considering porting to CouchDB or MongoDB. I have a many-to-many relationship within the SQL db which has hundreds of thousands rows in the xref table, corresponding to tens of thousands of rows in the tables on each side of the relationship. Will CouchDB and/or MongoDB be able to handle this data, and what would be the best way of formatting the relevant documents for performant querying? Thanks very much.
For CouchDB, I would highly recommend reading this article about Entity Relationships.
One thing I would note in CouchDB is to be careful of attempting to "normalize" a non-relational data model. The document-based storage offers you a great deal of flexibility, and it's seldom the best idea to abstract everything into as many "document types" as you can think of. Many times, it's best to leave much of your data within the same document unless you have clear cases where separate entities exist.
One common use-case of many-to-many relationships is implementing tagging. There are articles about different methods you can use to accomplish this in CouchDB. It may apply to your requirements, it may not, but it's probably worth a read.
Since the 'collection' model of MongoDB is similar to tables you can of course maintain
the m:n relationship inside a dedicated mapping collection (using the _id of the related documents of the referenced documents from other collections).
If you can: consider redesign your application using embedded documents.
http://www.mongodb.org/display/DOCS/Schema+Design
In general: try to turn off your memories to a RDBMS when working with MongoDB.
Blindly copying the database design from RDBMS to MongoDB is neither helpful nor adviceable nor will it work in general.