0% found this document useful (0 votes)
10 views6 pages

Backend (Day 009) DB

The document explains databases as programs for storing and retrieving data, likening them to organized digital filing cabinets. It contrasts relational databases, which use structured tables and SQL for data management, with non-relational databases that offer flexible structures and various data storage methods. Additionally, it discusses MongoDB as a prominent non-relational database, highlighting its schema-less nature, scalability, and the tools available for managing and interacting with it.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views6 pages

Backend (Day 009) DB

The document explains databases as programs for storing and retrieving data, likening them to organized digital filing cabinets. It contrasts relational databases, which use structured tables and SQL for data management, with non-relational databases that offer flexible structures and various data storage methods. Additionally, it discusses MongoDB as a prominent non-relational database, highlighting its schema-less nature, scalability, and the tools available for managing and interacting with it.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Notes

What is a Database? (A program which helps to store and retrieve data)

Imagine a digital filing cabinet: Databases are like super-organized digital


filing cabinets for your computer.

Purpose: They are programs designed to:

Store data: Keep information safe and organized. Think of it like storing
documents in folders within the filing cabinet.

Retrieve data: Quickly find and access the information you need when you
need it. Like easily pulling out a specific folder and document.

Example: Think about your phone contacts app. It uses a database to store all
your contact names, numbers, and other details. When you search for a
contact, the database helps the app quickly retrieve that information.

Relational Databases vs. Non-Relational Databases


Think of these as two different ways to organize your digital filing cabinet.
1. Relational Databases (Like a very structured filing cabinet)

Structure: Data is organized in tables.

Tables are like spreadsheets with rows and columns.

Each row represents a record (like information about one person or


product).

Each column represents a specific attribute (like name, age, or price).

Relationships: Tables are linked together using relationships.

This means information in one table can be connected to information in


another table.

Notes 1
Think of it like linking folders together in your filing cabinet if they are
related.

SQL (Structured Query Language): They use a special language called SQL to
manage and query data.

SQL is like a set of instructions you use to talk to the database.

You use SQL to ask questions like "Show me all customers who live in New
York."

Schema: They have a fixed schema.

This means you need to define the structure of your tables (columns and
data types) before you start storing data.

Like deciding how many columns your spreadsheet will have and what
kind of information will go in each column before you start filling it.

Examples:

MySQL

PostgreSQL

Microsoft SQL Server

Oracle Database

Good for:

Applications where data is highly structured and relationships between


data are important.

Situations where data consistency and accuracy are critical (like financial
transactions).

2. Non-Relational Databases (Like a more flexible filing cabinet)

Structure: More flexible data structures. Data is often stored in:

Documents: (like JSON or XML files) - Think of these as individual files or


documents that can hold different kinds of information.

Key-Value pairs: Like dictionaries where you have a key to find a value.

Graphs: Focus on relationships between data points.

Notes 2
Wide-column stores: Designed for massive amounts of data.

NoSQL (Not Only SQL): Often called NoSQL databases because they don't
primarily use SQL.

They might use different query languages or methods to access data.

Schema-less (or flexible schema): They often have a dynamic or flexible


schema.

You don't need to define the structure of your data strictly beforehand.

Different documents in the same collection can have different fields.

Like being able to put different kinds of documents and folders into your
filing cabinet without having to pre-define everything.

Scalability: Often designed to be easily scalable horizontally.

This means you can easily add more servers to handle more data and
traffic.

Important for applications that grow very quickly.

Examples:

MongoDB (Document Database)

Cassandra (Wide-column store)

Redis (Key-value store)

Neo4j (Graph database)

Good for:

Applications with rapidly changing data or semi-structured data.

Handling large volumes of data and high traffic.

Situations where flexibility and speed of development are important.

Real-time applications, content management, mobile apps, and more.

Key Differences Summarized:

Feature Relational Databases Non-Relational Databases

Notes 3
Data Structure Tables with rows and columns Documents, key-value, graphs, etc.

Schema Fixed schema Flexible/Schema-less

Query Language SQL NoSQL (varies)

Scalability Vertically scalable Horizontally scalable

Flexibility Less flexible More flexible

Use Cases Structured data, consistency Unstructured data, scalability

MongoDB - A Non-Relational Database (Specifically a Document


Database)
Document Database: MongoDB is a type of non-relational database that
stores data in documents.

Think of documents as similar to JSON (JavaScript Object Notation)


objects. They are like structured files.

Documents are grouped together into collections. Think of collections like


folders that hold related documents.

BSON (Binary JSON): MongoDB stores documents in a binary format called


BSON.

BSON is like a more efficient version of JSON that computers can process
faster.

Schema-less (Dynamic Schema): Collections in MongoDB are schema-less.

Documents within the same collection can have different fields.

This gives you a lot of flexibility. You don't have to pre-define the structure
of your data rigidly.

Scalability: MongoDB is designed for horizontal scalability.

Easy to distribute data across multiple servers (called sharding) to handle


large datasets and high traffic.

NoSQL Database: MongoDB is a prominent example of a NoSQL database.

Use Cases:

Content Management Systems (CMS)

Notes 4
Mobile and Web Applications

Real-time Analytics

Internet of Things (IoT) data

E-commerce platforms

MongoDB Community Edition Server


What is it? The free and open-source version of the MongoDB server.

It's the actual program that runs and manages your MongoDB database.

It's like the engine of your MongoDB filing cabinet.

Self-Managed: You need to install and manage the Community Edition server
yourself on your own computer or server.

You are responsible for setting it up, configuring it, and maintaining it.

Features: Provides all the core functionalities of MongoDB.

It's great for learning, development, and even production for many
applications.

Contrast with MongoDB Atlas: There's also MongoDB Atlas, which is a cloud-
based, fully managed database service offered by MongoDB. With Atlas,
MongoDB takes care of server management for you.

MongoDB Compass
What is it? A Graphical User Interface (GUI) tool for MongoDB.

Think of it as a user-friendly application that helps you visually interact


with your MongoDB database.

Purpose: It makes it easier to:

Explore your data: See your databases, collections, and documents in a


visual way.

Query data: Write and execute queries to find specific documents.

Manage your database: Create databases, collections, indexes, and


manage users.

Notes 5
Analyze performance: Get insights into how your database is performing.

User-Friendly: It's much easier to use Compass for many tasks than using the
command-line interface (like the mongo shell).

Analogy: Compass is like a visual dashboard for your MongoDB filing cabinet.
It lets you see what's inside, search for things, and manage everything without
having to use complicated commands.

Free to use: MongoDB Compass is free to download and use with any
MongoDB server, including the Community Edition.

Notes 6

You might also like