How should a schema be designed in Cloud Spanner to allow search by phone number?

Disable ads (and more) with a premium pass for a one time $4.99 payment

Prepare for the Google Cloud Professional Cloud Developer Test. Benefit from mock assessments featuring flashcards and multiple-choice format, each furnished with hints and detailed explanations. Excel in your exam with confidence!

Designing a schema in Cloud Spanner with the ability to search by phone number involves considering both normalization and indexing. The most effective approach among the options presented is to create a Customers table and interleave a Phones table with an index.

Interleaving a Phones table within the Customers table allows for a close relationship between customers and their associated phone numbers. This structure improves query performance because it clusters the related data together physically and can leverage the primary key in the Customers table as a foreign key in the Phones table. When using this schema design, each phone number is directly associated with its customer through the interleaved structure, minimizing the need for expensive join operations and enabling efficient searches.

Additionally, creating an index on the Phones table—either on the phone number itself or any other relevant searching criteria—further enhances the search capability. This indexing allows for quick retrieval of phone numbers without needing to scan the entire dataset.

In contrast, using an Array field for phone numbers may complicate querying since it could lead to inefficient searches and does not utilize Spanner's strengths of distributed computing efficiently. Similarly, separating the tables without interleaving might necessitate more complex join operations and can also degrade performance.

Thus, the proposed schema design promotes efficient search and

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy