Fundamentals
Database vs DBMS
A database does not provide tools to interact with data efficiently, DBMS does.
| Feature | Database (DB) | DBMS (Database Management System) |
|---|---|---|
| Definition | Collection of structured data. | Software to manage and interact with the database. |
| Nature | Passive (just stores data). | Active (manages, controls, secures, and queries data). |
| Content | Only contains raw data. | Contains programs, rules, and tools to handle data. |
| User Interaction | Users cannot directly interact easily. | Provides interface (like SQL) for users/applications. |
| Security | Not provided by database itself. | Provides authentication, authorization, backups. |
| Example | Student Records stored in tables/files. | MySQL, Oracle, PostgreSQL managing those records. |
Types of Databases
Relational Database (RDB)
- Stores data in tables (rows and columns).
- Relationships between tables are established using keys (Primary Key, Foreign Key).
- Managed by Relational Database Management Systems (RDBMS) like MySQL, Oracle, PostgreSQL, SQL Server.
- Uses SQL (Structured Query Language) for queries.
Example:
students
| student_id | name | dept | phone |
|---|---|---|---|
| S101 | Amina | CSE | 01711111111 |
courses
| course_id | course_name | credit |
|---|---|---|
| C201 | Database Sys. | 3 |
- Relationship:
studentsenroll incoursesvia a join table (Enrollment).
NoSQL Database
- “Not Only SQL” – used when data is unstructured or semi-structured (JSON, XML, documents, key-value pairs).
- Designed for scalability, flexibility, and big data.
- Types:
- Document-based (MongoDB, CouchDB)
- Key-Value Store (Redis, DynamoDB)
- Column-based (Cassandra, HBase)
- Graph-based (Neo4j)
Example:
A product entry in JSON format:
{
"product_id": "P101",
"name": "Laptop",
"price": 700,
"reviews": [
{ "user": "Amina", "rating": 5 },
{ "user": "Rahim", "rating": 4 }
]
}
Flexible for data that changes frequently (reviews, social media posts).
Distributed Database
- A single logical database that is spread across multiple locations/servers.
- Can be homogeneous (same DBMS everywhere) or heterogeneous (different DBMS).
- Increases availability, performance, and reliability.
Example: Banking System
- Customer data stored in Dhaka branch server.
- Transaction data stored in Chittagong branch server.
- A central DBMS coordinates queries across all servers.
Ensures high availability & quick access for global organizations.
Cloud Database
- Database that runs on a cloud platform (AWS RDS, Google Cloud SQL, Azure SQL).
- Provides scalability, pay-as-you-go pricing, automatic backup.
- Accessible from anywhere via internet.
Example: Netflix
- Stores millions of user profiles, watch history, and recommendations in cloud databases.
- Scaling is automatic when user demand spikes.
Best for web/mobile apps that need global access.
Object-Oriented Database
- Stores data as objects (similar to object-oriented programming).
- Each object has attributes (data) and methods (functions).
- Example systems: db4o, ObjectDB.
Example: Multimedia Application
- A "Video" object contains:
- Attributes: Title, Duration, Size.
- Methods: play(), pause(), stop().
Great for applications needing complex data types like images, audio, video
Why is Database Design Important?
- Eliminates Data Redundancy
- Ensures Data Integrity & Consistency
- Improves Query Performance
- Supports Scalability
- Enhances Security & Access Control
- Facilitates Maintenance & Updates
- Enables Better Decision-Making