0% found this document useful (0 votes)
13 views51 pages

Dbms - MongoDB Collection

The document provides an overview of non-relational databases, specifically focusing on MongoDB, including its features, advantages, and basic concepts such as documents and collections. It highlights the limitations of traditional RDBMS and explains the benefits of NoSQL databases, particularly MongoDB's flexibility and scalability. Additionally, it outlines the installation steps and the structure of data within MongoDB, emphasizing its dynamic schema and ease of use.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views51 pages

Dbms - MongoDB Collection

The document provides an overview of non-relational databases, specifically focusing on MongoDB, including its features, advantages, and basic concepts such as documents and collections. It highlights the limitations of traditional RDBMS and explains the benefits of NoSQL databases, particularly MongoDB's flexibility and scalability. Additionally, it outlines the installation steps and the structure of data within MongoDB, emphasizing its dynamic schema and ease of use.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 51

INT102

DATABASE MANAGEMENT
SYSTEMS
G.Manikandan
SAP / ICT / SOC
UNIT – IV
Introduction to Non-Relational Databases (MongoDB):

Getting Started - Documents, collections, databases, data


types. Creating, Updating and Deleting documents: Inserting
and saving documents - removing documents - updating
documents - Querying - Introduction to find querying - Type-
specific Queries

Tuesday, July 8, 2025 2


TEXT BOOK

2. Kristina Chodorow and Michel Dirolf,


“MongoDB: The Definitive Guide”,
O'Reilly Publications,
Second Edition
2012. (Unit IV)

Tuesday, July 8, 2025 3


Need for a
NonRelational DataBase

Tuesday, July 8, 2025 4


RDBMS - Limitations
• Relational Database Management Systems are
Schema Oriented
– i.e. the structure of the data should be known in
advance

• It is not possible to process unstructured


information.

• Databases are vertically scalable

Tuesday, July 8, 2025 5


NoSQL Databases
• NoSQL is a database technology driven by Cloud
Computing, the Web, Big Data and the Big Users.

• NoSQL Database, also known as “Not Only SQL” is an


alternative to SQL database which does not require
any kind of fixed table schemas unlike the SQL.

• NoSQL generally scales horizontally and avoids major


join operations on the data.

Tuesday, July 8, 2025 6


Types of No SQl data base

• Key Value pair

• Document Based

• Graph database

• Column Oriented database

Tuesday, July 8, 2025 7


Example Databases

Tuesday, July 8, 2025 8


NonRelational
• Couch DB - D
• Mongo DB - D
• Cassandra – C
• Neo4j – G
• Infinitegraph - G
• Aerospike - KV
• Riak - KV

Tuesday, July 8, 2025 9


Mongo DB

Tuesday, July 8, 2025 10


Introduction
• MongoDB was developed by a NewYork based organization named 10gen
which is now known as MongoDB Inc.

• It was initially developed as a PAAS (Platform As A Service).

• Later in 2009,
– it is introduced in the market as an open source database server
– that was maintained and supported by MongoDB Inc.

• MongoDB 2.4.9 was the latest and stable version which was released on
January 10, 2014.

Tuesday, July 8, 2025 11


Feature
• Ease of Use

• Easy Scaling

Tuesday, July 8, 2025 12


Ease of Use
• MongoDB is a document-oriented database

• A document-oriented database replaces the concept of a


“row” with a more flexible model, the “document.”

• By allowing embedded documents and arrays, the document


oriented approach makes it possible to represent complex
hierarchical relationships with a single record.

Tuesday, July 8, 2025 13


Ease of Use
• There are also no predefined schemas: a document’s keys
and values are not of fixed types or sizes.

• Without a fixed schema, adding or removing fields as needed


becomes easier.

• It is also easier to experiment.


• Developers can try dozens of models for the data and then
choose the best one to pursue.

Tuesday, July 8, 2025 14


Easy Scaling
• As the amount of data that developers need to store grows, developers
face a difficult decision: how should they scale their databases?

• Scaling a database comes down to the choice between scaling up (getting


a bigger machine) or scaling out (partitioning data across more
machines).

• Scaling up - drawbacks: large machines are often very expensive, and


eventually a physical limit is reached where a more powerful machine
cannot be purchased at any cost.

• The alternative is to scale out: to add storage space - buy another


commodity server and add it to your cluster. This is both cheaper and
more scalable; however, it is more difficult to administer a thousand
machines than it is to care for one.

Tuesday, July 8, 2025 15


