nosql & json
DESCRIPTION
NOSQL and JSON introductionTRANSCRIPT
![Page 1: NoSQL & JSON](https://reader033.vdocuments.us/reader033/viewer/2022042507/558eb9121a28ab7d778b462b/html5/thumbnails/1.jpg)
NOSQL & JSON
2014/10/12 WU TIEN YANG
![Page 2: NoSQL & JSON](https://reader033.vdocuments.us/reader033/viewer/2022042507/558eb9121a28ab7d778b462b/html5/thumbnails/2.jpg)
JSON
![Page 3: NoSQL & JSON](https://reader033.vdocuments.us/reader033/viewer/2022042507/558eb9121a28ab7d778b462b/html5/thumbnails/3.jpg)
JSON JAVASCRIPT OBJECT NOTATION
• serializing data objects
• Human-readable,useful for data interchange
• useful for storing semistructured data
![Page 4: NoSQL & JSON](https://reader033.vdocuments.us/reader033/viewer/2022042507/558eb9121a28ab7d778b462b/html5/thumbnails/4.jpg)
JSON
• Basic value
• number,string,boolean
• Objects{}
• label-value pairs
• Arrays[]
• list of value
![Page 6: NoSQL & JSON](https://reader033.vdocuments.us/reader033/viewer/2022042507/558eb9121a28ab7d778b462b/html5/thumbnails/6.jpg)
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](https://reader033.vdocuments.us/reader033/viewer/2022042507/558eb9121a28ab7d778b462b/html5/thumbnails/7.jpg)
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](https://reader033.vdocuments.us/reader033/viewer/2022042507/558eb9121a28ab7d778b462b/html5/thumbnails/8.jpg)
WHEN JSON MEET PYTHON!
![Page 9: NoSQL & JSON](https://reader033.vdocuments.us/reader033/viewer/2022042507/558eb9121a28ab7d778b462b/html5/thumbnails/9.jpg)
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](https://reader033.vdocuments.us/reader033/viewer/2022042507/558eb9121a28ab7d778b462b/html5/thumbnails/10.jpg)
LIVE DEMO
![Page 11: NoSQL & JSON](https://reader033.vdocuments.us/reader033/viewer/2022042507/558eb9121a28ab7d778b462b/html5/thumbnails/11.jpg)
NOSQL
![Page 12: NoSQL & JSON](https://reader033.vdocuments.us/reader033/viewer/2022042507/558eb9121a28ab7d778b462b/html5/thumbnails/12.jpg)
WHY WE CHOOSE NOSQL?
![Page 13: NoSQL & JSON](https://reader033.vdocuments.us/reader033/viewer/2022042507/558eb9121a28ab7d778b462b/html5/thumbnails/13.jpg)
Relational DBMS face the problem!
problem: semi-structure data poor performance
problem: scaling difficult / expensive / impossible ->BIG DATA
![Page 14: NoSQL & JSON](https://reader033.vdocuments.us/reader033/viewer/2022042507/558eb9121a28ab7d778b462b/html5/thumbnails/14.jpg)
NOSQL
• SQL : Traditional relational DBMS
• NOSQL = not only SQL
• MASSIVE!
![Page 15: NoSQL & JSON](https://reader033.vdocuments.us/reader033/viewer/2022042507/558eb9121a28ab7d778b462b/html5/thumbnails/15.jpg)
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](https://reader033.vdocuments.us/reader033/viewer/2022042507/558eb9121a28ab7d778b462b/html5/thumbnails/16.jpg)
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](https://reader033.vdocuments.us/reader033/viewer/2022042507/558eb9121a28ab7d778b462b/html5/thumbnails/17.jpg)
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](https://reader033.vdocuments.us/reader033/viewer/2022042507/558eb9121a28ab7d778b462b/html5/thumbnails/18.jpg)
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](https://reader033.vdocuments.us/reader033/viewer/2022042507/558eb9121a28ab7d778b462b/html5/thumbnails/19.jpg)
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](https://reader033.vdocuments.us/reader033/viewer/2022042507/558eb9121a28ab7d778b462b/html5/thumbnails/20.jpg)
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](https://reader033.vdocuments.us/reader033/viewer/2022042507/558eb9121a28ab7d778b462b/html5/thumbnails/21.jpg)
MONGODB
![Page 22: NoSQL & JSON](https://reader033.vdocuments.us/reader033/viewer/2022042507/558eb9121a28ab7d778b462b/html5/thumbnails/22.jpg)
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 24: NoSQL & JSON](https://reader033.vdocuments.us/reader033/viewer/2022042507/558eb9121a28ab7d778b462b/html5/thumbnails/24.jpg)
REFERENCES
• Stanford University -DB introduction to Databases
• python library - storing json
• mongoDB