Sample questions
Question 1Easy
CDC events for primary key 7 arrive in order: insert, update, update, delete. After all are applied to the target table, what exists for key 7?
- The inserted row
- Two rows
- The last updated row
- No row
Answer: D. No row
Explanation
The final event is a delete, so the row is removed.
Step-by-step solution
- The insert creates the row for key 7.
- The two updates change that same row, so there is still only one row for key 7.
- The final event is a delete, which removes the row for key 7.
- After all events are applied, no row exists for key 7. The correct answer is option D, no row.
Why the other options are wrong
- A. The inserted row was changed and then deleted, so it is no longer there.
- B. A table holds at most one row per primary key, so two rows cannot exist.
- C. The last update is removed by the later delete, so no updated row remains.
Tip: Replay CDC events in order; the final event for a key decides whether the row exists.
Question 2Easy
Change data capture (CDC) is used to:
- Convert SQL queries into Python scripts
- Encrypt the database's network traffic
- Stream inserts, updates and deletes from a database
- Compress database backups before storing them in cheap object storage
Answer: C. Stream inserts, updates and deletes from a database
Explanation
CDC turns row-level changes into a stream that downstream systems apply.
Step-by-step solution
- CDC tracks changes like inserts, updates and deletes in a database.
- These changes are turned into a continuous data stream.
- The stream is used by other systems to keep their data up-to-date.
- This matches option C exactly.
- Final answer: Stream inserts, updates and deletes from a database.
Why the other options are wrong
- A. Converting SQL queries into Python scripts is a code-translation task, unrelated to tracking database changes.
- B. Encrypting network traffic is a security job, while CDC tracks row changes so other systems can follow them.
- D. Compressing backups for cheap storage is a backup task; CDC is about streaming changes as they happen.
Tip: Remember CDC is about tracking live data changes, not encryption or compression.
Question 3Easy
Which kind of change does a simple query on an updated_at column fail to see?
- New inserts with a fresh timestamp
- Hard deletes
- Rows that already existed at the first run
- Updates that set a newer timestamp
Answer: B. Hard deletes
Explanation
A deleted row is gone from the table, so no query on it can return it; log-based CDC records the delete event.
Step-by-step solution
- A simple query checks for rows with updated_at values.
- Hard deletes remove rows entirely from the table.
- Deleted rows are not present in the table to be queried.
- So a query on updated_at cannot find deleted rows.
- Final answer: Hard deletes.
Why the other options are wrong
- A. New inserts get a fresh timestamp, so an updated_at query does see them.
- C. Rows that existed at the first run are still in the table, so a timestamp query can find them.
- D. Updates that set a newer timestamp change updated_at, so the simple query does catch them.
Tip: Hard deletes are invisible to any query.
Question 4Easy
A CDC pipeline first copies the whole existing table, then streams later changes. The first step is called:
- A tombstone record
- An initial snapshot
- A consumer rebalance
- A schema registry
Answer: B. An initial snapshot
Explanation
The snapshot sets the starting state; the change stream keeps it up to date.
Step-by-step solution
- The pipeline starts by copying the entire table.
- This initial copy is called an initial snapshot.
- After the snapshot, it streams changes.
- The first step is setting the starting state.
- So the first step is an initial snapshot.
Why the other options are wrong
- A. A tombstone is a marker for a deleted key in a log-compacted topic, not the first copy step.
- C. A consumer rebalance redistributes partitions among consumers; it is not a copy of the existing table.
- D. A schema registry stores message schemas; it does not copy the table's existing rows.
Tip: Remember: Snapshot sets the starting point for change tracking.
Question 5Medium
Log-based CDC reads changes from:
- The database's transaction log, such as the WAL or binlog
- Triggers that copy each changed row into separate audit tables in the source
- Hourly SELECT queries filtered on updated_at
- Screenshots of the admin console
Answer: A. The database's transaction log, such as the WAL or binlog
Explanation
Reading the log captures every committed change, including deletes, with low load on the source.
Step-by-step solution
- Log-based CDC reads changes directly from the database's transaction log.
- Transaction logs like WAL or binlog record all write operations.
- This method captures every committed change including deletes.
- It has minimal impact on source performance.
- Final answer: The database's transaction log, such as the WAL or binlog.
Why the other options are wrong
- B. Triggers write changes into audit tables; that is trigger-based CDC, not reading the transaction log.
- C. Hourly SELECT queries on updated_at poll the table and miss deletes; they do not read the transaction log.
- D. Screenshots of the admin console show what someone sees, not how changes are read from a database.
Tip: Use logs for real-time change tracking without affecting performance.
Question 6Medium
Applying a CDC stream to a warehouse table is usually done with:
MERGE (upsert and delete) keyed on the primary keyTRUNCATE and full reload on every eventDROP TABLE followed by CREATE TABLEINSERT only, keeping every version as a new row without ever deleting anything
Answer: A. MERGE (upsert and delete) keyed on the primary key
Explanation
MERGE applies inserts, updates and deletes; for history, the stream can instead feed an SCD Type 2 table.
Step-by-step solution
- MERGE allows upserts and deletes using primary key matches.
- It efficiently handles changes in data streams with minimal overhead.
- Other options like TRUNCATE or DROP are slower and less precise for incremental updates.
- INSERT only adds new rows without managing deletions or updates properly.
- Thus, MERGE is the best choice for CDC stream integration.
Why the other options are wrong
- B. TRUNCATE and a full reload on every event throws away the table each time and is far too slow for streams.
- C. Dropping and recreating the table loses the data and its structure on each change; it is not an incremental merge.
- D. INSERT only keeps every version but never applies deletes or updates to the target, so it does not mirror the source.
Tip: Use MERGE for efficient CDC stream operations with upserts and deletes.
Question 7Medium
Compared with log-based CDC, query-based CDC (polling on updated_at) tends to:
- Miss deletes and intermediate updates
- Capture every change, including deletes
- Require no timestamp column in the table
- Add no load at all to the source database
Answer: A. Miss deletes and intermediate updates
Explanation
Polling sees only the current state at each poll; rows changed twice between polls show only the final version.
Step-by-step solution
- Query-based CDC polls the table for rows whose updated_at is newer than the last poll.
- Each poll sees only the latest state of each row at that moment.
- A row deleted between polls is never seen, and a row changed twice shows only its final version.
- The correct answer is 0: query-based CDC misses deletes and intermediate updates.
Why the other options are wrong
- B. Polling cannot see deletes, so it cannot capture every change.
- C. Query-based CDC does need an updated_at column; it cannot work without one.
- D. Polling queries the source database, so it does add load.
Tip: Log-based CDC reads the change log and catches every change, including deletes.
Question 8Medium
When CDC events go into Kafka, why use the table's primary key as the message key?
- All changes to one row stay in order in one partition
- It makes each message smaller on disk than sending the same message with no key
- Kafka requires the key to match a database column
- It lets consumers skip the snapshot phase
Answer: A. All changes to one row stay in order in one partition
Explanation
Per-key ordering ensures an update is never applied before the insert that preceded it.
Step-by-step solution
- Kafka keeps messages in order only within one partition.
- Messages with the same key always go to the same partition, because the key decides the partition.
- Using the table's primary key as the key sends every change to one row into the same partition.
- Those changes therefore stay in order. The correct answer is option A, all changes to one row stay in order in one partition.
Why the other options are wrong
- B. A key does not make the message smaller; the key is extra data, not compression.
- C. Kafka does not require the key to match a database column; the producer picks the key.
- D. Skipping the snapshot phase is not a result of using a message key.
Tip: For ordering in Kafka, use one key per entity so all its events share a partition.
Question 9Hard
A service saves an order to its database and then publishes an event to Kafka. Sometimes the save succeeds but the publish fails. Which pattern fixes this dual-write problem?
- Send the event by email as a backup channel
- Retry the publish in an infinite loop inside the same web request until it works
- Transactional outbox: write the event to a table in the same transaction, then relay it
- Publish to Kafka first, then save the order afterwards
Answer: C. Transactional outbox: write the event to a table in the same transaction, then relay it
Explanation
One local transaction covers both the business row and the outbox row; CDC or a relay then publishes the outbox reliably.
Step-by-step solution
- The service must ensure both save and publish succeed together.
- Transactional outbox writes event to table in same transaction as order save.
- If publish fails, the event is retried from the outbox later.
- This ensures consistency without duplicating data.
- Final answer: Transactional outbox: write the event to a table in the same transaction, then relay it.
Why the other options are wrong
- A. Sending the event by email is not reliable and does not keep the order save and event publish consistent.
- B. Retrying in a loop inside the request can still fail if the process crashes, so the event can be lost.
- D. Publishing first still leaves the risk: if the order save then fails, the event describes an order that never existed.
Tip: Use transactional outbox for dual-write consistency in distributed systems.
Question 10Hard
In a CDC topic with log compaction, how is a deleted row represented so that compaction eventually removes the key?
- A message with a negative offset for that key
- No message at all; the key simply stops appearing in later records of the topic
- A message with the key and an empty string value
- A tombstone: a message with the key and a null value
Answer: D. A tombstone: a message with the key and a null value
Explanation
Compaction keeps the latest record per key; a null-value tombstone tells it the key can be dropped.
Step-by-step solution
- A tombstone is a special message used to mark deleted keys.
- It contains the key and a null value to indicate deletion.
- Compaction processes these tombstones to remove the key permanently.
- This ensures that only the latest record per key remains.
- The final answer is D (A tombstone: a message with the key and a null value).
Why the other options are wrong
- A. A negative offset is not a delete marker; offsets only number messages and cannot remove a key.
- B. Simply stopping sending messages keeps the old value in the log; compaction only removes a key after a tombstone.
- C. An empty string is still a real value, so compaction keeps that key instead of removing it.
Tip: Remember: Tombstones use null values to signal deletion in log compaction.
Practise all 11 questions free
The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.
Open this topic in the app →