Easy Scaling
• MongoDB was designed to scale out.
• Its document-oriented data model makes it easier for it to split up data
across multiple servers.

• MongoDB automatically takes care of balancing data and load across a


cluster, redistributing documents automatically and routing user requests
to the correct machines.

• This allows developers to focus on programming the application, not


scaling it.

• When a cluster need more capacity, new machines can be added and
MongoDB will figure out how the existing data should be spread to them.

Tuesday, July 8, 2025 16


Documents

Tuesday, July 8, 2025 17


Documents
• Document: an ordered set of keys with
associated values.
• The representation of a document varies by
programming language
• Most languages have a data structure such as
a map, hash, or dictionary.
• In JavaScript, documents are represented as
objects

Tuesday, July 8, 2025 18


Documents
• Example

• {"greeting" : "Hello, world!"}

• This simple document contains a single key,


"greeting", with a value of "Hello,world!".

Tuesday, July 8, 2025 19


Documents
• Example

• Most documents will be more complex than


this simple one and often will contain multiple
key/value pairs:

• {"greeting" : "Hello, world!", "foo" : 3}

Tuesday, July 8, 2025 20


Documents
• The keys in a document are strings.
• Any UTF-8 (8-bit Unicode Transformation Format) character is
allowed in a key, with a few notable exceptions:

• Keys must not contain the character \0 (the null character).


• This character is used to signify the end of a key.
• The . and $ characters have some special properties and
should be used only in certain circumstances.
• In general, they should be considered reserved, and drivers
will complain if they are used inappropriately.

Tuesday, July 8, 2025 21


Documents
• MongoDB is type-sensitive and case-sensitive.
• For example, these documents are distinct:

• {"foo" : 3}
• {"foo" : "3"}

• as are as these:

• {"foo" : 3}
• {"Foo" : 3}

Tuesday, July 8, 2025 22


MongoDB Installation steps

Tuesday, July 8, 2025 23


Collections

Tuesday, July 8, 2025 24


Collections

• A collection is a group of documents.

• MongoDB

• If a document - analog of a row in a relational database,

• Then a collection can be thought of as the analog to a table.

Tuesday, July 8, 2025 25


Dynamic Schemas
• Collections have dynamic schemas.

• This means that the documents within a single collection can


have any number of different “shapes.”

• For example, both of the following documents could be stored


in a single collection:

• {"greeting" : "Hello, world!"}


• {"foo" : 5}

Tuesday, July 8, 2025 26


Collections - Naming
• A collection is identified by its name.
• Collection names can be any UTF-8 string, with a few
restrictions:
• The empty string ("") is not a valid collection name.
• Collection names may not contain the character \0 (the null
character) because this delineates the end of a collection
name.
• You should not create any collections that start with system.,
a prefix reserved for internal collections.
• User-created collections should not contain the reserved
character $ in the name.

Tuesday, July 8, 2025 27


Collections - Databases
• MongoDB groups collections into databases.
• A single instance of MongoDB can host several
databases, each grouping together zero or
more collections.
• A database has its own permissions, and each
database is stored in separate files on disk

Tuesday, July 8, 2025 28


Collections

Tuesday, July 8, 2025 29


Collections

Tuesday, July 8, 2025 30


Collections

Tuesday, July 8, 2025 31


Collections

Tuesday, July 8, 2025 32


Collections

Tuesday, July 8, 2025 33


MongoDB Installation Steps

Tuesday, July 8, 2025 34


• https://www.mongodb.com/download-center

Tuesday, July 8, 2025 35


Tuesday, July 8, 2025 36
Tuesday, July 8, 2025 37
Tuesday, July 8, 2025 38
Tuesday, July 8, 2025 39
Tuesday, July 8, 2025 40
Tuesday, July 8, 2025 41
Tuesday, July 8, 2025 42
Tuesday, July 8, 2025 43
Tuesday, July 8, 2025 44
s?
5
Question

Tuesday, July 8, 2025 50


Basic concepts of MongoDB
• A document is the basic unit of data for MongoDB and is roughly
equivalent to a row in a relational database management system

• Similarly, a collection can be thought of as a table with a dynamic schema.

• A single instance of MongoDB can host multiple independent databases,


each of which can have its own collections.

• Every document has a special key, "_id", that is unique within a collection.

• MongoDB comes with a simple but powerful JavaScript shell, which is


useful for the administration of MongoDB instances and data
manipulation.

Tuesday, July 8, 2025 51

You might also like