1๏ธโฃ What is a table and a field in SQL?
โฆ Table: Organized data in rows and columns
โฆ Field: A column representing data attribute
2๏ธโฃ Describe the SELECT statement.
โฆ Fetch data from one or more tables
โฆ Use WHERE to filter, ORDER BY to sort
3๏ธโฃ Explain SQL constraints.
โฆ Rules for data integrity: PRIMARY KEY, FOREIGN KEY, UNIQUE, NOT NULL, CHECK
4๏ธโฃ What is normalization?
โฆ Process to reduce data redundancy & improve integrity (1NF, 2NF, 3NFโฆ)
5๏ธโฃ Explain different JOIN types with examples.
โฆ INNER, LEFT, RIGHT, FULL JOIN: Various ways to combine tables based on matching rows
6๏ธโฃ What is a subquery? Give example.
โฆ Query inside another query:
SELECT name FROM employees
WHERE department_id = (SELECT id FROM departments WHERE name='Sales');
7๏ธโฃ How to optimize slow queries?
โฆ Use indexes, avoid SELECT *, simplify joins, reduce nested queries
8๏ธโฃ What are aggregate functions? Examples?
โฆ Perform calculations on sets: SUM(), COUNT(), AVG(), MIN(), MAX()
9๏ธโฃ What is SQL injection? How to prevent it?
โฆ Security risk manipulating queries
โฆ Prevent: parameterized queries, input validation
๐ How to find the Nth highest salary without TOP/LIMIT?
SELECT DISTINCT salary FROM employees e1
WHERE N-1 = (SELECT COUNT(DISTINCT salary) FROM employees e2 WHERE e2.salary > e1.salary);
๐ฅ Double Tap โค๏ธ For More!