Introduction to Databases
—--------------------------------
1. What is a Database?
Definition: A database is a structured collection of data that allows for efficient storage, retrieval,
and manipulation.
Examples: Employee records, customer profiles, product inventories.
Key Components:
Data: Raw facts stored in tables.
Database Management System (DBMS): Software used to interact with the database.
Database Application: Programs that access the database for user needs.
2. Types of Databases
Relational Databases:
Use tables (rows and columns) to store data.
Example: MySQL, PostgreSQL, SQLite.
NoSQL Databases:
Designed for unstructured or semi-structured data.
● Example: MongoDB, Cassandra.
Object-Oriented Databases:
Store data as objects, as used in Object-Oriented Programming (OOP).
Example: db4o, ObjectDB.
Distributed Databases:
Data is distributed across multiple locations.
Example: Apache Cassandra.
Cloud Databases:
Hosted on cloud platforms.
Example: Amazon RDS, Google Cloud Spanner.
3. Components of a DBMS
Data Definition Language (DDL): Used to define database schema (e.g., CREATE, ALTER,
DROP).
Data Manipulation Language (DML): For data retrieval and manipulation (e.g., SELECT,
INSERT, UPDATE, DELETE).
Query Language: Most DBMSs use SQL (Structured Query Language) to query databases.
Storage Management: Handles physical storage of data.
Transaction Management: Ensures data integrity through ACID properties.
4. Relational Model
Key Terms:
Entity: Object or item represented in the database (e.g., a person, a product).
Attribute: Characteristics or properties of an entity (e.g., name, price).
Tuple: A row in a table, representing an instance of an entity.
Primary Key: A unique identifier for a tuple.
Foreign Key: An attribute in one table that links to the primary key in another table.
5. Database Design
Normalization:
Process of organizing data to minimize redundancy and improve integrity.
Normal Forms: 1NF, 2NF, 3NF, BCNF, etc.
Entity-Relationship (ER) Model:
Visual representation of data and relationships using ER diagrams.
Components: Entities, Attributes, Relationships.
6. SQL Basics
DDL Commands:
CREATE TABLE: Create a new table.
ALTER TABLE: Modify existing table structure.
DROP TABLE: Delete a table.
DML Commands:
SELECT: Retrieve data.
INSERT: Add data.
UPDATE: Modify data.
DELETE: Remove data.
Constraints:
NOT NULL, UNIQUE, PRIMARY KEY, FOREIGN KEY, CHECK.
7. Transactions and ACID Properties
Transaction: A sequence of operations performed as a single logical unit.
ACID Properties:
Atomicity: Ensures all operations are completed or none are.
Consistency: Ensures database remains in a valid state.
Isolation: Ensures transactions do not interfere with each other.
Durability: Ensures results persist even after system failures.
8. Indexing and Optimization
Index: A data structure that improves the speed of data retrieval.
Types of Indexing:
Single-column index, composite index, unique index.
Query Optimization: Techniques used by DBMS to execute queries efficiently.
9. Backup and Recovery
Backup:
Periodic copying of database files to prevent data loss.
Types: Full, incremental, differential.
Recovery:
Techniques to restore database to a consistent state after failure.
10. Emerging Trends in Databases
Big Data: Managing and analyzing large datasets.
Data Warehousing: Aggregating data for analytical processing.
Machine Learning Integration: Using databases to support AI/ML workflows.
Blockchain Databases: Decentralized, immutable data storage.
—-----------------------------------------