Skip to content
tezvyn:

Database

113 bites tagged Database — interview questions with model answers, and 60-second explainers.

Android & Kotlin2 min read

How do you define a Room table for a Kotlin data class?

Tests your grasp of the minimum Room entity contract. A strong answer cites Entity and PrimaryKey, notes Kotlin defaults work out of the box, and mentions ColumnInfo for renaming.

TypeScript & Web APIs2 min read

IndexedDB: A NoSQL Database in Your Browser

Think of IndexedDB as a NoSQL database in the browser, built for large structured data that localStorage can't handle. It's ideal for offline apps or caching large assets. The footgun: browsers can evict your data, so it's not permanent storage.

Python & FastAPI2 min read

SQLAlchemy: Control When Your Relationships Load

SQLAlchemy's default lazy loading is convenient but can cause an N+1 query storm. Use eager loading (`joinedload`, `selectinload`) for collections you'll access to prevent many database round trips.

Python & FastAPI2 min read

Beanie: Python Objects as MongoDB Documents

Beanie maps Pydantic models to MongoDB documents, letting you interact with the database using Python objects instead of raw queries. Use it in async apps like FastAPI for rapid, type-safe CRUD.

Python & FastAPI2 min read

Motor: Don't Block Your Python App on MongoDB

Motor is the async bridge for Python apps to talk to MongoDB without blocking. Use it in FastAPI or other async frameworks to keep your server responsive during database queries.

Python & FastAPI2 min read

Alembic: Version Control for Your Database Schema

Alembic is like Git for your database schema, providing versioned, reversible changes. Use it with SQLAlchemy to evolve your database structure alongside your code. The footgun is that autogeneration can miss changes; always review generated scripts.

Python & FastAPI2 min read

SQLAlchemy Declarative: Python Classes as Database Tables

SQLAlchemy's Declarative Mapping lets you define database tables as Python classes. You write a class with typed attributes, and SQLAlchemy generates the SQL. It's the standard way to use the ORM, turning database rows into Python objects.

Python & FastAPI2 min read

SQLAlchemy Engine vs. Session: The Switchboard and the Call

Think of SQLAlchemy's Engine as the database switchboard (one per app) and a Session as a single, short-lived phone call (one per request). This pattern is standard in FastAPI for managing database connections.

Node.js & Express2 min read

Preventing SQL Injection: Never Trust User Input

To prevent SQL injection, treat SQL as a template and user input as data that can only fill placeholders, never changing the query's structure. Use this for any database query in your Node.js app that uses external data.

Node.js & Express2 min read

Sequelize Scopes: Reusable Query Shortcuts

Sequelize scopes are named shortcuts for common query conditions, letting you define `where` or `include` clauses once and reuse them. Use them to keep code DRY, like an `active` scope. The footgun: a `defaultScope` is always on unless you call `.unscoped()`.

Node.js & Express2 min read

Sequelize Transactions: All-or-Nothing Database Writes

A Sequelize transaction is a safety wrapper for database queries, ensuring they all succeed or none do. Use it for multi-step operations like creating a user and profile.

Node.js & Express2 min read

Sequelize Migrations: Version Control for Your Database

Think of Sequelize migrations as Git for your database schema. Each file is a commit describing how to apply (`up`) and revert (`down`) a change. Use them to evolve your schema reliably across environments. The footgun: never edit the DB directly.

Node.js & Express2 min read

Mongoose Validation: Your Schema's Built-in Guard

Mongoose validation is a guard at the application layer, ensuring data conforms to schema rules before hitting the database. Use it for required fields, lengths, and ranges. The `unique` option is for database indexes, not a Mongoose validation rule.

Node.js & Express2 min read

Mongoose Middleware (Hooks): Intercepting Database Operations

Mongoose middleware (hooks) lets you intercept database operations. Think of them as "before" or "after" scripts for actions like `save` or `find`. Use them to hash passwords before saving a user.

Node.js & Express2 min read

Sequelize Associations: Who Holds the Foreign Key?

Think of Sequelize associations as rules for foreign keys. `A.belongsTo(B)` means `A` holds the `bId` foreign key. `A.hasOne(B)` or `A.hasMany(B)` means `B` holds the `aId` key. The footgun is mixing these up, which breaks your database schema and queries.

Node.js & Express2 min read

Connecting to MongoDB with the Native Node.js Driver

The MongoDB driver is a translator between your Node.js app and database. You create a MongoClient, point it at your database URL, and then you can execute commands. The footgun is not closing the connection, which leads to resource leaks in your application.

Node.js & Express2 min read

Mongoose: Schemas are Blueprints, Models are Factories

A Mongoose Schema is the blueprint for your data, defining its shape and types. A Model is the factory that uses this blueprint to create, query, and save documents in MongoDB. The common footgun is trying to query the blueprint instead of the factory.

Monitoring & SRE2 min read

Data Sharding: Splitting a Database for Scale

Sharding splits a huge database into smaller, independent databases (shards), each on its own server. It's like giving different volumes of a phone book to different librarians. This is critical for massive datasets, but a bad shard key creates 'hot spots'.

Monitoring & SRE2 min read

Time-Series Databases: Optimized for Data Over Time

A Time-Series Database (TSDB) is a database optimized for data where time is the primary key. It's the backbone for monitoring systems, IoT devices, and financial apps. The footgun is using a regular database, which can't handle the unique query load.

iOS & Swift2 min read

Realm Database

Realm is an object oriented mobile database that stores your Swift model objects directly, without an ORM layer translating to and from SQL, and gives you live objects that automatically update in your UI whenever the underlying data changes.

iOS & Swift2 min read

SQLite: A Database in a Single File

SQLite is a self-contained SQL database engine that lives in a single file. It's ideal for mobile apps needing fast, reliable local data storage without a server. The footgun is using it for high-concurrency write scenarios, where it becomes a bottleneck.

Flutter & Dart2 min read

Choosing a Flutter Local Persistence Strategy

Flutter offers three main ways to persist data locally. Your options are simple key-value pairs for settings, direct file I/O for blobs like images, or a full SQLite database for complex, structured data. The main footgun is picking the wrong tool for the job.

Flutter & Dart2 min read

Isar: A Modern NoSQL Database for Flutter Apps

Isar is a fast, local NoSQL database for Flutter, offering static typing and ACID guarantees. Use it for on-device persistence in iOS, Android, and desktop apps. Don't mistake it for a remote database; Isar is for local storage, not cloud sync.

Flutter & Dart2 min read

Drift: Type-Safe SQL in Dart & Flutter

Drift gives your raw SQL queries compile-time safety. Instead of parsing maps, its build-time analyzer validates your SQL and generates typed Dart objects for results. Use it to write complex queries without risking runtime errors from typos or schema changes.

Get Database bites daily.

Five a day, five minutes, offline. With quizzes so it sticks.

Open testing — you’ll join as an early tester.