What this topic covers
33 subtopics- NULL3
- Architecture2
- Data types2
- Dates2
- DBMS basics2
- LIMIT2
- Logical operators2
- Sorting NULL2
- SQL command families2
- String functions2
- Three-valued logic2
- Arithmetic1
Show all 33 subtopics
- BETWEEN1
- CASE1
- Choosing a database1
- COALESCE1
- Collations1
- Data models1
- DELETE1
- DISTINCT1
- Distributed databases1
- DML vs DDL1
- IN1
- INSERT … SELECT1
- LIKE1
- ORDER BY1
- Relational model1
- Security1
- Stored programs1
- UPDATE1
- Views1
- WHERE and ORDER BY1
- Workloads1
- Beginner 15
- Intermediate 15
- Advanced 15
About this topic
Start here. This topic covers what a DBMS adds over plain files, the families of SQL commands, and the everyday clauses – WHERE, ORDER BY, LIKE, BETWEEN, IN – that every later topic builds on. Pay special attention to NULL: it means "unknown", comparisons with it are neither true nor false, and that single rule explains most beginner surprises.
Free preview
Sample questions
Try each one first, then open the answer for the explanation and why the other options are wrong.
Which is a key advantage of a DBMS over storing data in plain files?
Show answer and explanation
Explanation
A DBMS reduces redundancy, enforces constraints, lets many users work safely at once, recovers from crashes and answers ad-hoc queries – all of which file-based systems leave to each application.
Why the other options are wrong
- AA DBMS runs on an operating system.
- BData still needs storage.
- DDeletion is a normal operation.
Keyboard's stock is NULL. What does this return?
| id | name | category | price | stock | launched |
|---|---|---|---|---|---|
| 1 | Pen | Stationery | 20.00 | 500 | 2024-01-10 |
| 2 | Notebook | Stationery | 60.00 | 120 | 2024-03-05 |
| 3 | Backpack | Bags | 899.00 | 40 | 2025-06-01 |
| 4 | Laptop Sleeve | Bags | 650.00 | 0 | 2025-08-15 |
| 5 | Mouse | Electronics | 499.00 | 75 | 2025-02-20 |
| 6 | Keyboard | Electronics | 1299.00 | NULL | 2026-01-12 |
| 7 | Marker | Stationery | 35.00 | 300 | NULL |
SELECT
(SELECT COUNT(*) FROM products WHERE stock = NULL) AS with_equals,
(SELECT COUNT(*) FROM products WHERE stock IS NULL) AS with_is;
| with_equals | with_is |
|---|---|
| 1 | 1 |
| with_equals | with_is |
|---|---|
| 0 | 0 |
| with_equals | with_is |
|---|---|
| 0 | 1 |
| with_equals | with_is |
|---|---|
| 1 | 0 |
Show answer and explanation
Explanation
stock = NULL is UNKNOWN for every row, never true, so it matches nothing. Test for NULL with IS NULL / IS NOT NULL.
Why the other options are wrong
- A= NULL never matches.
- BIS NULL finds Keyboard.
- DThis reverses the two.
The author meant "bags or electronics, costing over 1000". What does the query actually return?
| id | name | category | price | stock | launched |
|---|---|---|---|---|---|
| 1 | Pen | Stationery | 20.00 | 500 | 2024-01-10 |
| 2 | Notebook | Stationery | 60.00 | 120 | 2024-03-05 |
| 3 | Backpack | Bags | 899.00 | 40 | 2025-06-01 |
| 4 | Laptop Sleeve | Bags | 650.00 | 0 | 2025-08-15 |
| 5 | Mouse | Electronics | 499.00 | 75 | 2025-02-20 |
| 6 | Keyboard | Electronics | 1299.00 | NULL | 2026-01-12 |
| 7 | Marker | Stationery | 35.00 | 300 | NULL |
SELECT COUNT(*) AS n FROM products
WHERE category = 'Bags' OR category = 'Electronics' AND price > 1000;
| n |
|---|
| 0 |
| n |
|---|
| 4 |
| n |
|---|
| 1 |
| n |
|---|
| 3 |
Show answer and explanation
Explanation
AND binds tighter than OR, so it means Bags OR (Electronics AND price > 1000): both bags plus Keyboard = 3. With parentheses around the OR it would be 1. Always bracket mixed AND/OR.
Why the other options are wrong
- ABags match unconditionally.
- BMouse fails the price test.
- CThat is the intended result, which needs parentheses.
How many products does NOT(…) return?
| id | name | category | price | stock | launched |
|---|---|---|---|---|---|
| 1 | Pen | Stationery | 20.00 | 500 | 2024-01-10 |
| 2 | Notebook | Stationery | 60.00 | 120 | 2024-03-05 |
| 3 | Backpack | Bags | 899.00 | 40 | 2025-06-01 |
| 4 | Laptop Sleeve | Bags | 650.00 | 0 | 2025-08-15 |
| 5 | Mouse | Electronics | 499.00 | 75 | 2025-02-20 |
| 6 | Keyboard | Electronics | 1299.00 | NULL | 2026-01-12 |
| 7 | Marker | Stationery | 35.00 | 300 | NULL |
SELECT COUNT(*) AS n FROM products WHERE NOT (stock > 100);
| n |
|---|
| 4 |
| n |
|---|
| 3 |
| n |
|---|
| 2 |
| n |
|---|
| 7 |
Show answer and explanation
Explanation
For Keyboard, NULL > 100 is UNKNOWN and NOT UNKNOWN is still UNKNOWN, so the row is excluded. Matching rows: 40, 0 and 75 – three.
Why the other options are wrong
- ANOT does not turn UNKNOWN into TRUE.
- CLaptop Sleeve (0) matches.
- DThree products have more than 100.