HTHyperTransformer AI

Study cards › Databases

DatabasesInterview questions and answers

← Topics1 / 100
1 / 100 viewed
Question

What is a JOIN?

Answer

A JOIN combines rows from two or more tables based on a related column. Types: INNER (only matches), LEFT (all rows from left, NULL where no match on right), RIGHT (mirror), FULL OUTER (everything from both sides), and CROSS (every combination). The right join is foundational to relational thinking.

Question

INNER JOIN vs LEFT JOIN?

Answer

INNER JOIN keeps only rows that have a match on both sides — like an intersection. LEFT JOIN keeps every row from the left table, filling NULL for missing matches on the right — useful when you want a list with optional related data (e.g. users and their last order, where some users have no orders).

Question

What is a database index?

Answer

An index is a separate data structure (usually a B-tree) that speeds up lookups by key. It's like the index at the back of a book — instead of scanning every page, you jump straight to where you need. Indexes speed reads but slightly slow writes (the index also needs updating).

Question

What is a composite index?

Answer

A composite index covers multiple columns in a specific order, e.g. (user_id, created_at). The order matters: queries that filter on user_id can use the index; ones filtering only on created_at can't. Always lead with the most selective column you query equality on.

Question

What is a covering index?

Answer

A covering index contains every column a query needs, so the database can answer the query from the index alone without touching the table itself. Massive speedup for hot read paths. In Postgres, use INCLUDE to add 'payload' columns to an index without making it part of the key.

95 more Databases cards

Sign in with Google to study the whole deck, flag tricky answers and track your progress.

Continue with Google

More topics: React & Frontend JavaScript & TypeScript Backend Engineering System Design AI & Agentic AI DevOps & Cloud Security Testing DSA Coding Problems (Python)