‹ General IT

Databases & SQL

1 test · 10 questions
Browse all 10 questions ›
Your progress

About these Databases & SQL questions

This is a practice topic, not a vendor exam. The questions are for anyone who needs to read and write SQL with confidence: developers preparing for a technical interview, analysts moving past simple SELECT statements, and people studying for cloud database certifications who want the relational basics settled before they learn a managed service. Nothing here is tied to one product. The SQL is standard, and where databases behave differently the question says which behaviour it assumes, using PostgreSQL as the reference.

Most questions show a small table or query and ask what it returns or why it misbehaves. That is how SQL usually comes up in interviews: not "define a join" but "this report is missing rows, what went wrong?" The wrong options are the mistakes people actually make, such as filtering an outer join in the wrong place or expecting NULL to compare like any other value.

What the questions cover

There is one 10-question test so far. It samples these areas:

  • Joins. How a LEFT JOIN keeps unmatched rows, and how a condition in the WHERE clause quietly turns it back into an inner join.
  • Aggregation and grouping. The difference between WHERE and HAVING, and why selecting a column that is neither grouped nor aggregated is an error.
  • NULL semantics. Why COUNT(*) and COUNT(column) give different answers, and how three-valued logic affects comparisons.
  • Keys and constraints. What primary and foreign keys guarantee and what they leave to you.
  • Schema design and normalisation. Spotting a transitive dependency and fixing it to reach third normal form.
  • Transactions and isolation. Phantom reads and the isolation level that prevents them, and why moving money between two accounts needs an atomic transaction.
  • Indexes and performance. Why a B-tree index can't help a LIKE pattern that starts with a wildcard.
  • Window functions. How ROW_NUMBER() and RANK() treat ties differently.

How to use them

  • Before checking an answer, work out the result by hand on the sample rows. If you can't predict the output, you have found the gap.
  • Read the whole explanation, including why each wrong option fails. Several of them describe bugs you will meet in real code.
  • Run the queries yourself. A local PostgreSQL or SQLite database takes minutes to set up, and changing one clause at a time teaches more than rereading the explanation.
  • Pay particular attention to NULL, outer joins and isolation levels. They account for many of the bugs that only show up in production, and interviewers know it.
  • If you are heading for a cloud database certification, come back to the transactions and indexing questions when you study replicas, consistency and query tuning there.

These questions are original, written from public database documentation, chiefly the PostgreSQL manual. They are not taken from any exam or interview question bank.