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?
Yam Marcovic
9,4002 gold badges29 silver badges30 bronze badges
asked Oct 21, 2012 at 20:43
3
  • "Sharded"? I don't know such word and can't find it in any dictionary. Did you mean "shared"? Commented Oct 22, 2012 at 7:10
  • 2
    "sharded" is the correct term in this question, but you could also use "partitioned" in this case. Commented Oct 22, 2012 at 7:31
  • For more information about sharding: en.wikipedia.org/wiki/Shard_%28database_architecture%29 Commented Oct 22, 2012 at 9:34

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

answered Oct 22, 2012 at 17:11

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.