SQL (Structured Query Language) is a domain-specific language used for managing, querying, and manipulating data stored in relational database management systems (RDBMS), which organize data into tables with rows and columns linked by foreign keys. SQL provides four main classes of operations — Data Query Language (SELECT), Data Manipulation Language (INSERT, UPDATE, DELETE), Data Definition Language (CREATE, ALTER, DROP), and Data Control Language (GRANT, REVOKE). It remains the most widely used database language in industry, underpinning systems from small web applications to enterprise data warehouses handling petabytes of data.
Problem
A database has an "orders" table with columns: order_id, customer_id, amount, status. Write a SQL query to find the total order amount per customer for all "completed" orders, showing only customers whose total exceeds ₹10,000, sorted by total descending.
Solution
Step 1 — Filter rows: Use WHERE status = 'completed' to restrict to completed orders. Step 2 — Group by customer: Use GROUP BY customer_id to aggregate per customer. Step 3 — Aggregate: Use SUM(amount) to get total per group. Step 4 — Filter groups: Use HAVING SUM(amount) > 10000 (HAVING filters after aggregation, WHERE filters before). Step 5 — Sort: Use ORDER BY total_amount DESC. Final Query: SELECT customer_id, SUM(amount) AS total_amount FROM orders WHERE status = 'completed' GROUP BY customer_id HAVING SUM(amount) > 10000 ORDER BY total_amount DESC;
Answer
Returns a result set listing customer_id and their total_amount for completed orders exceeding ₹10,000, sorted from highest to lowest total.
| Category | Full Name | Commands | Purpose |
|---|---|---|---|
| DQL | Data Query Language | SELECT | Retrieve data from tables |
| DML | Data Manipulation Language | INSERT, UPDATE, DELETE | Modify table data |
| DDL | Data Definition Language | CREATE, ALTER, DROP | Define table structures |
| DCL | Data Control Language | GRANT, REVOKE | Manage user permissions |
| TCL | Transaction Control Language | COMMIT, ROLLBACK | Control transactions |
Wikimedia Commons, CC BY-SA
NoSQL databases are non-relational data storage systems that provide flexible schemas and horizontal scalability by abandoning the traditional table-row-column model of SQL databases in favour of document, key-value, column-family, or graph data models. They were designed to address the limitations of relational databases when handling massive volumes of unstructured or semi-structured data, high write throughput, and distributed deployments across commodity hardware. Popular NoSQL databases like MongoDB, Redis, Cassandra, and Neo4j are widely used in web-scale applications, real-time analytics, caching layers, and social network graphs.
A distributed system is a collection of independent computers that appear to users as a single coherent system, coordinating their actions by passing messages over a network to achieve a common computational goal. Key challenges in distributed systems include handling partial failures (where some nodes crash but others continue), achieving consensus on shared state, ensuring data consistency across replicas, and tolerating network partitions. Modern distributed systems underpin the internet's most critical infrastructure — from Google's search index and Amazon's shopping cart to financial clearing systems and distributed databases.
REST (Representational State Transfer) API is an architectural style for designing networked applications that uses HTTP requests to perform CRUD operations on resources identified by URLs. It enforces stateless communication, meaning each request from a client must contain all information needed to process it, with no session state stored on the server. REST APIs are the backbone of modern web services, enabling interoperability between frontend clients, mobile apps, and backend services.
SQL was developed at IBM by Donald D. Chamberlin and Raymond F. Boyce in the early 1970s, originally called SEQUEL (Structured English Query Language). It was renamed SQL to avoid trademark conflict. The language is based on Edgar F. Codd's 1970 relational model paper.