6

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?
3

1 Answer 1

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.

Regards,

Andy Grove
Chief Architect
http://www.dbshards.com

Your Answer

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

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