CLOUD-DATABASE-ENGINEER practice question 15 of 25

You are building a data warehouse on BigQuery. Sources of data include several MySQL databases located on-premises. You need to transfer data from these databases into BigQuery for analytics. You want to use a managed solution that has low latency and is easy to set up. What should you do?

Full set: 141 questions
Answer options
A: Create extracts from your on-premises databases periodically, and push these extracts to Cloud Storage. Upload the changes into BigQuery, and merge them with existing tables.
B: Use Cloud Data Fusion and scheduled workflows to extract data from MySQL. Transform this data into the appropriate schema, and load this data into your BigQuery database.
C: Use Datastream to connect to your on-premises database and create a stream. Have Datastream write to Cloud Storage. Then use Dataflow to process the data into BigQuery. Correct answer
D: Use Database Migration Service to replicate data to a Cloud SQL for MySQL instance. Create federated tables in BigQuery on top of the replicated instances to transform and load the data into your BigQuery database.
Correct Answer:
C. Use Datastream to connect to your on-premises database and create a stream. Have Datastream write to Cloud Storage. Then use Dataflow to process the data into BigQuery.
Explanation

This solution provides a fully managed, low-latency, and easy-to-set-up pipeline for Change Data Capture (CDC). Datastream is Google Cloud's serverless CDC and replication service, designed to stream changes from source databases like MySQL with minimal latency. It writes these changes to Cloud Storage in a standardized format. From there, a pre-built Dataflow streaming template can be used to efficiently process these changes and merge them into the target BigQuery tables in near real-time. This architecture directly addresses all the requirements of the question by using purpose-built, managed services for each step of the process.

Why Incorrect

A. This describes a manual, periodic batch process. It fails to meet the requirements for a managed solution with low latency, as it relies on custom scripting and scheduled extracts.
B. Cloud Data Fusion with "scheduled workflows" implies a batch processing model, not a continuous, low-latency stream. While powerful for ETL, it is not the optimal choice for near real-time CDC.
D. While Database Migration Service (DMS) provides low-latency replication to Cloud SQL, using federated queries is an anti-pattern for loading a data warehouse. Federated queries are for ad-hoc analysis on external data, not for efficient, large-scale data ingestion and transformation into native BigQuery tables.

References

1. Datastream for CDC: "Datastream is a serverless and easy-to-use change data capture (CDC) and replication service. It allows you to synchronize data across heterogeneous databases and applications reliably, and with minimal latency." It supports MySQL as a source.

Source: Google Cloud Documentation, "Datastream overview", Introduction section.

2. Datastream to BigQuery Architecture: The recommended pattern for this use case is detailed in official Google Cloud tutorials. "Datastream streams every change from the source database—inserts, updates, and deletes—into Cloud Storage. Dataflow then picks up the files from Cloud Storage, and loads the data into BigQuery."

Source: Google Cloud Documentation, "Replicate data from an operational database to BigQuery using Datastream and Dataflow", Architecture section.

3. Dataflow Templates for Datastream: Google provides a specific template to simplify this process. "The Datastream to BigQuery template is a streaming pipeline that reads CDC data from Cloud Storage and replicates it into BigQuery."

Source: Google Cloud Documentation, "Datastream to BigQuery (template)", Overview section.

4. BigQuery Federated Queries Use Case: Federated queries are designed for a different purpose. "Federated queries let you send a query statement to an external database... and get the result back as a temporary table. Federated queries are useful for running ad hoc queries to analyze external data."

Source: Google Cloud Documentation, "Introduction to federated queries", first paragraph.

Scroll to Top