5

I was using SQL in all my previous application and to understand the Parse.com db storage, I wanted to know NOSQL.

I tried searching the differences between SQL and NOSQL for past 2 days & I still don't understand how a relation works in NOSQL.

I learned that NOSQL is schemaless and there's no structure like SQL. Let me brief my question in an example.

Example :

In a SQL application for School management, I would create a table students which stores students' information. For marks, I'll have a marks table which has a column user_id that refers to students table. I'll have one more table subjects which will hold sub_id, sub_code and subject_name.

So, if I change sub_code in the subjects table, that will simply reflect to the other tables where FOREIGN KEY is used by using ON UPDATE DELETE CASCADE.

Now my question is,

since NOSQL doesn't use NORMALIZATION, how will the data be stored? Should a single table (document in NOSQL) hold all the information that is in students table, marks table and subjects table?

If we dump all the information into one single table, how efficient will it be?

If we want to change a subject code, then we need to update all the documents, right? (In SQL, we simply change subject code in one table, since other columns in other table which are referencing this column subject code will simply update right rather than updating each single entries?)

closed as too broad by Colin 't Hart, Mark Sinkinson, RolandoMySQLDBA, Max Vernon, RLF Apr 20 '15 at 23:45

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    NoSQL is a very broad term, it's not a thing in itself. What sort of NoSQL system are you talking about? Graph database? Document store? Key-value? Object store? – Mat Apr 19 '15 at 18:14
  • Key - Value.... – Yuva Raj Apr 19 '15 at 18:15
  • Which one? Please update your question with the actual system you're using so people who are familiar with it can help out. – Mat Apr 19 '15 at 18:16
  • 1
    Basically i've no idea about NOSQL rather than its schemaless. I just know parse.com uses key-value. What should i update because i don't know what to add. I'm just first clearing my questions before i start. – Yuva Raj Apr 19 '15 at 18:19
5

In your question you are using "SQL" and "relational" to mean the same thing. In the same way you can think of "NoSQL" as meaning "not relational" i.e. there is no primary key / foreign key concept; there is no "normalisation" enforced or implied; there is no real meaning of the words "table" or "column". To a key-value store all it knows about is a big collection of bytes you pass to it - the "value" - and a smaller collection of bytes - the "key" - used to index that big collection. What is inside that big collection and how it maps onto byte in other values in the database is entirely down to your application and the quality of the code in it.

Other NoSQL DBMSs, however, do allow you to define what is inside the "value". They hold a schema for the data, much like relational databases do. Cassandra is an example of this.

So it is up to you and how you implement your application. You could set up your key-value store to mimic a relational data model with surrogate ids. This would require a lot of reads and lose the point of a NoSQL solution. You could set up your key-values to store all denormalised values at the instant the record was written. This will be fast for retrieval but slow for updates. You have to choose what's best for your system and implement it accordingly. NoSQL is not magic. You still have a lot of design and development to do.

The term NoSQL is very broad. It has more to do with marketing than with a technology. Still less to do with maths such as the set theory underpinning relational databases. Different NoSQL products work differently. You will not know all of "NoSQL" by reading just Parse.com.

Understand your problem. Understand the compromises you are prepared to make to achieve your performance or consistency goals and choose the product which best matches your requirement.

  • Thanks for the edit & the answer. So, what if someone like Google is storing user information, location code with key - value pair & if one Govt. that changes the location code, does it mean it should perform update operation to all the user details who has the old code in value? Suppose, if they save user info in US, and if US change the country code, is it efficient to update each single user details who has old code to new code? If there's something called relation, won't be efficient just to update in one place to reflect others where it was referencing? – Yuva Raj Apr 21 '15 at 7:59
  • I mean suppose if there are 1 Million user information, and to change the country code for some country like US, does it mean it should perform update operation 1 Milli times to reflect the new data to user's location code in value? Because, you told it has no relation. Sorry if my question is stupid. I'm just trying hard to get. – Yuva Raj Apr 21 '15 at 8:02
  • If their design is to hold the country code in the data records then, yes, a change to the country code would mean all one million records would have to be updated. If their design was to hold country codes in a separate key namespace, and store a system-generated, unique number along side each country code, and store that system-generated number in the million records then, no, a change of country code would update one record only, not one million. – Michael Green Apr 21 '15 at 9:56
  • Here's a discussion of some options in one NoSQL product: blog.mongodb.org/post/87200945828/… – Michael Green Apr 21 '15 at 10:00
  • Doesn't it sounds like a relation here? It sounds similar to SQL relational db where you tell your column to refer other column through id(ON DELETE ON UPDATE CASCADE). The only difference i get is here it is key - value where u can create dynamically, there it's a predefined types and columns. Am i missing anything? – Yuva Raj Apr 21 '15 at 13:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.