24
NOSQL & JSON 2014/10/12 WU TIEN YANG

NoSQL & JSON

Embed Size (px)

DESCRIPTION

NOSQL and JSON introduction

Citation preview

Page 1: NoSQL & JSON

NOSQL & JSON

2014/10/12 WU TIEN YANG

Page 2: NoSQL & JSON

JSON

Page 3: NoSQL & JSON

JSON JAVASCRIPT OBJECT NOTATION

• serializing data objects

• Human-readable,useful for data interchange

• useful for storing semistructured data

Page 4: NoSQL & JSON

JSON

• Basic value

• number,string,boolean

• Objects{}

• label-value pairs

• Arrays[]

• list of value

Page 5: NoSQL & JSON

LIVE DEMO JSON EDITOR ONLINE

Page 6: NoSQL & JSON

JSON

Relational JSON

Structure TablesNest,label-value,array

Schema Fix Flexible

Queries simple expressive language XD,widely use

Ordering None Arrays

Implementation Native system NOSQL system

Page 7: NoSQL & JSON

JSON JAVASCRIPT OBJECT NOTATION

• Sets of label-value pairs

• Arrays of values

• Base values from predefined types

JSON fileJSON parse program objects

syntactic error

Page 8: NoSQL & JSON

WHEN JSON MEET PYTHON!

Page 9: NoSQL & JSON

JSON

JSON PYTHON

Object dict

array list,tuple

str unicode

null none

number int,long,float

encoding: python -> json json.dumps()

decoding: json -> python json.loads()

Page 10: NoSQL & JSON

LIVE DEMO

Page 11: NoSQL & JSON

NOSQL

Page 12: NoSQL & JSON

WHY WE CHOOSE NOSQL?

Page 13: NoSQL & JSON

Relational DBMS face the problem!

problem: semi-structure data poor performance

problem: scaling difficult / expensive / impossible ->BIG DATA

Page 14: NoSQL & JSON

NOSQL

• SQL : Traditional relational DBMS

• NOSQL = not only SQL

• MASSIVE!

Page 15: NoSQL & JSON

NOSQL

• Flexibles schema

• Quicker / Cheaper to set up

• Massive scalability

• Relaxed consistency -high performance,availability

NOSQL system V.S Traditional relational DBMS

Page 16: NoSQL & JSON

NOSQL

• Flexibles schema

• Quicker / Cheaper to set up

• Massive scalability

• Relaxed consistency -high performance,availability

NOSQL system V.S Traditional relational DBMS

no declarative query language -> more programming

Relaxed consistency ->fewer guarantees

Page 17: NoSQL & JSON

NOSQL MAPREDUCE FRAMEWORK

• no data model,data stored in files

• specific function

• map(),reduce(),read(),write()

• system provides fault-tolerance,scability

Page 18: NoSQL & JSON

NOSQL MAPREDUCE FRAMEWORK

• Map: divide problem into subproblems

• map(item) -> <key,value>pairs

• Reduce: do work on subproblems,combine result

• reduce(key,lists of value) -> result

Page 19: NoSQL & JSON

NOSQL MAPREDUCE EXAMPLE

• record: User ID,URL,timestamp,additional-info

• task: Count number of accesses for each domain

• map(record) -> <domain,value>

• reduce(domain,lists of value) -> <domain,sum>

Web log analysis

Page 20: NoSQL & JSON

NOSQL KEY-VALUE STORES

• extremely simple interface

• Data model: {key,value} pairs

• Operation : insert , update , delete

• implement : efficiency,scalability,fault-tolerance

• record distributed to nodes base on key

• eventual consistency

Page 21: NoSQL & JSON

MONGODB

Page 22: NoSQL & JSON

MONGODB NOSQL DATABASE

RDBMS MongoDB

Database Database

Table collection

Record/Row Document

Column Field

Primary Key _id

a record = a document

many documents = a collection

Page 23: NoSQL & JSON

LIVE DOME TRY IT OUT !

Page 24: NoSQL & JSON

REFERENCES

• Stanford University -DB introduction to Databases

• python library - storing json

• mongoDB