1. Introduction to Databases
A database is an organized collection of data that can be accessed, managed, and
updated. In web development, databases are used to store and retrieve data for
web applications. Databases can be classified into two main categories: Relational
Databases and NoSQL Databases. Each type has its own use cases, advantages,
and characteristics.
2. Types of Databases
1. Relational Databases (RDBMS)
Relational databases store data in tables (rows and columns) and maintain
relationships between tables. They use Structured Query Language (SQL)
for managing and querying the data.
Features:
o Data is stored in tables with predefined schemas (tables, rows, and
columns).
o Supports ACID (Atomicity, Consistency, Isolation, Durability)
properties to ensure data reliability and integrity.
o Relationships between tables are established via primary and foreign
keys.
Examples:
o MySQL: One of the most popular relational databases, widely used
for web applications.
o PostgreSQL: An advanced open-source relational database system
known for supporting complex queries and large datasets.
o Oracle: A widely used enterprise-level RDBMS.
o SQLite: A serverless, self-contained SQL database engine.
, When to use:
o Applications requiring structured data with complex relationships
(e.g., financial applications, e-commerce).
2. NoSQL Databases
NoSQL databases are designed to handle unstructured or semi-structured
data, offering flexibility in terms of data models (key-value, document,
graph, or column-based).
Features:
o Does not use the traditional table-based structure.
o Can store large volumes of unstructured data.
o Highly scalable and flexible.
Examples:
o MongoDB: A document-oriented NoSQL database that stores data in
JSON-like BSON (Binary JSON) format.
o Cassandra: A distributed column-based NoSQL database used for
handling large-scale data across multiple nodes.
o Redis: A fast, in-memory key-value store used for caching and real-
time data processing.
o CouchDB: A document-oriented NoSQL database known for its ease
of use and flexible schema.
When to use:
o Applications that require scalability and flexibility with unstructured
data (e.g., social media platforms, big data applications).
3. SQL vs. NoSQL Databases
Feature SQL (Relational) NoSQL (Non-Relational)
Data Tables (Rows & Columns) Documents, Key-Value pairs,
Structure Graphs, etc.
Schema Fixed, predefined schema Flexible schema, can be dynamic
Data ACID-compliant (Atomicity, BASE (Basically Available, Soft
Integrity Consistency, Isolation, state, Eventually consistent)
Durability)
Scalability Vertical scaling (upgrading Horizontal scaling (adding more