MongoDB or PostgreSQL for a Q&A or social app?

poze 3 months ago236 gadeen

6

My data looks like JSON (users, posts, comments, likes), so MongoDB seems natural. Friends say to use Postgres. What are the real trade-offs?

Dyagnostik IA

Se IA ki fè l. Se pa yon repons — kominote a anba a konfime oswa korije l. Toujou verifye anvan ou fye l.

poze 3 months ago

1 Repons

9
✓
✓ Repons yo aksepte

Social and Q&A data is actually highly relational: users ↔ posts ↔ comments ↔ votes ↔ tags, plus follows, notifications and reputation. You'll constantly query *across* those relationships ("questions with tag X that the user hasn't voted on, sorted by score"). That's where relational databases shine.

PostgreSQL gives you joins, foreign keys (no orphaned comments), unique constraints (one vote per user), transactions across tables, and JSONB for the genuinely flexible parts.

MongoDB is strong when data is naturally document-shaped and read as a whole (product catalogs with varying attributes, event logs, CMS content), or when you need its horizontal-scaling model.

For a Q&A app, Postgres is the better default. It's exactly what Stack Overflow-style systems rely on (Stack Overflow itself runs on SQL Server).

Konekte pou di lòt moun si li te mache.

answered 3 months ago

Sign in and verify your email to post an answer.