Cloud Computing-Based Service Design and Programming
Andy Kuo @andikan
1
Slide 2
Slide 2 text
DB = DataBase
(n.) 資料庫
A database is an organized collection of data.
2
Slide 3
Slide 3 text
3
Slide 4
Slide 4 text
Hello DB!
4
Slide 5
Slide 5 text
SQL
Relational Database
5
Slide 6
Slide 6 text
NoSQL
http://nosql-database.org/
Not Only SQL
6
Slide 7
Slide 7 text
Volume • Velocity • Variety
7
Slide 8
Slide 8 text
Key / Value Column Graph Document
8
Slide 9
Slide 9 text
MongoDB
scalable, high-performance, open source NoSQL database
• document store
• full index support
• replication
• querying
• map / reduce
9
Slide 10
Slide 10 text
MongoDB
implemented in C++
drivers are available in many language
http://docs.mongodb.org/manual/applications/drivers/
MongoDB Drivers and Client Libraries
10
Slide 11
Slide 11 text
BSON
Binary JSON
BSON = JSON + a few additions
• ObjectID
• Timestamp
• Date
11
Download : http://www.mongodb.org/downloads
Installation : http://docs.mongodb.org/manual/installation/
Getting Started
14
Slide 15
Slide 15 text
http://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/
https://speakerdeck.com/xpsteven/ntu-ccsp-2012fall-node-dot-js-number-3-mongoose
Install MongoDB on Windows
15
Slide 16
Slide 16 text
mongod
The primary daemon process for the MongoDB system
It handles data requests, manages data format, and performs background management operations
16
Slide 17
Slide 17 text
Default dbpath /data/db
Can use your custom directory
17
Slide 18
Slide 18 text
Listen on localhost : 27017
18
Slide 19
Slide 19 text
admin web console
localhost : 28017
19
Slide 20
Slide 20 text
Connect to mongod
By default, mongo looking for a database server listening on port 27017 on the localhost
20
Slide 21
Slide 21 text
Welcome to the MongoDB shell
Session will use the test database by default
Access with the Javascript Language
21
Slide 22
Slide 22 text
http://try.mongodb.org/
22
Slide 23
Slide 23 text
Name of the current database
Display the list of databases
Switch to a new database named cooldb
23
The versionKey is a property set on each document when first created by Mongoose.
This keys value contains the internal revision of the document.
__v
http://mongoosejs.com/docs/guide.html#versionKey
48
Slide 49
Slide 49 text
Query with Mongoose
49
Slide 50
Slide 50 text
Query with Mongoose
50
Slide 51
Slide 51 text
Population
Pseudo-joins
Reference to documents in other collections
51
Mongoose Plugins
Re-use schema functionality in your own project
- Auto increment
https://github.com/codetunnel/mongoose-auto-increment
- Timestamp
https://github.com/drudge/mongoose-timestamp
58