PROFESSIONAL-CLOUD-DEVELOPER · Question #4
You are designing a schema for a Cloud Spanner customer database. You want to store a phone number array field in a customer table. You also want to allow users to search customers by phone number. Ho
The correct answer is D. Create a table named Customers as a parent table.. Cloud Spanner supports ARRAY columns, but arrays cannot be indexed directly, so storing phone numbers as an ARRAY field in the Customers table makes search-by-phone-number impossible without a full scan. The idiomatic Cloud Spanner solution is to create a separate CustomerPhoneNu
Question
You are designing a schema for a Cloud Spanner customer database. You want to store a phone number array field in a customer table. You also want to allow users to search customers by phone number. How should you design this schema?
Options
- ACreate a table named Customers.
- BCreate a table named Customers.
- CCreate a table named Customers.
- DCreate a table named Customers as a parent table.
How the community answered
(46 responses)- A4% (2)
- B15% (7)
- C9% (4)
- D72% (33)
Explanation
Cloud Spanner supports ARRAY columns, but arrays cannot be indexed directly, so storing phone numbers as an ARRAY field in the Customers table makes search-by-phone-number impossible without a full scan. The idiomatic Cloud Spanner solution is to create a separate CustomerPhoneNumbers table that is INTERLEAVED IN PARENT Customers-this child table holds one row per phone number and can carry a secondary index on the phone number column. Using Customers as the parent table (option D) enables this parent-child interleaving, which co-locates phone rows with their parent customer row for efficient joins and allows a proper index for phone-number-based lookups. Options A, B, and C represent variations that do not establish the correct parent-child interleaved relationship needed for indexable, searchable phone data.
Topics
Community Discussion
No community discussion yet for this question.