SQL_Concepts_Differences
SQL_Concepts_Differences
---
Drawbacks of RDBMS:
1. **Scalability Limitations**:
- **Vertical Scalability:** RDBMS are typically vertically scalable, requiring
more powerful hardware to handle increased load. Scaling horizontally (adding more
servers) is challenging.
- **Large Data Volume:** Managing huge volumes of unstructured data is
inefficient in RDBMS due to the need for predefined schemas and complex joins.
4. **Rigid Schema**:
- **Fixed Schema:** Any changes to the data structure require modifying the
schema, which is time-consuming.
- **Schema Changes Impact:** Frequent structure changes can cause downtime or
performance issues.
5. **Cost of Maintenance**:
- High licensing, hardware, and administrative costs compared to non-relational
(NoSQL) systems.
---
| **Criteria** | **Subquery**
| **Correlated Subquery** |
|---------------------------|------------------------------------------------------
----|--------------------------------------------------------------|
| **Definition** | A subquery is a query within another query that is
executed independently and returns a result set used by the outer query. | A
correlated subquery is a subquery that references columns from the outer query and
is executed once for each row processed by the outer query. |
| **Execution** | Executed only once, regardless of the number of rows
processed by the outer query. | Executed repeatedly for each row of the outer
query. |
| **Dependency** | The subquery is independent of the outer query and
can be executed on its own. | The correlated subquery depends on the outer query
for its execution because it references values from the outer query. |
| **Performance** | Generally faster since the subquery is executed only
once. | Can be slower due to repeated execution for each row in the outer query. |
| **Use Case** | Used when you need to filter data in the outer query
based on an independent query result. | Used when you need to filter data in the
outer query based on a per-row basis from the outer query. |
| **Example** | ```SELECT name FROM Employees WHERE salary > (SELECT
AVG(salary) FROM Employees);``` | ```SELECT name FROM Employees e1 WHERE salary >
(SELECT AVG(salary) FROM Employees e2 WHERE e1.department = e2.department);``` |
| **Scope** | The inner query (subquery) is self-contained and
does not rely on any data from the outer query. | The correlated subquery uses data
from the outer query, making it context-dependent. |