Master-Master Replication — SQL Technical Interview Questions & Answers

Master-Master Replication

Master-Master Replication

  • Master-Master Replication is how bigger MySQL setups split or copy data. Replication: one primary takes writes, replicas copy via the binary log (binlog) for reads/backups. Sharding: split rows across servers by a key (app-level or extra tools). Partitioning: split one table into pieces on the same server (PARTITION BY RANGE …).
  • A fresher viva: ‘we replicate for backup/read scale; we shard only when one server cannot hold the data.’ Don’t design sharding on day one of a college project.
  • Trap: calling PARTITION the same as SHARD. Trap: replica as a second writable primary without a plan (see primary-primary only if they ask).
  • On the example next to this theory: Master-Master Replication: create two demo rows, then SELECT qty >= 2 ordered. Say which labels come back.

Technical Interview Tip: Replication vs partition vs shard in one line each.

Code Examples for Master-Master Replication

Master-Master Replication — sample query

-- Master-Master Replication
CREATE TABLE demo (
  id INTEGER PRIMARY KEY,
  label TEXT NOT NULL,
  qty INTEGER DEFAULT 0
);
INSERT INTO demo (id, label, qty) VALUES
  (1, 'alpha', 2),
  (2, 'beta', 5);
SELECT label, qty FROM demo WHERE qty >= 2 ORDER BY qty DESC;

Master-Master Replication: create two demo rows, then SELECT qty >= 2 ordered. Say which labels come back.

How to Explain Master-Master Replication to an Interviewer

Replica vs shard?

Replica = copy of the same data Shard = different rows on different servers