Intermediate Backend

Databases (SQL vs NoSQL)

PostgreSQL, MongoDB, data modeling, and query optimization.

Storing and Retrieving Data

Databases are the backbone of most applications, providing persistent storage and efficient data retrieval.

SQL (Relational)

  • Structure: Tables with rows and columns
  • Schema: Defined upfront, enforced by database
  • Relationships: Foreign keys, JOINs
  • ACID: Strong consistency guarantees
  • Examples: PostgreSQL, MySQL, SQLite
-- SQL Example
SELECT users.name, COUNT(posts.id) as post_count
FROM users
LEFT JOIN posts ON users.id = posts.user_id
GROUP BY users.id
ORDER BY post_count DESC;

NoSQL (Non-Relational)

  • Document: MongoDB, CouchDB (JSON-like docs)
  • Key-Value: Redis, DynamoDB
  • Wide-Column: Cassandra, ScyllaDB
  • Graph: Neo4j, ArangoDB

When to Use What

  • SQL: Complex queries, transactions, data integrity
  • NoSQL: Flexible schema, horizontal scaling, specific access patterns

ORMs and Query Builders

  • Prisma: Type-safe ORM with migrations
  • Drizzle: TypeScript SQL query builder
  • Knex: SQL query builder
  • Mongoose: MongoDB ODM