Its No "No Structured Query Language"
Alice: Hey! Are you on the new Project in which they are going to use a different database ? Bob: Yes, they are gonna use NoSQL for that project. Alice: What is it... No Structured Query Language..eh?. Bob: Oh no they call it "Not only SQL" actually. Alice: Great ! that explains a lot, What exactly is Nosql ?, I mean this must be some anti SQL movements, dont you think the name makes it kinda obvious. Bob: No, NoSql was initially nothing but a catchy twitter hash tag, with the purpose of attracting people for a meetup,#NoSQL, just like red black tree, which got it name because the guy who invented it had just two inks to distinguish 2 types of node "red" and "black" and Voila! the name just "happened". Alice: How different is it from the traditional table databases ? Bob: Well, to start with there are no table and most datamodels in NoSQL are not relational. They store data as a whole like a object, unlike RDBMS in which we rip of data from the object and store it in different tables. Alice: Data as a whole object, but that makes no sense. Bob: Yeah it doesn't if you think of it from a RDBMS point of view. Think of this as your assignment notebook. Your note is the database and assignments is the collection containing all your assignments. Then each assignment is an object and while storing it we store it as a whole without breaking it down. ##collection Assignments: ##object 1 Assignment 1: <all your notes, including title, date and all possible data in that assignment> #object 2 Assignment 2: <data> . . . Alice: Well dont you this would lead to a lot of data and redundancy ? Bob: Yes, but we dont have to worry about that. Todays databases are not costly as they used to be and moreover today data is more valuable than the storage cost. Alice: And what exactly does data models in NoSQl mean ? Bob: Well this is what i found "A data model is a conceptual representation of the data structures that are required by an database. The data structures include the data objects, the associations between data objects, and the rules which govern operations on the objects. As the name implies, the data model focuses on what data is required and how it should be organized." They are 4 data models in NoSQL 1. Key-Value Pair 2. Document Type 3. Column-Family type 4. Graph Alice: Can you speak in English ? Bob: Ok lets take it one at a time: Key-Value Pair- Its basically like a big hash table, wherein we have a key and corresponding to that key we have some value stored. For eg: Take our example of Assignments Here Assignment1 is a "Key" and its corresponding data is the "value". Alice: mmmm... Bob: Ok here is a better one, Lets say we want to store Ruby on Rails Pvt. Ltd. address in US and India key value "India" {"Ruby Software Resources, 3740 DaVinci Court Suite 300 Norcross GA, 30092, Phone: +1 770-325-4352, Fax: 770-234-6195, Email: [email protected]"} "USA" {"Pamba Building, Trivandrum Technopark, Kerala, India -695581, Phone: +91 9446472021, Email: [email protected]"} Alice: Oh okay, I got it, you dont store state and country at a different location like we do in RDBMS to prevent redundancy. So we only need to get the kay and we can have all the data without having to define any relation. I see we dont have any schema here, so NoSQL is schema less and unstructured ? Bob: Mostly, yes. But let me introduce you to the Document Type first. This is almost like Key-Value pair, the difference being that it is kinda semi-structured. for eg: if we were to store the address data in Document data type it would look like this {office : "Ruby on Rails Pvt Ltd", location : "USA", Address : "3740 DaVinci Court Suite 300 Norcross GA, 30092", Phone: "+1 770-325-4352", Fax: "770-234-6195", Email: "[email protected]" } {office : "Ruby on Rails Pvt Ltd", location : "India", Address : "Pamba Building Trivandrum Technopark, Kerala, India -695581", Phone: "+91 9446472021", Email: "[email protected] } Alice: Oh this looks like a JSON file. Bob: Exactly, Document type databases uses JSON documents to store records. So you can see now that this is kinda structured, yet no definite schema is defined. Alice: Okay, so you can get specific data out of a object which was not possible with key-value pair, like if only we want to know the phone number, we can query for that specifically. Bob: Exactly. To be contd...















