nerdexam
Google

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

Designing and Implementing Data Storage Solutions

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)
  • A
    4% (2)
  • B
    15% (7)
  • C
    9% (4)
  • D
    72% (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

#Cloud Spanner#Schema Design#Data Modeling#Indexing

Community Discussion

No community discussion yet for this question.

Full PROFESSIONAL-CLOUD-DEVELOPER Practice