PCDE Design and implement database schemas Practice Question
A financial services company is designing a Cloud Spanner schema for a trading system. They have two main entities: 'accounts' and 'transactions'. Each account has many transactions, and queries almost always retrieve transactions for a specific account. Which TWO schema design strategies should they employ?
⚠ Common exam trap
Google Cloud often tests the misconception that secondary indexes are the default solution for filtering, when in Cloud Spanner the primary key design and interleaving are the preferred strategies for performance and cost efficiency.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Ensure the primary key of transactions includes the account_id as the first part.
Cloud Spanner distributes rows across splits based on the primary key prefix. By making `account_id` the first part of the transactions table primary key, all transactions for a given account are co-located, enabling efficient range scans and point lookups without cross-node shuffling.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Use a secondary index on transactions.account_id.
Why it's wrong here
While possible, a secondary index is less efficient than interleaving for this access pattern and adds write overhead.
- ✓
Ensure the primary key of transactions includes the account_id as the first part.
Why this is correct
This is required for interleaved tables: the child's primary key must start with the parent's primary key.
- ✗
Define a foreign key constraint from transactions to accounts.
Why it's wrong here
Cloud Spanner does not enforce foreign keys; they are informational only.
- ✗
Store transactions as a JSON array of repeating fields within the account record.
Why it's wrong here
Denormalization limits query flexibility and indexing, and is not recommended for Spanner.
- ✓
Use an interleaved table hierarchy with accounts as parent and transactions as child.
Why this is correct
Interleaved tables co-locate child rows with the parent row, optimizing queries that access transactions by account.
Go deeper
Related to this question
About these practice questions
One of 1,446 original PCDE practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This PCDE practice question is part of Courseiva's free Google Cloud certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCDE exam.