Database Administration Interview Questions and Answer Cues

Database administration interviews test how you protect correct data while keeping a service usable. Explain transactions, constraints, isolation, replication, permissions and query evidence with the database engine clearly named. The worked case below distinguishes a committed update from a stale read on an asynchronous standby. It also examines two statements in one PostgreSQL transaction.

Aug 13, 2024 - 12:06
Updated: 
103.2k

Data Analytics & Data Science in AI & Data · Interview preparation

Database Administration Interview Questions and Answer Cues

Quick answer: Database administration interviews test how you protect correct data while keeping a service usable. Explain transactions, constraints, isolation, replication, permissions and query evidence with the database engine clearly named. The worked case below distinguishes a committed update from a stale read on an asynchronous standby. It also examines two statements in one PostgreSQL transaction. These supplied timelines let you practise a precise answer without changing a database or treating every inconsistency as corruption.

Key takeaways

  • Name the engine and isolation level before predicting concurrent reads.
  • Separate transaction consistency from replica freshness.
  • Use constraints for the invariants they can actually enforce.
  • Review inherited and assumed roles when assessing access.
  • Investigate query plans and waits before recommending an index or retry.

Table of Contents

What does a DBA need to protect?

A DBA helps keep database data correct, accessible to authorised workloads and recoverable when failures occur. The role includes access control, performance investigation, change planning and verification of protection mechanisms. The exact responsibility split changes for managed services, but the organisation still owns its data requirements.

An interviewer might ask whether a successful backup job proves recoverability. It proves that the job reported success; restoration and application validation provide different evidence. Establish the required recovery point and usable service outcome before judging the protection design.

In a transaction question, separate atomicity, consistency, isolation and durability. ACID consistency concerns preserving declared rules and valid state through transactions. It is not a synonym for every replica always returning the newest value immediately after a commit.

How do keys and constraints protect data?

A primary key identifies a row and disallows null key values. A foreign key enforces a relationship to referenced rows according to its definition. Unique, not-null and check constraints address other specific rules. The PostgreSQL constraint manual explains their PostgreSQL semantics.

Suppose an inventory database requires a unique supplier reference within each supplier account. A uniqueness rule on the pair can represent that requirement; a global uniqueness rule on the reference alone would reject valid records from different accounts. Ask which columns actually define identity.

Normalisation can reduce duplicated facts and update anomalies. Denormalisation deliberately introduces duplication for a defined access need, which also creates maintenance obligations. Avoid saying either technique is always faster. Explain how changes to the source fact reach every stored representation and how correctness is tested.

Can two reads in one transaction return different committed values?

In PostgreSQL Read Committed, an ordinary SELECT takes its snapshot at the start of that statement. Two successive statements can therefore see different committed values. The PostgreSQL transaction isolation manual documents this behaviour and the stronger guarantees and retry requirements of other isolation levels.

Use this supplied timeline: session A reads stock 10. Session B commits stock 8. Session A then performs a second ordinary read in the same Read Committed transaction and sees 8. That result is compatible with the isolation level; it does not establish a dirty read.

Ask what the application needs to preserve. Choosing a stronger level can change concurrency behaviour and may require retrying an entire transaction. It does not remove the need for correct constraints or a plan for side effects outside the transaction.

Supplied eventRead Committed interpretation
A reads stock 10Snapshot belongs to the first statement
B commits stock 8A later statement can observe that committed change
A reads stock 8Nonrepeatable read is permitted here
A needs one stable analysis viewReview the required isolation and transaction design

Why might a read replica return an older value after commit?

The PostgreSQL standby server manual explains that PostgreSQL streaming replication is asynchronous by default. A commit on the primary and visibility on a standby are distinct events. A lagging standby can return an earlier committed state.

In the second supplied case, an order update commits at 10:00:00 on the primary. A read from the standby at 10:00:01 still shows the previous status because that update has not yet been replayed. Do not conclude that the primary lost the commit solely from that read.

Establish the connection target, transaction context and replication progress. If the workflow requires an immediate read of its own update, its read-routing and consistency design must support that requirement. A synchronous configuration also needs precise interpretation of what acknowledgement waits for; receipt and replay are not interchangeable promises.

Does membership in a database role mean every privilege is active?

Role membership can provide a path to privileges, but the active role and membership options affect how they are used. The PostgreSQL role membership manual explains PostgreSQL INHERIT and SET behaviour. Inspect the actual chain instead of treating membership as an unconditional grant of every capability.

For example, a report user may have direct read access and a separate maintenance membership that is not automatically inherited. Explain whether the session can assume that role and which object privileges it would then use. Special role attributes also have their own rules.

Keep application permissions narrow. A query performance investigation does not automatically justify granting schema ownership or superuser access. Ask for the operation needed, its approved scope and an account of how access will be reviewed afterward.

Would you always add an index to fix a slow query?

No. Compare the query, execution plan, row estimates, waits and workload first. The PostgreSQL index introduction explains how indexes can accelerate access while adding maintenance overhead. A scan can be reasonable when a query needs much of the table.

The PostgreSQL EXPLAIN manual distinguishes the estimated plan from EXPLAIN ANALYZE, which executes the statement. Its name should not be mistaken for a harmless metadata-only operation, especially for statements that modify data.

In an interview, describe a bounded test using representative data under permission. Compare the relevant latency, resource use and write overhead before recommending the index. A faster isolated query can still be an unsuitable change if it substantially harms the application's write path or creates unacceptable maintenance cost.

How do you distinguish blocking, deadlock and a retryable failure?

Blocking means an operation waits for a conflicting lock. A deadlock involves a cycle of waiting transactions. The PostgreSQL explicit locking manual describes PostgreSQL deadlock detection, which aborts one participant rather than promising which transaction will win.

Request a time-aligned view of waiting and holding transactions before declaring the cause. Long transactions can retain locks while application code waits for an unrelated external operation. Retrying indefinitely can intensify the pressure.

A useful handoff records the affected operation, error category, transaction boundary and the evidence that supports the next action. For the stock case, record the isolation context. For the standby case, record the read target and replay evidence. These details let the next DBA distinguish expected behaviour from a defect that requires correction.

SymptomEvidence to establish firstAvoid assuming
Two different readsIsolation and statement timingEvery changed result is corruption
Old value on standbyTarget and replay progressPrimary commit failed
Waiting transactionLock holder and dependency chainEvery wait is a deadlock

Related reading: Cloud storage questions; IT operations questions.

References

Frequently Asked Questions

No. Transaction invariants and replica freshness are separate concerns, so state the replication and read-routing behaviour explicitly.

Yes. Ordinary successive statements can see different committed snapshots when another transaction commits between their statement start times.

No. Establish replication progress and the read target before distinguishing delayed replay from a missing or failed primary transaction.

No. Grant the approved operations within their scope and assess the active role, inherited privileges and any role-assumption path.

It executes the statement and reports observations, so its operational effects must be considered before using it on any environment.

No. The workload and rows needed matter; compare the plan and measurements before proposing an index or another change.

No. A deadlock requires a cycle of waiting transactions, whereas ordinary blocking can resolve when the current holder finishes.

Use supplied transaction and replica timelines to explain possible results, missing context and the next evidence a DBA would request.

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Wow Wow 0
Sad Sad 0
Angry Angry 0
Anjali

I am passionate about technology, invention and big challenging tasks on my to- do list. In terms of the work I am doing also at Bunnyshell, I am most passionate about the technologies that we are using., I'm devoted to delivering content that not only informs but also inspires. Whether you need in- depth analysis pieces, educational attendants, or study- provoking opinion pieces, I draft content that resonates with tech suckers and professionals likewise.