What is the difference between CREATE and MERGE commands?

Beginner

Answer

CREATE always creates new nodes/relationships, potentially causing duplicates:

CREATE (p:Person {name: "John"})  // Always creates new node

MERGE finds existing patterns or creates them if they don't exist:

MERGE (p:Person {name: "John"})   // Creates only if doesn't exist

MERGE with ON CREATE/MATCH:

MERGE (p:Person {email: "john@example.com"})
ON CREATE SET p.created = timestamp(), p.name = "John"
ON MATCH SET p.lastSeen = timestamp()

MERGE is safer for avoiding duplicates but can be slower than CREATE when you're certain the data doesn't exist.