Backend. Everything recorded here becomes a permanent entry in their history.
Ask the prepared questions and mark each answer. The score sets the grade.
What is the difference between a primary key and a foreign key?
A primary key uniquely identifies a row in its own table (unique, not null, one per table). A foreign key is a column that references the primary key of another table, so the database enforces that the referenced row exists.
Explain one-to-many and many-to-many relationships, and how each is stored.
One-to-many: the "many" side holds a foreign key to the "one" side (an order has a customer_id). Many-to-many needs a join table holding two foreign keys (e.g. student_course(student_id, course_id)).
customer_id
student_course(student_id, course_id)
What does NULL mean in SQL, and why does `WHERE col = NULL` not work?
NULL means "unknown / no value", not zero or empty string. Any comparison with NULL yields unknown, so = NULL never matches. Use IS NULL / IS NOT NULL.
= NULL
IS NULL
IS NOT NULL
What is the difference between INNER JOIN and LEFT JOIN? When would you use a LEFT JOIN?
INNER JOIN returns only rows that match on both sides. LEFT JOIN returns every row from the left table, with NULLs where the right side has no match. Use it to keep rows without a match, e.g. customers with no orders (WHERE o.id IS NULL).
WHERE o.id IS NULL
What is the difference between WHERE and HAVING?
WHERE filters rows before grouping; HAVING filters groups after GROUP BY and can use aggregates, e.g. HAVING COUNT(*) > 5.
WHERE
HAVING
GROUP BY
HAVING COUNT(*) > 5
What is an index, what does it cost, and when should you add one?
An index is a separate structure (usually a B-tree) that lets the database find rows without scanning the table. It speeds up reads on filtered/joined/sorted columns but costs disk space and slows every insert/update/delete. Add one for frequent, selective queries — confirmed with the query plan.
What is a transaction, and what does ACID stand for?
A transaction groups statements so they succeed or fail together. Atomicity (all or nothing), Consistency (constraints hold), Isolation (concurrent transactions do not see each other’s partial work), Durability (committed data survives a crash).
Explain transaction isolation levels and one anomaly that READ COMMITTED allows.
Read Uncommitted, Read Committed, Repeatable Read, Serializable — each prevents more anomalies at more cost. READ COMMITTED allows non-repeatable reads (a row changes between two reads in one transaction) and phantoms (new rows appear in a repeated range query).
A report query became slow in production. How do you investigate and fix it?
Reproduce with the real parameters, run EXPLAIN ANALYZE, look for sequential scans, bad row estimates, and expensive sorts/joins. Fixes: a suitable (possibly composite) index, rewriting the query, updating statistics, pagination, or pre-aggregating. Measure before and after.
EXPLAIN ANALYZE
How do you run a schema migration on a large live table without downtime?
Make changes backward compatible in steps (expand → migrate → contract): add nullable column, deploy code that writes both, backfill in batches, then add constraints and remove the old column. Avoid long table locks (e.g. CREATE INDEX CONCURRENTLY), and have a rollback plan and a backup.
CREATE INDEX CONCURRENTLY
What are the common HTTP methods and what is each used for in a REST API?
GET read, POST create, PUT replace, PATCH partial update, DELETE remove. GET must not change state.
GET
POST
PUT
PATCH
DELETE
What do the status code families mean? Give an example of each: 2xx, 4xx, 5xx.
2xx success (200 OK, 201 Created, 204 No Content); 4xx client error (400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found, 422); 5xx server error (500, 503).
200 OK
201 Created
204 No Content
400 Bad Request
401 Unauthorized
403 Forbidden
404 Not Found
422
500
503
What is the difference between authentication and authorization?
Authentication establishes who you are (login, token). Authorization decides what you are allowed to do (roles, ownership checks). A 401 means not authenticated; a 403 means authenticated but not allowed.
What does idempotent mean? Which HTTP methods are idempotent?
Repeating the same request has the same effect as sending it once. GET, PUT, DELETE (and HEAD, OPTIONS) are idempotent; POST is not. Matters for safe retries — POST can be made safe with an idempotency key.
Where should input validation happen, and what should the API return for invalid input?
Always on the server at the boundary, even if the client validates too. Return 400 or 422 with a consistent error body that says which field failed and why — never a 500 or a stack trace.
400
How does token-based authentication with a JWT work, and where are its weaknesses?
The server signs a token with claims (user id, expiry); the client sends it in the Authorization: Bearer header and the server verifies the signature without a session lookup. Weaknesses: hard to revoke before expiry, so keep access tokens short-lived with refresh tokens; never store secrets in the payload; store securely on the client.
Authorization: Bearer
Compare offset pagination with cursor pagination.
Offset (?page=3&limit=20) is simple and allows jumping to a page, but gets slow on large offsets and skips/duplicates rows when data changes. Cursor (?after=<last id>) is fast and stable for feeds, but cannot jump to an arbitrary page. Both need a stable sort order.
?page=3&limit=20
?after=<last id>
How would you ship a breaking change to an API that mobile apps already use?
Never break the old contract in place: version it (/v2 or a header), or make the change additive. Run both versions, monitor usage of the old one, communicate a deprecation timeline, and remove it only when old app versions are gone — mobile clients update slowly.
/v2
How do you protect an API against abuse or traffic spikes?
Rate limiting per user/key/IP (token bucket or sliding window) with 429 and Retry-After; request size limits; timeouts; caching; queueing slow work; autoscaling; and monitoring/alerting to spot abuse.
429
Retry-After
A request is slow only sometimes in production. How do you find the cause?
Use logs with correlation/request IDs and metrics (p95/p99 latency) to find which requests and when. Trace the request through its dependencies (DB, external APIs). Common causes: lock contention, N+1 queries, cold caches, slow third parties, resource exhaustion. Reproduce, fix, then confirm with the metrics.
A 90–100B 80–89C 70–79D 60–69E below 60· Basic 1pt, Intermediate 2pt, Advanced 3pt
Currently verified D · they self-assessed D
Leave a dimension blank if this assessment did not cover it — a blank is more honest than a guess, and blanks show as gaps rather than zeros.
The grade rests on the Q&A alone. Cite a practical task, code review or project work as well to raise confidence.
Using AI is not a negative. What matters is whether they understand and control the solution.
Not assessed yet — leave it blank if this review did not cover it.
Thin or single-source evidence — treat this level as provisional.