Questions every good Database/SQL developer should be able to answer [closed]
I was going through Questions every good .Net developer should be able to answer and was highly impressed with the content and approach of this question and so in the same spirit, I am asking this question for Database/SQL Developer.
What questions do you think should a good Database/SQL programmer be able to respond to?
The different types of JOINs:
- INNER JOIN
- LEFT and RIGHT OUTER JOIN
- FULL JOIN
- CROSS JOIN
See Jeff Atwood's Visual Explanation of JOINs
- What is a key? A candidate key? A primary key? An alternate key? A foreign key?
What is an index and how does it help your database?
What are the data types available and when to use which ones?
A reprint of my answer here, as general guidelines for topics.
Basics
-
SELECT
ing columns from a table - Aggregates Part 1:
COUNT
,SUM
,MAX
/MIN
- Aggregates Part 2:
DISTINCT
,GROUP BY
,HAVING
Intermediate
-
JOIN
s, ANSI-89 and ANSI-92 syntax -
UNION
vsUNION ALL
-
NULL
handling:COALESCE
& Native NULL handling - Subqueries:
IN
,EXISTS
, and inline views - Subqueries: Correlated
-
WITH
syntax: Subquery Factoring/CTE - Views
Advanced Topics
- Functions, Stored Procedures, Packages
- Pivoting data: CASE & PIVOT syntax
- Hierarchical Queries
- Cursors: Implicit and Explicit
- Triggers
- Dynamic SQL
- Materialized Views
- Query Optimization: Indexes
- Query Optimization: Explain Plans
- Query Optimization: Profiling
- Data Modelling: Normal Forms, 1 through 3
- Data Modelling: Primary & Foreign Keys
- Data Modelling: Table Constraints
- Data Modelling: Link/Corrollary Tables
- Full Text Searching
- XML
- Isolation Levels
- Entity Relationship Diagrams (ERDs), Logical and Physical
- Transactions:
COMMIT
,ROLLBACK
, Error Handling
Here are a few:
- What is normalization and why is it important?
- What are some situations where you would de-normalize data?
- What is a transaction and why is it important?
- What is referential integrity and why is it important?
- What steps would to take to investigate reports of slow database performance?
What is sql injection and how do you prevent it?
What is a cursor and when would you use it (or not) and why?
I've placed this answer because Erwin Smout posted a answer that was so wrong it highlighted that there is probably a need to specifically guard against it.
Erwin suggested:
"Why should every SELECT always include DISTINCT ?"
A more appropriate question would be: If someone were to make the claim that: "every SELECT always include DISTINCT"; how would you comment on the claim?
If a candidate is unable to shoot the claim down in flames they either:
- Don't understand the problem with the claim.
- Lack in critical thinking skills.
- Lack in ability to communicate technical issues.
For the record
- Suppose your query is correct, and does not return any duplicates, then including DISTINCT simply forces the RDBMS to check your result (zero benefit, and a lot of additional processing).
- Suppose your query is incorrect, and does return duplicates, then including DISTINCT simply hides the problem (again with additional processing). It would be better to spot the problem and fix your query... it'll run faster that way.