Design Cloud Spanner schema to store multiple phone numbers per customer and allow lookup by phone number. Which schema is best?
Choose an answer
Tap an option to check your answer.
Correct answer: Create a Customers parent table and an interleaved Phones table; create an index on the phone number field in Phones..
Why this is the answer
The correct approach is to create a Customers parent table and an interleaved Phones table, with an index on the phone number field in Phones. Interleaving tables in Cloud Spanner physically co-locates child rows with their parent rows, which significantly improves read performance for customer-specific phone number lookups. An index on the phone number in the Phones table enables efficient lookups by phone number across all customers. Using an array field directly in the Customers table for phone numbers is inefficient for searching by phone number across all customers, as it would require scanning the entire Customers table. Creating a secondary index on an array field is not directly supported for efficient individual element lookup in the way a separate indexed table provides. While creating separate Customers and Phones tables is a valid relational model, interleaving optimizes performance in Cloud Spanner by reducing I/O operations for related data.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed