Database Study Flashcards
100 interactive study cards across 10 database engines. Test core architecture, querying syntax, indexing, and interview concepts.
What is MVCC in PostgreSQL?
Multi-Version Concurrency Control (MVCC) ensures data consistency by granting each transaction a snapshot of the database, allowing concurrent reads and writes without locking.
What is the purpose of the Write-Ahead Log (WAL)?
WAL records changes to disk before data pages are updated, ensuring durability and enabling point-in-time recovery (PITR) and replication.
How does JSONB differ from standard JSON in Postgres?
JSONB stores data in a parsed binary format that supports indexing (GIN/GiST) and faster processing, whereas JSON stores exact unparsed text.
What does the EXPLAIN ANALYZE statement do?
EXPLAIN ANALYZE executes the query and provides the exact execution plan along with real execution time and row count statistics.
What is the function of autovacuum?
Autovacuum reclaims dead tuple storage left behind by UPDATEs and DELETEs, and updates planner statistics to maintain performance.
What is a GIN Index used for in Postgres?
Generalized Inverted Index (GIN) is designed for composite items like JSONB documents, arrays, and full-text search documents.
What is the RETURNING clause in INSERT/UPDATE/DELETE?
RETURNING allows DML statements to return modified or inserted row columns directly without issuing a separate SELECT query.
What is a Foreign Data Wrapper (FDW)?
FDW allows PostgreSQL to query external datasets (like Remote Postgres, MySQL, Redis, or CSVs) as if they were local tables.
What is PG Vector used for?
pgvector is an open-source vector similarity search extension for storing and searching high-dimensional AI vector embeddings in Postgres.
How does STRING_AGG work in Postgres?
STRING_AGG concatenates non-null text values from a set of rows into a single string separated by a specified delimiter.
What is the default storage engine in MySQL?
InnoDB is the default storage engine, offering ACID transactions, foreign keys, and row-level locking.
What is the difference between InnoDB and MyISAM?
InnoDB supports transactions, row locking, and foreign keys. MyISAM supports table-level locking only and has no transaction support.
How does ON DUPLICATE KEY UPDATE work in MySQL?
When an INSERT statement causes a primary or unique key duplicate, MySQL executes an UPDATE on the existing row instead.
What is GROUP_CONCAT used for?
GROUP_CONCAT aggregates multiple non-null row values into a single concatenated string per group.
What is the function of the Redo Log in InnoDB?
The Redo Log records page changes to ensure crash recovery (durability) before changes are written to tablespace data files.
What does EXPLAIN in MySQL show?
EXPLAIN displays how MySQL executes a query, including key usage, join types (ALL, ref, eq_ref), and rows examined.
How do AUTO_INCREMENT columns work?
AUTO_INCREMENT automatically generates sequential unique numeric keys for new table rows.
What is Master-Replica Replication in MySQL?
A topology where writes to a Primary database are recorded in binary logs (binlog) and replayed on Secondary replica instances.
What is a Covering Index in MySQL?
An index that contains all columns required by a query, enabling MySQL to return results directly from the index without reading table pages.
What is the default isolation level in InnoDB?
REPEATABLE READ is InnoDB's default isolation level, preventing non-repeatable reads using multi-versioning.
What does 'serverless' mean in SQLite?
SQLite reads and writes directly to standard disk files without running a background server process daemon.
What is WAL mode in SQLite?
Write-Ahead Logging (WAL) allows concurrent readers while a write is occurring, improving concurrency and speed.
How does dynamic typing work in SQLite?
Data types are associated with the stored values themselves rather than the declared column types (manifest typing).
What is an in-memory SQLite database?
A database created using ':memory:' as the filename, residing entirely in RAM and deleted upon connection close.
What does PRAGMA table_info(tbl) do?
It returns metadata about table columns, data types, nullability, default values, and primary key flags.
What is VACUUM in SQLite?
VACUUM rebuilds the database file to reclaim unused space and defragment data pages.
How do AUTOINCREMENT primary keys work in SQLite?
AUTOINCREMENT ensures primary key IDs are strictly monotonically increasing and never reused.
What is FTS5 in SQLite?
Full-Text Search 5 (FTS5) is a built-in virtual table module providing fast text search over text columns.
What is a Virtual Table in SQLite?
An object that presents an external data source (like CSV files or custom C code) as a SQLite table.
What is the strict mode introduced in SQLite 3.37?
STRICT tables enforce rigid column data type checks, overriding default dynamic manifest typing.
What is SGA in Oracle Architecture?
System Global Area (SGA) is the shared memory region containing data buffer cache, shared pool, and redo log buffer.
What is PGA in Oracle Database?
Program Global Area (PGA) is private memory allocated for each server process executing SQL operations.
How does ROWNUM differ from FETCH FIRST in Oracle?
ROWNUM assigns row numbers during fetch, whereas FETCH FIRST N ROWS ONLY is standard ANSI pagination syntax.
What is NVL() in Oracle SQL?
NVL(expr1, expr2) replaces NULL with expr2 if expr1 evaluates to NULL.
What is PL/SQL?
Procedural Language/SQL (PL/SQL) is Oracle's extension providing procedural constructs like loops, variables, and exceptions.
What is a Materialized View in Oracle?
A database object storing pre-computed query results that can be refreshed on demand or commit.
What is Oracle Flashback Query?
Enables querying table data state as it existed at a past timestamp or SCN number.
What is a Table Space in Oracle?
Logical storage unit grouping physical data files (.dbf) containing tables and indexes.
What is CONNECT BY used for?
Hierarchical query clause used to traverse parent-child tree relationships in Oracle SQL.
What is a Sequence in Oracle?
Database object that generates sequential unique integers (using NEXTVAL and CURRVAL).
What is T-SQL?
Transact-SQL (T-SQL) is Microsoft's extension to SQL adding procedural variables, string functions, and control flow.
How does TOP (N) work in SQL Server?
TOP (N) limits the number of output rows returned by a SELECT query.
What is the difference between #temp and ##temp tables?
Single hash (#temp) is visible only to the current session. Double hash (##temp) is global and visible to all sessions.
What is CROSS APPLY in T-SQL?
CROSS APPLY invokes a table-valued function or correlated subquery for each row returned by an outer table query.
How does IDENTITY(1,1) work?
IDENTITY automatically generates auto-incrementing integer key values for new records.
What is SQL Server Agent?
A background service that executes scheduled administrative tasks, jobs, and automated backups.
What is the difference between ISNULL and COALESCE?
ISNULL accepts two arguments and uses data type of first argument. COALESCE accepts multiple arguments and returns highest data type precedence.
What is TRY_CAST / TRY_CONVERT?
Converts data to specified type and returns NULL if conversion fails instead of throwing a runtime error.
What is a Clustered Index in SQL Server?
Defines the physical storage order of data rows on disk (only one clustered index per table).
What is STRING_AGG in T-SQL?
Concatenates expression values with specified separator across dataset groups.
What is BSON in MongoDB?
Binary JSON (BSON) is the binary serialization format used to store documents and extend JSON with data types like Date and ObjectId.
What is an ObjectId?
A 12-byte unique identifier generated automatically for document _id fields containing timestamp, machine, process, and counter bits.
What is the Aggregation Pipeline?
A multi-stage framework ($match, $group, $lookup, $unwind) for transforming and summarizing documents sequentially.
How does $lookup work in MongoDB?
It performs an equality left outer join to a collection in the same database to pull in related document arrays.
What is a Replica Set in MongoDB?
A cluster of MongoDB servers maintaining identical data copies to ensure high availability and automatic failover.
What is Sharding in MongoDB?
Horizontal scaling method partitioning document datasets across multiple server shards using a shard key.
What is a 2dsphere Index?
An index supporting spatial queries over spherical geometry objects like points, lines, and polygons.
What is Schema Validation in MongoDB?
JSON Schema rules enforced during write operations to guarantee document structure integrity.
What does the $unwind stage do?
It deconstructs an array field from input documents to output a document for each element in the array.
What is an Upsert in MongoDB?
An update operation that updates matching documents or creates a new document if no match is found.
What data structures does Redis support?
Strings, Hashes, Lists, Sets, Sorted Sets (ZSet), Bitmaps, HyperLogLogs, Geospatial indexes, and Streams.
What is TTL in Redis?
Time-To-Live (TTL) sets an automated expiration time after which Redis deletes the key from RAM.
How does Redis persistence work?
Redis supports RDB (point-in-time snapshot files) and AOF (Append-Only File logging every write command).
What is Pub/Sub in Redis?
A messaging pattern where publishers send messages to channels without knowing connected subscribers.
What is a Sorted Set (ZSET)?
A collection of unique strings where each element is associated with a floating-point score used for ordering.
What is Redis Sentinel?
A system providing high availability, monitoring, notification, and automatic failover for Redis primary nodes.
What is Redis Cluster?
Provides a way to run a Redis installation where data is automatically sharded across 16,384 hash slots.
What is Pipeline execution in Redis?
Sending multiple commands to the server without waiting for individual replies, reducing round-trip time (RTT).
What is the LRU Eviction Policy?
Least Recently Used (LRU) automatically evicts least recently accessed keys when RAM usage hits maxmemory limits.
How do Lua scripts execute in Redis?
Lua scripts run atomically on the Redis server, guaranteeing no other command executes concurrently during script run.
What is the core architecture of Snowflake?
Separation of Storage, Multi-Cluster Compute (Virtual Warehouses), and Cloud Services layer.
What is a Virtual Warehouse?
An independent CPU/RAM compute cluster used to execute SQL queries and DML operations.
What is Micro-partitioning in Snowflake?
Automatic contiguous 50MB-150MB compressed storage blocks formatted in columnar layout.
What is the QUALIFY clause?
QUALIFY filters window function results in a SELECT statement, eliminating subqueries.
What is Zero-Copy Cloning?
Instantly creates a metadata copy of tables or databases without duplicating physical data storage.
What is Time Travel in Snowflake?
Access historic table data state at any point within a configurable period (up to 90 days).
What is Snowpipe?
An automated continuous data ingestion service loading files as they land in S3/GCS stages.
What is VARIANT data type?
A flexible semi-structured data type storing up to 16MB of JSON, Avro, ORC, or XML data.
How does Clustering Key help queries?
Organizes micro-partitions along specified columns to maximize partition pruning speed.
What is Data Sharing in Snowflake?
Enables secure live data sharing across Snowflake accounts without copying physical files.
What is MergeTree in ClickHouse?
The default and most powerful table engine family, featuring primary key indexing, partition pruning, and background data merging.
Why is ClickHouse column-oriented?
Columnar storage reads only queried columns from disk, dramatically accelerating analytical aggregation queries over billions of rows.
How does Primary Key work in ClickHouse MergeTree?
Primary keys do not enforce row uniqueness; instead, they create a sparse index pointing to data mark ranges.
What is ReplacingMergeTree?
A table engine that asynchronously deduplicates rows matching the primary key in background merges.
What is SummingMergeTree?
A specialized table engine that automatically sums numeric columns sharing the same primary key during background merges.
What is vector execution in ClickHouse?
Processing data in memory blocks (vectors) using SIMD CPU instructions for high query execution performance.
What is a Materialized View in ClickHouse?
Stores transformed rows continuously as data is inserted into the source table, avoiding query-time computation.
What does arrayJoin() do?
It expands array elements into individual result output rows, similar to MongoDB's $unwind.
How does Partition Pruning work?
Skipping unneeded data partition files based on WHERE conditions matching the PARTITION BY expression.
What is the system.parts table?
A system catalog table providing metrics about physical MergeTree table parts, sizes, and row counts.
What is DuckDB?
An embedded columnar analytical database engine (often called the SQLite for Analytics).
What is vectorized execution in DuckDB?
Queries process vectors of data values in CPU cache lines using SIMD instructions for maximum throughput.
Can DuckDB read Parquet files directly?
Yes, DuckDB can execute SQL queries directly against local or remote Parquet and CSV files without importing them into tables.
How does DuckDB integrate with Python Pandas/Polars?
DuckDB can query Pandas DataFrames, Polars DataFrames, and Arrow tables directly zero-copy.
Does DuckDB support the QUALIFY clause?
Yes, DuckDB supports Snowflake-style QUALIFY clauses to filter window function outputs directly.
Is DuckDB single-threaded or multi-threaded?
DuckDB automatically parallelizes query execution across all available CPU cores.
What is read_parquet('s3://...')?
A function allowing direct HTTP/S3 querying of remote Parquet data lakes.
How does DuckDB handle memory limits?
DuckDB gracefully spills intermediate data to disk when query memory usage exceeds RAM limits.
What is COPY TO in DuckDB?
Exports query results directly into Parquet, CSV, or JSON files on disk.
Does DuckDB support ACID transactions?
Yes, DuckDB features full ACID transactional semantics using Multi-Version Concurrency Control (MVCC).
No flashcards found matching your query.