#note NoSQL のデータベース例 (RDB よりも各サービスでの違いが顕著に感じる) - Key-Value Store - [DynamoDB](https://aws.amazon.com/jp/dynamodb/) - Redis - Document Store - MongoDB - [Cloud Firestore](https://firebase.google.com/docs/firestore) - Wide-Column Store - Apache Cassandra - [Google Bigtable](https://cloud.google.com/bigtable) - Graph Database - [Neo4j](https://neo4j.com/) [MongoDB 101: Non-Relational Databases for Beginners](https://www.mongodb.com/academia/courses/mongodb-101-nonrelational-for-beginners) ![image](https://gyazo.com/720d38ba64080da40b36bfc339e16e5a/thumb/1000) この Link or Embed という考え方がシンプルでいて、わかりやすかった もちろん Embded すると1つのクエリで情報を取得できるのでパフォーマンス的には嬉しい 一方で複数箇所から利用されるのであれば write をいろんなところでしないといけなくなってしまうので Link を選択するのも重要 (ただしパフォーマンスがトレードオフ対象になる) メモ - 基本的にはデータに局所性がある (上記でいうと Embedded が代表例) のでトランザクションは不要なケースが多い - その上でも Atomic な操作が必要な場合には、 [Saga 分散トランザクションパターン](https://learn.microsoft.com/ja-jp/azure/architecture/patterns/saga) のように分散システムの考え方が必要 - -> というよりも NoSQL 自体が DB を水平スケールする前提での取り組みなので最初から分散システムの考え方をする必要があるのだなあ - トランザクションをサポートしているケースもありそう (もちろんオーバーヘッドが増える) - e.g. [https://firebase.google.com/docs/firestore/manage-data/transactions](https://firebase.google.com/docs/firestore/manage-data/transactions) - [https://firebase.google.com/docs/firestore/best-practices?hl=ja#transactions_retries](https://firebase.google.com/docs/firestore/best-practices?hl=ja#transactions_retries) 参考 [NoSQLデータモデリング技法](https://gist.github.com/matope/2396234) [http://www.slideshare.net/mongodb/mongodb-schema-design-richard-kreuters-mongo-berlin-preso](http://www.slideshare.net/mongodb/mongodb-schema-design-richard-kreuters-mongo-berlin-preso) [http://www.michaelhamrah.com/blog/2011/08/data-modeling-at-scale-mongodb-mongoid-callbacks-and-denormalizing-data-for-efficiency/](http://www.michaelhamrah.com/blog/2011/08/data-modeling-at-scale-mongodb-mongoid-callbacks-and-denormalizing-data-for-efficiency/) [http://seancribbs.com/tech/2009/09/28/modeling-a-tree-in-a-document-database/](http://seancribbs.com/tech/2009/09/28/modeling-a-tree-in-a-document-database/) [http://www.mongodb.org/display/DOCS/Schema+Design](http://www.mongodb.org/display/DOCS/Schema+Design) [http://www.mongodb.org/display/DOCS/Trees+in+MongoDB](http://www.mongodb.org/display/DOCS/Trees+in+MongoDB) [http://blog.fiesta.cc/post/11319522700/walkthrough-mongodb-data-modeling](http://blog.fiesta.cc/post/11319522700/walkthrough-mongodb-data-modeling)