Lab 3.pdf - Lab 4 MongoDB[S18 Advanced Databases(DS Introduction MongoDB is a document-oriented DB which means It is a subclass of key-value databases

Lab 3.pdf - Lab 4 MongoDB[S18 Advanced Databases(DS...

This preview shows page 1 - 11 out of 27 pages.

Lab 4 MongoDB [S18] Advanced Databases (DS)
Image of page 1

Subscribe to view the full document.

Introduction MongoDB is a document-oriented DB, which means: - It is a subclass of key-value databases - However, MongoDB relies on the structure of the data to extract metadata for optimization - It is different from RDB in how objects are stored - In RDB, an object can be stored in multiple tables - In Document DB, the object is always stored in a single instance and every object can be different from other - In MongoDB documents are similar to JSON objects - It supports CRUD operations 2
Image of page 2
MongoDB main features - Ad hoc queries - Indexing - Replication - Load balancing - File storage - See grid filesystem - Aggregation - Built-in MapReduce - Capped collections (circular queues) 3
Image of page 3

Subscribe to view the full document.

Documents - A record in MongoDB is a document, which is a data structure composed of field and value pairs. MongoDB documents are similar to JSON objects. 4
Image of page 4
Collections - MongoDB stores documents in collections. Collections are analogous to tables in relational databases. Unlike a table, however, a collection does not require its documents to have the same schema. 5
Image of page 5

Subscribe to view the full document.

MongoDB, a closer look - Written in C++ - Actively maintained (last commit was an hour ago at the moment of writing) - Average commit frequency is above 50 per week 6 Installation instruction:
Image of page 6
MongoDB Architecture 7
Image of page 7

Subscribe to view the full document.

Data as Documents - Data is stored in BSON - BSON documents contain fields, fields contain values (including arrays, binary data and sub documents) - Closely aligned to the structure of objects in programming languages - Faster for developers to map data - Keep all data for a given record in a single document 8
Image of page 8
Data as Documents - Consider for example a data model for blogging application: - In RDB, it would involve having separate tables for Users, Categories, Articles, Comments etc - In MongoDB this could be modelled by two collections: one for Users and one for Articles: 9
Image of page 9

Subscribe to view the full document.

Data as Documents - Consider for example a data model for blogging application: - In RDB, it would involve having separate tables for Users, Categories, Articles, Comments etc - In MongoDB this could be modelled by two collections: one for Users and one for Articles - Pros: - Data is more localized, no need to join - A single read can return the whole document - Higher scalability - Cons: - What happens if you have many transactions?
Image of page 10
Image of page 11
  • Fall '16
  • Adil Khan

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes