Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam Professional Cloud Developer All Questions

View all questions & answers for the Professional Cloud Developer exam

Exam Professional Cloud Developer topic 1 question 56 discussion

Actual exam question from Google's Professional Cloud Developer
Question #: 56
Topic #: 1
[All Professional Cloud Developer Questions]

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?

  • A. Create a table named Customers. Add an Array field in a table that will hold phone numbers for the customer.
  • 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.
  • 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.
  • 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.
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
dendut
Highly Voted 3 years, 10 months ago
i vote D since it said 'interleave'
upvoted 12 times
StelSen
3 years, 9 months ago
Correct. Just sharing a link: https://cloud.google.com/spanner/docs/schema-and-data-model#creating_a_hierarchy_of_interleaved_tables
upvoted 7 times
...
...
fosky94
Highly Voted 3 years, 7 months ago
Correct answer is C, as in the question states: "You want to store a phone number array field in a customer table". So... adding the phone number as array field and adding a secondary index should be the best option in this case.
upvoted 7 times
mastodilu
3 years, 6 months ago
i say B, because if a user has more numbers you are storing the same user multiple times each time changing the phone number. Having a second table for phone numbers and having a foreign key that points to the user with this phone number avoid this duplication problem.
upvoted 1 times
...
...
thewalker
Most Recent 4 months, 1 week ago
Selected Answer: D
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.
upvoted 1 times
thewalker
4 months, 1 week ago
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.
upvoted 1 times
...
...
santoshchauhan
8 months, 3 weeks ago
Selected Answer: D
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.
upvoted 1 times
...
__rajan__
1 year, 2 months ago
Selected Answer: D
I will go with D.
upvoted 1 times
...
omermahgoub
1 year, 10 months ago
The correct answer is D. You should create a table named Customers as a parent table and a table named Phones, and interleave this table into the Customer table. You should also create an index on the phone number field in the Phones table. This allows you to store the phone number array field in the Customers table and search for customers by phone number using the index on the Phones table.
upvoted 3 times
omermahgoub
1 year, 10 months ago
C is not a valid solution because Cloud Spanner does not allow creating secondary indexes on array fields.
upvoted 3 times
...
...
tomato123
2 years, 3 months ago
Selected Answer: D
D is correct
upvoted 3 times
...
akshaychavan7
2 years, 4 months ago
Selected Answer: D
It's D.
upvoted 1 times
...
keshav1
2 years, 5 months ago
Selected Answer: A
Search on ARRAY column is best here. Answer: A
upvoted 1 times
...
Ksamilosb
2 years, 9 months ago
D seems quite nice, but what do u thing about statement "You want to store a phone number array field in a customer table.", and interleave in another table, not customer one. In sql there is array field, and using UNNEST function is possible to filter records based on array, then answer A
upvoted 3 times
...
ParagSanyashiv
2 years, 10 months ago
Selected Answer: D
D is the correct answer
upvoted 1 times
...
syu31svc
3 years, 4 months ago
https://cloud.google.com/spanner/docs/schema-design#creating-indexes: "bad idea to create non-interleaved indexes on columns whose values are monotonically increasing or decreasing" Since phone numbers monotonically increase/decrease, I would take D as the answer
upvoted 1 times
...
yuchun
3 years, 5 months ago
https://cloud.google.com/spanner/docs/data-types -->can't set secondary index in array so I vote D
upvoted 4 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...