Presentation is loading. Please wait.

Presentation is loading. Please wait.

Intro to NoSQL Databases

Similar presentations


Presentation on theme: "Intro to NoSQL Databases"— Presentation transcript:

1 Intro to NoSQL Databases

2 Introduction NoSQL database by definition is "next generation" type of database mostly addressing some points: non-relational, distributed, open source and horizontally scalable. We will be focusing on the MongoDB specifically based on its popularity in past few years.

3 Why NoSQL? Small to medium size company, like the company I work with, often uses MongoDB as the starting point of micro services. Why? When building modern web application now, it's often that business requirement changes in between development cycle and even change in a day or two. MongoDB databases is designed to help with rapidly changing data types.

4 Why NoSQL (cont) MongoDB is only within a type of NoSQL database, specifically under document model database. For the class purposes, we will not address other types of databases. Do not assume that NoSQL = MongoDB. This is wrong

5 Why NoSQL (cont) Relational databases were created in the 1970s NoSQL:
Not designed to cope with scale/changing environments that we see today. Processing data has changed over time. NoSQL: Able to handle new software design paradigms such as Agile development 2-week sprints vs waterfall Ever changing requirements Able to be distributed in the cloud easily Able to handle structured, semi-structured, unstructured, and polymorphic data

6 MongoDB Document model databases like MongoDB stores the data in documents. And these documents typically use a structure like JSON. This format is very close to how modern webapps are structured. For example, to store data that will only be used by the front-end, simply store whatever data the client side passes without any sort of schema definition from the backend. Note that the above example can prove to be risky, as you are trusting that the client will not manipulate the client database. Always try to validate data in the backend!

7 MongoDB (cont) Furthermore, in document storage, the notion of schema is very flexible: each document can contain different fields. This flexibility is helpful for modeling unstructured data. Makes the development easier to evolve application in the development cycle, such as adding new fields. In short, document model databases are for general purpose and useful for wide variety of applications due to the flexibility of the data modeling -- which we will see in the following lectures. You can read more on the comparison between NoSQL and Relational databases here -- 

8 JSON data So far, we have been learning how to represent data in more like a tabular format (like sql tables). In upcoming lessons, we will not be using tabular format anymore. Instead we will be using JSON to represent data.

9 JSON JSON is short for JavaScript Object Notation
A way to store information in an organized, easy-to-access-manner When exchanging data between a browser and a server, the data can only be text. JSON is text, and we can convert any JavaScript object into JSON, and send JSON to the server. We can also convert any JSON received from the server into JavaScript objects. This way we can work with the data as JavaScript objects, with no complicated parsing and translations.

10 Why JSON? Important to have data that doesn’t need to have a strict structure JSON is able to be loaded quickly and asynchronously JSON parsers are everywhere It is not XML

11 JSON data JSON contain a few concepts:
{} indicates an object like skills or the entire object [] indicates an list like students can contain String like name can contain numbers like gpa can nest as many levels you want and as many attributes as you want

12 JSON data Example: { "name": ”Randy", "gpa": 3.9, "students": [
"Alice", "Bob", "Eve" ] "skills": { "mysql": "good", "nosql": "good", "javascript": "very good" }

13 JSON – Detailed Breakdown
Key value pairs "key" : "value” Keys are on the left side of the colon Wrapped in double quotation marks Within each object, keys need to be unique Values are found to the right of the colon Datatypes: strings, numbers, objects, arrays, Booleans, null You can have nested objects and arrays { "users": [ {"username" : "SammyShark", "location" : "Indian Ocean"}, {"username" : "JesseOctopus", "location" : "Pacific Ocean"}, {"username" : "DrewSquid", "location" : "Atlantic Ocean"}, {"username" : "JamieMantisShrimp", "location" : "Pacific Ocean"} ] }

14 JSON data JSON has been the most popular format of passing data from the front-end to back-end! And because of this, NoSQL database arise! NoSQL database store the data in mostly JSON format (as we will see later in the MongoDB). MySQL recently also add the support to store JSON data (see 


Download ppt "Intro to NoSQL Databases"

Similar presentations


Ads by Google