yoklainterview sim

Database Junior Interview Questions

1651 verified Database Junior interview questions — solve with answers, learn from explanations, test yourself in a real simulation.

Try the real simulation →

Sample questions

Backup RecoveryDifficulty 1
What is the primary purpose of taking database backups?
  • aTo speed up read queries by keeping hot rows in an in-memory cache layer
  • bTo spread incoming read traffic evenly across several database servers
  • cTo recover the data after hardware failure, accidental deletion, or corruption
  • dTo enforce referential integrity automatically between related parent and child tables
Explanation:Backups exist so you can restore lost or damaged data after failures — disk crashes, human mistakes, software bugs, ransomware. Caching (a) and load distribution (b) are performance concerns, and integrity constraints (d) are enforced by the schema, not by backups.
Backup RecoveryDifficulty 2
A team runs a primary database with a synchronous replica and argues: 'We don't need backups — the replica is our backup.' Why is this reasoning dangerous?
  • aA replica only serves reads, so you can never copy the lost data back out of it
  • bAn accidental DELETE or corruption is replicated to the standby too, destroying both copies
  • cReplication lags so far behind the primary that the standby never holds usable recent data
  • dA replica keeps its data in a compressed on-disk format that cannot be turned back into a database
Explanation:Replication copies changes faithfully — including destructive ones. A bad DELETE, an UPDATE with the wrong WHERE, or corruption propagates to the replica in seconds, so both copies are lost together. A backup is a point-in-time copy you can go back to; a replica is not. Reads (a), lag (c), and storage format (d) are not the core reason.
Backup RecoveryDifficulty 2
How do incremental and differential backups differ?
  • aThey are simply two different names for one and the same backup technique
  • bAn incremental copies everything since the last full backup; a differential copies only the very newest changes
  • cAn incremental may only follow a full backup, while a differential may only follow another differential
  • dAn incremental copies changes since the last backup of any kind; a differential, since the last full backup
Explanation:An incremental backup captures only what changed since the previous backup (full or incremental), so a restore must replay the full plus every incremental in order. A differential captures everything changed since the last full backup, so a restore needs only the full plus the latest differential. Option (b) swaps the two definitions.
Backup RecoveryDifficulty 2
Compared with taking a fresh full backup every night, a 'weekly full + nightly incremental' strategy mainly trades...
  • aFaster, smaller nightly backups for a slower restore that replays the full plus each incremental
  • bSlower nightly backups for an absolute guarantee that no committed data can ever be lost
  • cExtra storage consumption for the ability to recover the database to any individual second
  • dA simpler setup for the database engine automatically copying each backup to an off-site location
Explanation:Incrementals write far less each night (faster, smaller), but recovery must start from the last full and replay every incremental in sequence — more steps, more time, and more chance that one link is missing. It does not guarantee zero loss (b) or second-level recovery (c); those are separate concerns.
Backup RecoveryDifficulty 2
pg_dump mydb > mydb.sql

This command produces a logical backup. How does a logical backup differ from a physical backup?
  • aA logical backup copies the raw on-disk files and blocks; a physical backup exports SQL statements
  • bA logical backup exports data as SQL or a portable format; a physical backup copies the raw files
  • cA logical backup can only capture the schema definition and never the actual rows of table data
  • dA physical backup can run only while the database currently has zero open client connections
Explanation:A logical backup (like pg_dump / mysqldump) reconstructs data as portable statements, so it can restore into a different version or platform. A physical backup copies the raw data files and blocks — faster for huge databases but tied to the same engine layout. Option (a) reverses the two.
Backup RecoveryDifficulty 3
You must move a database to a server running a different major version on a different CPU architecture.
# option A (physical): copy the raw data files
# option B (logical): pg_dump olddb | psql -h newhost newdb

Which is generally the safer choice, and why?
  • aThe physical file copy, since raw data files are always compatible across versions and CPU architectures
  • bNeither works — data moves between servers only by configuring streaming replication first
  • cEither is equivalent here, because the backup format has no bearing on cross-platform portability
  • dThe logical SQL dump, since it is portable and can be reloaded into a different version or platform
Explanation:Physical backups copy engine-internal file formats that can differ between major versions and architectures, so restoring them elsewhere is fragile. A logical dump is engine-readable SQL/data, which is exactly why it is the standard tool for cross-version and cross-platform moves. Replication (b) keeps copies in sync but is not a prerequisite for migration.

Test yourself against the 2475-question Database bank.

Start interview