I do not have a ton of experience designing databases. Imagine There are 3 tables, a members table with primary key MemeberID, a books table with primary key BookID and a loans table with primary key LoanID as well as having two foreign keys BookID and MemberID. I am partitioning the members table across multiple shards using MemberID and partitioning books table across shards using BookID. My problem arise when I want to partition loans table because it contains both partition keys. My idea to reduce cross-shard queries is to store loan entries that have MemberID and BookID on lets say shard ‘A’, on the same shard. And in the case where the bookID and memberID were on different shards then I’ll store duplicates (of the same loan entry) on both shards. This way the foreign keys on the loan entries will always reference a book or member row within the same database. Do you guys think duplication is acceptable in this situation and this is good design?
Fred is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.