SlideShare a Scribd company logo
PostgreSQL
MongoDB

        CTO
      @basuke
not only
but also
PostgreSQLからMongoDBへ
http://www.assiston.co.jp/

•

•           ~1000

•   30~80   PV
•

•

•

• Google
•

•

•

•
MongoDB
  (   )
PostgreSQLからMongoDBへ
•   PostgreSQL 7.4 => 8.1

•   PHP 4.3 => 4.4 => 5.1

•
•   MongoDB 1.6.3

•   PHP 5.3

•   Lithium

•
•
PostgreSQLからMongoDBへ
Lithium

•   http://lithify.me/

•   5.3

•   CakePHP

•   MongoDB / CouchDB

•   ↑                    RDB   w
PHP            MongoDB


 •   Lithium

 •         pecl   mongo

     •
Item::find('all', array(

   
 
 'conditions' => array(

   
 
 
 'category' => $tag,

   
 
 
 'visible' => true,

   
 
 ),

   
 
 'order' => array(

   
 
 
      
   
 'position'=>'DESC', 'id' => 'DESC'),

   
 ));
$item_collection->find(array(

   
 
 'category' => $tag,

   
 
 'visible' => true,

   
 )).sort(array(

   
 
 'position'=>-1, 'id' => -1),

   
 ));
•   mongoimport / mongoexport

    •   JSON

    •                 JSON

•   PHP

