When designing data structures for an application, what are some best practices to make sure it can be sharded?

In particular, which of the following is better:

  1. Creating relationships in databases
  2. Establishing relationships in SQL queries as necessary?

1 Answer 1


You would typically shard a group of tables based on a key such as customer_id. One simple approach is to use the modulus. For example if you have 4 shards then divide the customer_id by 4 and use the remainder to determine which shard to use.

However, this approach isn't very flexible when you want to change the number of shards later on.

You may want to read this database sharding whitepaper that explains the theory in much more detail.


Andy Grove
Chief Architect

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.