1 / 24

Daprota M2 Data modeling service for M ongoDB

Daprota M2 Data modeling service for M ongoDB. Goran Zugic goran.zugic@daprota.com June 2014. Part 1 (20-25 mins ) Introduction MongoDB data m odeling overview Types of data models What is M2? When to use M2? M2 technology Part 2 (20-25 mins ) M2 demonstration Show website

toshi
Download Presentation

Daprota M2 Data modeling service for M ongoDB

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. DaprotaM2Data modeling service for MongoDB Goran Zugic goran.zugic@daprota.com June 2014

  2. Part 1 (20-25 mins) • Introduction • MongoDB data modeling overview • Types of data models • What is M2? • When to use M2? • M2 technology • Part 2 (20-25 mins) • M2 demonstration • Show website • Public models • Explore • Documentation • Registration • Show some public models • Product (embedded) • Referenced One-to_many V2 (referenced) • Atomic Operation (hybrid) • Show M2 features • Create one-to-few, one-to-many, and one-to-squillion models (based on patterns from William Zola’s MongoDB blog post) • Q & A Agenda

  3. Part 1

  4. Flexible schema • no need to determine and declare structural data elements before inserting data • Document-based data model • Collections, documents, fields, references • Document structure is not enforced what enables mapping of documents to any object (entity) • While it is not required, it is recommended to have uniform document structure across single collections. Introduction

  5. Atomicity • There is no concept of transaction in MongoDB • All operations that create or change data (e.g., write, update, delete) are atomic at the document level only • MongoDBdoes not support joins. • MongoDB is designed to take care of many performance aspects by itself but it leaves to designers and developers to figure out the best possible data model for the specific application patterns. Introduction (cont.)

  6. It may come as a surprise to some people, but as AsyaKamsky wrote in her 10 Things You Should Know About Running MongoDB at Scale article, on the High Scalability portal, the biggest impact to performance is “how well the schema design fits with the application needs“. Asya came to this conclusion after having seen hundreds of production deployments. This is a fairly firm statement that proves the importance of data modeling for MongoDB-based systems. Introduction (cont.)

  7. MongoDB data models created in M2 includes • Collections (analogous to JSON objects, RDBMS tables) • Documents (analogous to RDBMS table rows) • Fields (analogous to RDBMS table columns) • References (analogous to RDBMS foreign keys) Data Modeling Overview Model Collection Reference Document Field Field

  8. Data Modeling Overview (cont.) Manual Reference parentId _id Database A DBRef _id parentId Database B Database A

  9. Read and write operations • Document growth • Automicity • Sharding Key Considerations with Data Modeling

  10. There are several types of MongoDBdata models you can create: • Embedding Model • Referencing Model • Hybrid Model that combines embedding and referencing models. • Embedding model enables de-normalization of data, which means that two or more related pieces of data will be stored in a single document. Frequently it is a choice for “contains” and “one-to-many” relationships between entities (documents). • Related data can be fetched with a single query • Duplication of data; multi-document changes • It is a better choice for • atomicity • smaller documents; • data does not change or does not grow much; • data that you usually fetch together; • fast reads Types of Data Models

  11. Referencing model enables normalization of data by storing references between documents to indicate a relationship between the data stored in each document. • No duplication of data • Only one document change is required to change data • No joins. Retrieving data from multiple documents requires multiple queries to be done by an application. • It is a better choice for • when embedding would result in extensive data duplication (but would not provide a significant read performance advantage) and/or data fragmentation when embedded documents grow; • to present more complex “many-to-many” relationships; • to model large hierarchical data sets. • fast writes • Hybrid model is a combination of embedding and referencing model. It is usually used when neither embedding or referencing model is the best choice but their combination makes the most balanced model. Types of Data Models (cont.)

  12. Data Modeling Overview (cont.) Embedding Model Collection C1 Doc D1 Doc D2 Referencing Model Collection C1 Collection C2 Doc D2 Doc D1

  13. M2 is a cloud service for the creation and management of MongoDB data models • M2 features include: • Management of models and their elements (collections, documents, fields and references) • Copying and versioning of models, collections and documents via related Copy utilities • Multiple document formats for a collection • Full models' view in a JSON-like format (M2 notation) • Export/Import Models • Public models sharing • Models documentation repository • Messaging between M2 users What is M2?

  14. Analysis and design are important steps in an overall engineering process of system architecture, design, development and implementation/deployment. M2 is used for a data model (schema) design. Up-to-date data model management with an on-line (cloud) service capability. Educative purposes. Public data model samples based on various design patterns and best practices. When to use M2?

  15. Models can be documented via documentation stored and managed in M2 documentation repository or referenced via external links. • Free service. More plans will be available in near future. • Code generation (future releases) • Standardizing (based on M2 data models) and automating the writing of data access code (from M2 data models) can save significant developer time and make the resulting code better defined and easier to maintain and to interface with. • Model visualisation (future releases) When to use M2? (cont.)

  16. MongoDB Java, Java Servlets, JSP, jQuery Tomcat Red Hat Enterprise Linux M2Technology

  17. Part 2(M2 Demonstration)

  18. http://www.daprota.com https://m2.daprota.com How to Access M2?

  19. > db.person.findOne() { _id: ObjectId(‘ABC’), name: ‘John Smith', sin: '123-456-7890', addresses : [ { street: '123 Sesame St', city: ‘Toronto', cc: ‘CA' }, { street: '123 Avenue Q', city: 'New York', cc: 'US' } ] } One-to-Few

  20. > db.parts.findOne() { _id : ObjectId('AAA'), partno : '123-aff-456', name : '#4 grommet', qty: 94, price: 3.99 } > db.products.findOne() { _id : ObjectId(‘BBB’), name : 'left-handed smoke shifter', manufacturer : 'Acme Corp', catalog_number: 1234, parts : [ // array of references to Part documents ObjectId('AAA'), // reference to the #4 grommet above ObjectId('F17'), // reference to a different Part ObjectId('D2A'), // etc ] One-to-Many

  21. > db.hosts.findOne() { _id : ObjectId('AAAB'), name : 'goofy.example.com', ipaddr : '127.66.66.66' } >db.logmsg.findOne() { time : ISODate("2014-03-28T09:42:41.382Z"), message : 'cpu is on fire!', host: ObjectId('AAAB') // Reference to the Host document } One-to-Squillions

  22. M2 Documentation http://www.daprota.com/doc/m2/m2-documentation.html • Data Models (MongoDB Documentation) http://docs.mongodb.org/manual/data-modeling/ • MongoDB: The Definitive Guide by Kristina Chodorow(2013) • MongoDBAppliedDesignPatterns by Rick Copeland(2013) • MongoDBinAction by Kyle Banker(2011) Documentation and Books

  23. Q&A

  24. Thank you! Goran Zugic goran.zugic@daprota.com http://www.daprota.com https://m2.daprota.com @DaprotaM2 http://goranzugic.wordpress.com/ http://www.goranzugic.com/

More Related