•
•
•   mongoimport -d assiston -c items --drop --file
    items.dump

    {"no" : 123456, "items" : [{"at" : 1285679232000}}
Mongo Extended JSON

•   http://www.mongodb.org/display/DOCS/Mongo
    +Extended+JSON

•                 $binary, $date, $oid

•        $date      milliseconds

    •   PHP      32bit int
•
    •   PHP JSON

•   TIMESTAMP                          json_encode



    •   '2010-12-10 17:20:21' => 1291969221

    •   1291969221 sec => "||date:1291969221000||"

    •   JSON

    •   "||date:1291969221000||" => Date(1291969221000)
•   PHP           w

    •   Python        OK

    •   pgmongo
1: atomic
•
•
    •

•
CREATE TABLE ORDERS (
 id SERIAL PRIMARY KEY,
 total INTEGER NOT NULL,     {
 ...                          no: integer,
);                            total: integer,
                              items: [
CREATE TABLE ORDER_ITEMS (     { price: integer, ...},
 id SERIAL PRIMARY KEY,
                              ]
 order_id INTEGER
                               ...
   REFERS TO ORDERS,
                             }
 price INTEGER NOT NULL,
 ...
);
2:
•   ObjectID

•
•   function(seqname) { return
    db.sequences.findAndModify({ query:{_id:seqname},
    update: {$inc: {val:1}}, upsert: true, 'new': true}).val; }

•   db.system.js

    •   db.eval("return sequence('abc')")
3: mongo on github


•   https://github.com/mongodb/mongo/tree/
    master/jstests

•   MongoDB      JavaScript
Thank you.
http://basuke.com/
Ad

Recommended

MongoDBで作るソーシャルデータ新解析基盤
MongoDBで作るソーシャルデータ新解析基盤
Takahiro Inoue
 
MongoDB Oplog入門
MongoDB Oplog入門
Takahiro Inoue
 
MongoDB全機能解説2
MongoDB全機能解説2
Takahiro Inoue
 
20110514 mongo dbチューニング
20110514 mongo dbチューニング
Yuichi Matsuo
 
MongoDB dla administratora
MongoDB dla administratora
3camp
 
Mongo db dla administratora
Mongo db dla administratora
Łukasz Jagiełło
 
Database api
Database api
InternetDevels
 
2016 gunma.web games-and-asm.js
2016 gunma.web games-and-asm.js
Noritada Shimizu
 
Couchdb
Couchdb
Саги Усаги
 
20151224-games
20151224-games
Noritada Shimizu
 
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
OlinData
 
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
Walter Heck
 
MongoDB Aggregation
MongoDB Aggregation
Amit Ghosh
 
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
MongoSF
 
高性能かつスケールアウト可能なHPCクラウド AIST Super Green Cloud
高性能かつスケールアウト可能なHPCクラウド AIST Super Green Cloud
Ryousei Takano
 
MongoDB
MongoDB
Steve Klabnik
 
Mongodb workshop
Mongodb workshop
Harun Yardımcı
 
CGI.pm - 3ло?!
CGI.pm - 3ло?!
Anatoly Sharifulin
 
Inside MongoDB: the Internals of an Open-Source Database
Inside MongoDB: the Internals of an Open-Source Database
Mike Dirolf
 
Absolute Beginners Guide to Puppet Through Types - PuppetConf 2014
Absolute Beginners Guide to Puppet Through Types - PuppetConf 2014
Puppet
 
Getting Started with MongoDB
Getting Started with MongoDB
Michael Redlich
 
Litebox
Litebox
meli media
 
Paris js extensions
Paris js extensions
erwanl
 
Google App Engine Developer - Day3
Google App Engine Developer - Day3
Simon Su
 
JavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovy
Yasuharu Nakano
 
Full-Stack JavaScript with Node.js
Full-Stack JavaScript with Node.js
Michael Lehmann
 
Brief intro to clojure
Brief intro to clojure
Roy Rutto
 
Mongodb Aggregation Pipeline
Mongodb Aggregation Pipeline
zahid-mian
 
NoSQL を Ruby で実践するための n 個の方法
NoSQL を Ruby で実践するための n 個の方法
Tomohiro Nishimura
 
MongoDB Schema Design (Richard Kreuter's Mongo Berlin preso)
MongoDB Schema Design (Richard Kreuter's Mongo Berlin preso)
MongoDB
 

More Related Content

What's hot (20)

Couchdb
Couchdb
Саги Усаги
 
20151224-games
20151224-games
Noritada Shimizu
 
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
OlinData
 
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
Walter Heck
 
MongoDB Aggregation
MongoDB Aggregation
Amit Ghosh
 
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
MongoSF
 
高性能かつスケールアウト可能なHPCクラウド AIST Super Green Cloud
高性能かつスケールアウト可能なHPCクラウド AIST Super Green Cloud
Ryousei Takano
 
MongoDB
MongoDB
Steve Klabnik
 
Mongodb workshop
Mongodb workshop
Harun Yardımcı
 
CGI.pm - 3ло?!
CGI.pm - 3ло?!
Anatoly Sharifulin
 
Inside MongoDB: the Internals of an Open-Source Database
Inside MongoDB: the Internals of an Open-Source Database
Mike Dirolf
 
Absolute Beginners Guide to Puppet Through Types - PuppetConf 2014
Absolute Beginners Guide to Puppet Through Types - PuppetConf 2014
Puppet
 
Getting Started with MongoDB
Getting Started with MongoDB
Michael Redlich
 
Litebox
Litebox
meli media
 
Paris js extensions
Paris js extensions
erwanl
 
Google App Engine Developer - Day3
Google App Engine Developer - Day3
Simon Su
 
JavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovy
Yasuharu Nakano
 
Full-Stack JavaScript with Node.js
Full-Stack JavaScript with Node.js
Michael Lehmann
 
Brief intro to clojure
Brief intro to clojure
Roy Rutto
 
Mongodb Aggregation Pipeline
Mongodb Aggregation Pipeline
zahid-mian
 
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
OlinData
 
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
Walter Heck
 
MongoDB Aggregation
MongoDB Aggregation
Amit Ghosh
 
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
MongoSF
 
高性能かつスケールアウト可能なHPCクラウド AIST Super Green Cloud
高性能かつスケールアウト可能なHPCクラウド AIST Super Green Cloud
Ryousei Takano
 
Inside MongoDB: the Internals of an Open-Source Database
Inside MongoDB: the Internals of an Open-Source Database
Mike Dirolf
 
Absolute Beginners Guide to Puppet Through Types - PuppetConf 2014
Absolute Beginners Guide to Puppet Through Types - PuppetConf 2014
Puppet
 
Getting Started with MongoDB
Getting Started with MongoDB
Michael Redlich
 
Paris js extensions
Paris js extensions
erwanl
 
Google App Engine Developer - Day3
Google App Engine Developer - Day3
Simon Su
 
JavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovy
Yasuharu Nakano
 
Full-Stack JavaScript with Node.js
Full-Stack JavaScript with Node.js
Michael Lehmann
 
Brief intro to clojure
Brief intro to clojure
Roy Rutto
 
Mongodb Aggregation Pipeline
Mongodb Aggregation Pipeline
zahid-mian
 

Viewers also liked (6)

NoSQL を Ruby で実践するための n 個の方法
NoSQL を Ruby で実践するための n 個の方法
Tomohiro Nishimura
 
MongoDB Schema Design (Richard Kreuter's Mongo Berlin preso)
MongoDB Schema Design (Richard Kreuter's Mongo Berlin preso)
MongoDB
 
イマドキのフロントエンドエンジニアの道具箱
イマドキのフロントエンドエンジニアの道具箱
Fumio SAGAWA
 
MongoDBを用いたソーシャルアプリのログ解析 〜解析基盤構築からフロントUIまで、MongoDBを最大限に活用する〜
MongoDBを用いたソーシャルアプリのログ解析 〜解析基盤構築からフロントUIまで、MongoDBを最大限に活用する〜
Takahiro Inoue
 
MongoDBを使用したモバイルゲーム開発
MongoDBを使用したモバイルゲーム開発
Genki Yamada
 
MongoDB全機能解説1
MongoDB全機能解説1
Takahiro Inoue
 
NoSQL を Ruby で実践するための n 個の方法
NoSQL を Ruby で実践するための n 個の方法
Tomohiro Nishimura
 
MongoDB Schema Design (Richard Kreuter's Mongo Berlin preso)
MongoDB Schema Design (Richard Kreuter's Mongo Berlin preso)
MongoDB
 
イマドキのフロントエンドエンジニアの道具箱
イマドキのフロントエンドエンジニアの道具箱
Fumio SAGAWA
 
MongoDBを用いたソーシャルアプリのログ解析 〜解析基盤構築からフロントUIまで、MongoDBを最大限に活用する〜
MongoDBを用いたソーシャルアプリのログ解析 〜解析基盤構築からフロントUIまで、MongoDBを最大限に活用する〜
Takahiro Inoue
 
MongoDBを使用したモバイルゲーム開発
MongoDBを使用したモバイルゲーム開発
Genki Yamada
 
MongoDB全機能解説1
MongoDB全機能解説1
Takahiro Inoue
 
Ad

Similar to PostgreSQLからMongoDBへ (20)

From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)
Night Sailer
 
MongoDB World 2018: Keynote
MongoDB World 2018: Keynote
MongoDB
 
2013-03-23 - NoSQL Spartakiade
2013-03-23 - NoSQL Spartakiade
Johannes Hoppe
 
MongoDB: a gentle, friendly overview
MongoDB: a gentle, friendly overview
Antonio Pintus
 
MongoDB, PHP and the cloud - php cloud summit 2011
MongoDB, PHP and the cloud - php cloud summit 2011
Steven Francia
 
How to use MongoDB with CakePHP
How to use MongoDB with CakePHP
ichikaway
 
MongoUK - PHP Development
MongoUK - PHP Development
Boxed Ice
 
MongoUK - PHP Development
MongoUK - PHP Development
Boxed Ice
 
REST Web API with MongoDB
REST Web API with MongoDB
MongoDB
 
FrozenRails Training
FrozenRails Training
Mike Dirolf
 
mongodb-introduction
mongodb-introduction
Tse-Ching Ho
 
Mongo NYC PHP Development
Mongo NYC PHP Development
Fitz Agard
 
2012-08-29 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)
2012-08-29 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)
Johannes Hoppe
 
Latinoware
Latinoware
kchodorow
 
[MongoDB.local Bengaluru 2018] Keynote
[MongoDB.local Bengaluru 2018] Keynote
MongoDB
 
Introduction to MongoDB
Introduction to MongoDB
Chun-Kai Wang
 
Advanced MongoDB #1
Advanced MongoDB #1
Takahiro Inoue
 
Keynote - Speaker: Grigori Melnik
Keynote - Speaker: Grigori Melnik
MongoDB
 
视觉中国的MongoDB应用实践(QConBeijing2011)
视觉中国的MongoDB应用实践(QConBeijing2011)
Night Sailer
 
MongoDB开发应用实践
MongoDB开发应用实践
iammutex
 
From mysql to MongoDB(MongoDB2011北京交流会)
From mysql to MongoDB(MongoDB2011北京交流会)
Night Sailer
 
MongoDB World 2018: Keynote
MongoDB World 2018: Keynote
MongoDB
 
2013-03-23 - NoSQL Spartakiade
2013-03-23 - NoSQL Spartakiade
Johannes Hoppe
 
MongoDB: a gentle, friendly overview
MongoDB: a gentle, friendly overview
Antonio Pintus
 
MongoDB, PHP and the cloud - php cloud summit 2011
MongoDB, PHP and the cloud - php cloud summit 2011
Steven Francia
 
How to use MongoDB with CakePHP
How to use MongoDB with CakePHP
ichikaway
 
MongoUK - PHP Development
MongoUK - PHP Development
Boxed Ice
 
MongoUK - PHP Development
MongoUK - PHP Development
Boxed Ice
 
REST Web API with MongoDB
REST Web API with MongoDB
MongoDB
 
FrozenRails Training
FrozenRails Training
Mike Dirolf
 
mongodb-introduction
mongodb-introduction
Tse-Ching Ho
 
Mongo NYC PHP Development
Mongo NYC PHP Development
Fitz Agard
 
2012-08-29 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)
2012-08-29 - NoSQL Bootcamp (Redis, RavenDB & MongoDB für .NET Entwickler)
Johannes Hoppe
 
[MongoDB.local Bengaluru 2018] Keynote
[MongoDB.local Bengaluru 2018] Keynote
MongoDB
 
Introduction to MongoDB
Introduction to MongoDB
Chun-Kai Wang
 
Keynote - Speaker: Grigori Melnik
Keynote - Speaker: Grigori Melnik
MongoDB
 
视觉中国的MongoDB应用实践(QConBeijing2011)
视觉中国的MongoDB应用实践(QConBeijing2011)
Night Sailer
 
MongoDB开发应用实践
MongoDB开发应用实践
iammutex
 
Ad

More from Basuke Suzuki (7)

CoAP Talk
CoAP Talk
Basuke Suzuki
 
初めての単体テスト
初めての単体テスト
Basuke Suzuki
 
Introducing CakeEntity
Introducing CakeEntity
Basuke Suzuki
 
Introducing CakeEntity
Introducing CakeEntity
Basuke Suzuki
 
Kiosk / PHP
Kiosk / PHP
Basuke Suzuki
 
iOS4時代の位置情報サービスの使い方
iOS4時代の位置情報サービスの使い方
Basuke Suzuki
 
iPhoneのオモチャ箱 - 刊行記念イベント@ジュンク堂新宿 - バスケ
iPhoneのオモチャ箱 - 刊行記念イベント@ジュンク堂新宿 - バスケ
Basuke Suzuki
 
初めての単体テスト
初めての単体テスト
Basuke Suzuki
 
Introducing CakeEntity
Introducing CakeEntity
Basuke Suzuki
 
Introducing CakeEntity
Introducing CakeEntity
Basuke Suzuki
 
iOS4時代の位置情報サービスの使い方
iOS4時代の位置情報サービスの使い方
Basuke Suzuki
 
iPhoneのオモチャ箱 - 刊行記念イベント@ジュンク堂新宿 - バスケ
iPhoneのオモチャ箱 - 刊行記念イベント@ジュンク堂新宿 - バスケ
Basuke Suzuki
 

Recently uploaded (20)

PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
 
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
 
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
Connecting Data and Intelligence: The Role of FME in Machine Learning
Connecting Data and Intelligence: The Role of FME in Machine Learning
Safe Software
 
Securing AI - There Is No Try, Only Do!.pdf
Securing AI - There Is No Try, Only Do!.pdf
Priyanka Aash
 
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
 
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Safe Software
 
The Future of AI Agent Development Trends to Watch.pptx
The Future of AI Agent Development Trends to Watch.pptx
Lisa ward
 
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Priyanka Aash
 
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
Priyanka Aash
 
2025_06_18 - OpenMetadata Community Meeting.pdf
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
 
The Future of Technology: 2025-2125 by Saikat Basu.pdf
The Future of Technology: 2025-2125 by Saikat Basu.pdf
Saikat Basu
 
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
 
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
Edge AI and Vision Alliance
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
Curietech AI in action - Accelerate MuleSoft development
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
 
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
 
Cyber Defense Matrix Workshop - RSA Conference
Cyber Defense Matrix Workshop - RSA Conference
Priyanka Aash
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
 
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
 
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
Connecting Data and Intelligence: The Role of FME in Machine Learning
Connecting Data and Intelligence: The Role of FME in Machine Learning
Safe Software
 
Securing AI - There Is No Try, Only Do!.pdf
Securing AI - There Is No Try, Only Do!.pdf
Priyanka Aash
 
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
 
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Safe Software
 
The Future of AI Agent Development Trends to Watch.pptx
The Future of AI Agent Development Trends to Watch.pptx
Lisa ward
 
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Priyanka Aash
 
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
Priyanka Aash
 
2025_06_18 - OpenMetadata Community Meeting.pdf
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
 
The Future of Technology: 2025-2125 by Saikat Basu.pdf
The Future of Technology: 2025-2125 by Saikat Basu.pdf
Saikat Basu
 
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
 
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
Edge AI and Vision Alliance
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
Curietech AI in action - Accelerate MuleSoft development
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
 
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
 
Cyber Defense Matrix Workshop - RSA Conference
Cyber Defense Matrix Workshop - RSA Conference
Priyanka Aash
 

PostgreSQLからMongoDBへ

  • 1. PostgreSQL MongoDB CTO @basuke
  • 9. PostgreSQL 7.4 => 8.1 • PHP 4.3 => 4.4 => 5.1 •
  • 10. MongoDB 1.6.3 • PHP 5.3 • Lithium • •
  • 12. Lithium • http://lithify.me/ • 5.3 • CakePHP • MongoDB / CouchDB • ↑ RDB w
  • 13. PHP MongoDB • Lithium • pecl mongo •
  • 14. Item::find('all', array( 'conditions' => array( 'category' => $tag, 'visible' => true, ), 'order' => array( 'position'=>'DESC', 'id' => 'DESC'), ));
  • 15. $item_collection->find(array( 'category' => $tag, 'visible' => true, )).sort(array( 'position'=>-1, 'id' => -1), ));
  • 16. mongoimport / mongoexport • JSON • JSON • PHP • •
  • 17. mongoimport -d assiston -c items --drop --file items.dump {"no" : 123456, "items" : [{"at" : 1285679232000}}
  • 18. Mongo Extended JSON • http://www.mongodb.org/display/DOCS/Mongo +Extended+JSON • $binary, $date, $oid • $date milliseconds • PHP 32bit int
  • 19. • PHP JSON • TIMESTAMP json_encode • '2010-12-10 17:20:21' => 1291969221 • 1291969221 sec => "||date:1291969221000||" • JSON • "||date:1291969221000||" => Date(1291969221000)
  • 20. PHP w • Python OK • pgmongo
  • 21. 1: atomic • • • •
  • 22. CREATE TABLE ORDERS ( id SERIAL PRIMARY KEY, total INTEGER NOT NULL, { ... no: integer, ); total: integer, items: [ CREATE TABLE ORDER_ITEMS ( { price: integer, ...}, id SERIAL PRIMARY KEY, ] order_id INTEGER ... REFERS TO ORDERS, } price INTEGER NOT NULL, ... );
  • 23. 2: • ObjectID • • function(seqname) { return db.sequences.findAndModify({ query:{_id:seqname}, update: {$inc: {val:1}}, upsert: true, 'new': true}).val; } • db.system.js • db.eval("return sequence('abc')")
  • 24. 3: mongo on github • https://github.com/mongodb/mongo/tree/ master/jstests • MongoDB JavaScript

Editor's Notes