Preparing Practice Exam…
Please wait a moment while the system generates the exam questions, answers, and study session.
Please wait a moment while the system generates the exam questions, answers, and study session.
Google Cloud Certified Professional Cloud Developer · Google Cloud
Select one answer.
Written by other learners. Comments can disagree with the marked answer — check the official documentation when in doubt.
The best approach is D. Create a table named Customers as a parent table. Create a table named Phones and interleave this table into the Customer table. Create an index on the phone number field in the Phones table. Here's why: Interleaved Tables: Interleaved tables in Cloud Spanner are designed for efficient storage and retrieval of related data. By interleaving the Phones table into the Customers table, you ensure that data for a specific customer is stored together, improving query performance. Indexing for Search: Creating an index on the phone number field in the Phones table allows for efficient searching of customers based on their phone numbers. This is crucial for your requirement to allow users to search customers by phone number. Scalability: This approach scales well as your customer database grows. Cloud Spanner automatically handles the distribution and scaling of data across multiple nodes.
Let's look at why the other options are less suitable: A. Create a table named Customers. Add an Array field in a table that will hold phone numbers for the customer. This approach is inefficient for searching. You would need to scan the entire array field for each customer, which can be slow for large datasets. B. Create a table named Customers. Create a table named Phones. Add a CustomerId field in the Phones table to find the CustomerId from a phone number. This approach is less efficient than interleaving. You would need to join the Customers and Phones tables for every search, which can be slower than using interleaved tables. C. Create a table named Customers. Add an Array field in a table that will hold phone numbers for the customer. Create a secondary index on the Array field. Cloud Spanner doesn't support secondary indexes on array fields.
D. Create a table named Customers as a parent table. Create a table named Phones, and interleave this table into the Customer table. Create an index on the phone number field in the Phones table. This design will allow you to store multiple phone numbers for each customer and efficiently search for customers by their phone numbers. In Cloud Spanner, tables can be interleaved, which means that the child table's rows are co-located with the parent table's rows. This setup can offer better performance for certain types of queries and data models, especially when there's a strong relational structure.