
Answer-first summary for fast verification
Answer: Create a Cloud Spanner table that has TransactionId and CustomerId configured as primary keys. Use a random string (UUID) for the TransactionId.
The question requires selecting a scalable SQL database for global expansion. Cloud Spanner is designed for horizontal scaling and global distribution, making it a better choice over Cloud SQL. Using a UUID (random string) for TransactionId in Cloud Spanner avoids hotspotting issues that can occur with incremental numbers in distributed systems. Although the composite primary key (TransactionId, CustomerId) might seem redundant since TransactionId alone should be unique, the given options necessitate this structure. Thus, the correct choice combines Cloud Spanner's scalability with UUID's distribution benefits.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
Your organization manages an ecommerce website currently serving one region but planning global expansion. You need to choose a scalable SQL database and design a schema. How would you create a table to store customer transactions while ensuring uniqueness for both CustomerId and TransactionId?
A
Create a Cloud SQL table that has TransactionId and CustomerId configured as primary keys. Use an incremental number for the TransactionId.
B
Create a Cloud SQL table that has TransactionId and CustomerId configured as primary keys. Use a random string (UUID) for the Transactionid.
C
Create a Cloud Spanner table that has TransactionId and CustomerId configured as primary keys. Use a random string (UUID) for the TransactionId.
D
Create a Cloud Spanner table that has TransactionId and CustomerId configured as primary keys. Use an incremental number for the TransactionId.
No comments yet.