A database is an organised collection of data that can be easily accessed, managed, and updated. It allows for storing information systematically to ensure efficient retrieval, modification, and manipulation.
| Aspect | Relational Database (RDBMS) | Non-Relational Database (NoSQL) |
|---|---|---|
| Structure | Data is stored in structured tables with rows and columns. | Data is stored in flexible formats like JSON, key-value pairs, documents, or graphs. |
| Schema | Follows a fixed schema; data must conform to predefined tables. | Schema-less or dynamic schema; data structure can vary. |
| Query Language | Uses SQL (Structured Query Language) for querying data. | Query languages vary (e.g., MongoDB Query Language, CQL for Cassandra). |
| Scalability | Scales vertically (by upgrading hardware). | Scales horizontally (by adding more servers). |
| Best for | Complex relationships and structured data (e.g., banking, ERP). | Large volumes of unstructured or semi-structured data (e.g., social media, IoT). |
| Flexibility | Less flexible; data relationships must be defined upfront. | Highly flexible; allows storage of different types of data. |
| Examples | MySQL, PostgreSQL, Oracle Database, Microsoft SQL Server. | MongoDB, Cassandra, DynamoDB, Neo4j. |
| Performance | Best for transactional operations (ACID-compliant). | Optimized for fast reads/writes and handling large datasets. |
| Data Relationships | Enforces strong relationships via keys and constraints. | Relationships are typically handled at the application level. |
| Use Cases | Financial systems, inventory management, CRM systems. | Real-time analytics, content management, big data applications. |
| Level | Source | Difficulty Level |
|---|---|---|
| 1 | Leetcode | Easy & Moderate |
| 2 | Hackerank (Optional) | Easy, Moderate & Difficult |
| 3 | DataLemur | Interview Based |
https://datalemur.com/sql-tutorial/best-practices-for-writing-sql-queries