Schema-on-Read and Schema-on-Write
Schema-on-Read vs Schema-on-Write
Visual Comparison
Schema-on-Write (SQL):
User → Application → [Schema Validation] → Database
↑ (rejects invalid data)
Structure enforced here
Schema-on-Read (NoSQL):
User → Application → Database (stores anything)
↑
Structure interpreted here when readingSchema-on-Write
Characteristics
Advantages
Disadvantages
Common in
Schema-on-Read
Characteristics
Advantages
Disadvantages
Common in
Golang Example: Comparing Both Approaches
Schema-on-Write (PostgreSQL)
Schema-on-Read (MongoDB)
Handling Schema Changes
Schema-on-Write: Requires Migration
Schema-on-Read: No Migration Needed
Key Differences Summary
Aspect
Schema-on-Write
Schema-on-Read
Hybrid approach
Complete SQL Example
Full Golang Example
Last updated