🌍 Backend Development · subject

Backend Development Databases and Data Modeling Syllabus

The Databases and Data Modeling syllabus for Backend Development in full: 7 chapters and 31 topics, every one listed below, plus 51 Databases and Data Modeling flashcards with answers.

7Chapters
31Topics
51Flashcards

Databases and Data Modeling syllabus: all 7 chapters

Expand any chapter to see its topics and sub-topics.

  1. Relational Databases

    4 topics
    • Relational Model and Tables
    • Primary and Foreign Keys
    • PostgreSQL and MySQL
    • Constraints and Data Integrity
  2. SQL Query Language

    5 topics
    • SELECT, INSERT, UPDATE, DELETE
    • Joins and Subqueries
    • Aggregations and Grouping
    • Window Functions
    • Views and Stored Procedures
  3. Data Modeling and Normalization

    4 topics
    • Entity-Relationship Modeling
    • Normalization Forms
    • Denormalization Tradeoffs
    • Schema Migrations
  4. NoSQL Databases

    5 topics
    • Document Stores (MongoDB)
    • Key-Value Stores (Redis)
    • Wide-Column Stores (Cassandra)
    • Graph Databases (Neo4j)
    • Choosing SQL vs NoSQL
  5. Transactions and Concurrency

    4 topics
    • ACID Properties
    • Isolation Levels
    • Locking and Deadlocks
    • Optimistic vs Pessimistic Concurrency
  6. ORMs and Query Builders

    4 topics
    • Object-Relational Mapping Concepts
    • Popular ORMs
    • Query Builders and Raw SQL
    • Connection Pooling
  7. Database Performance and Scaling

    5 topics
    • Indexing Strategies
    • Query Optimization and EXPLAIN
    • Replication and Read Replicas
    • Sharding and Partitioning
    • Backups and Disaster Recovery

Backend Development Databases and Data Modeling flashcards — 51 questions with answers

  1. In the relational model, what is a relation, and what are its rows and columns called?

    A relation is a table representing a set of related data. Its rows are called tuples (records), and its columns are called attributes (fields). Each relation has a schema defining attribute names and domains (allowed value types).

  2. What is a candidate key versus the primary key in a relational table?

    A candidate key is any minimal set of attributes that uniquely identifies each tuple. The primary key is the one candidate key chosen to be the main identifier; it must be unique and NOT NULL. Remaining candidate keys are called alternate keys.

  3. Define a foreign key and the referential integrity rule it enforces.

    A foreign key is a column (or set) in one table that references the primary key of another table. Referential integrity requires that every foreign key value either match an existing primary key value in the referenced table or be NULL.

  4. What do the referential actions ON DELETE CASCADE, SET NULL, and RESTRICT do?

    CASCADE deletes child rows when the referenced parent row is deleted. SET NULL sets the foreign key to NULL on parent deletion. RESTRICT (and NO ACTION) blocks deletion of a parent row while dependent child rows still reference it.

  5. Name the five main SQL integrity constraints and what each guarantees.

    NOT NULL (value must exist), UNIQUE (no duplicate values), PRIMARY KEY (unique + not null), FOREIGN KEY (referential integrity), and CHECK (value satisfies a boolean condition). DEFAULT supplies a value when none is given.

  6. What are the ACID properties of a database transaction?

    Atomicity (all-or-nothing execution), Consistency (transitions leave the DB in a valid state respecting constraints), Isolation (concurrent transactions do not interfere), and Durability (committed changes survive failures).

  7. List the four SQL transaction isolation levels from weakest to strongest.

    READ UNCOMMITTED, READ COMMITTED, REPEATABLE READ, and SERIALIZABLE. Higher levels prevent more anomalies (dirty read, non-repeatable read, phantom read) at the cost of concurrency.

  8. Which concurrency anomalies are prevented at each SQL isolation level?

    READ UNCOMMITTED allows dirty, non-repeatable, and phantom reads. READ COMMITTED prevents dirty reads. REPEATABLE READ also prevents non-repeatable reads. SERIALIZABLE prevents all three, including phantoms.

  9. Contrast PostgreSQL and MySQL on their default primary storage/concurrency model.

    PostgreSQL is a single unified engine using MVCC (multi-version concurrency control) for all tables. MySQL supports pluggable engines; its default InnoDB also uses MVCC and supports transactions, while the older MyISAM engine lacks transactions and foreign keys.

  10. Name two features PostgreSQL supports that classic MySQL historically lacked.

    PostgreSQL has long supported advanced features like CHECK constraints enforcement, full window functions, CTEs, rich JSONB, array types, custom types, and true partial/expression indexes—many of which MySQL added only in later versions (e.g., MySQL 8.0 added window functions and CTEs).

  11. Write the general syntax of a SELECT statement including the main clauses in execution-friendly order.

    SELECT columns FROM table WHERE condition GROUP BY cols HAVING group_condition ORDER BY cols LIMIT n. Logical processing order is: FROM → WHERE → GROUP BY → HAVING → SELECT → ORDER BY → LIMIT.

  12. How do INSERT, UPDATE, and DELETE statements differ in their basic syntax and effect?

    INSERT INTO t (cols) VALUES (...) adds new rows. UPDATE t SET col = val WHERE cond modifies existing rows matching the condition. DELETE FROM t WHERE cond removes rows matching the condition. Omitting WHERE affects all rows.

  13. What is the difference between DELETE and TRUNCATE?

    DELETE is a DML statement that removes rows one by one (can use WHERE, fires triggers, is logged, is transactional/rollbackable). TRUNCATE is a DDL statement that quickly removes all rows, resets identity counters, and is typically not row-by-row logged.

  14. Explain the difference between an INNER JOIN and a LEFT OUTER JOIN.

    INNER JOIN returns only rows where the join condition matches in both tables. LEFT OUTER JOIN returns all rows from the left table plus matching right-table rows, filling unmatched right columns with NULL.

  15. What does a FULL OUTER JOIN return, and how does a CROSS JOIN differ?

    FULL OUTER JOIN returns all rows from both tables, with NULLs where either side has no match. CROSS JOIN returns the Cartesian product—every row of the first table paired with every row of the second, producing $m \times n$ rows.

  16. What is a self-join and when is it used?

    A self-join joins a table to itself using table aliases. It is used to relate rows within the same table, such as finding an employee's manager when both are rows in an employees table (e.g., e.manager_id = m.employee_id).

  17. Distinguish a correlated subquery from a non-correlated (independent) subquery.

    A non-correlated subquery runs once independently and its result is used by the outer query. A correlated subquery references columns from the outer query and is conceptually re-evaluated for each outer row, e.g., using EXISTS or a comparison per row.

  18. What is the difference between IN, EXISTS, and a JOIN for matching rows across tables?

    IN tests membership in a subquery's result set. EXISTS returns true if the correlated subquery yields any row (often faster, short-circuits). A JOIN combines columns and can multiply rows on many-to-many matches, whereas EXISTS/IN filter without duplicating.

  19. Name the five standard SQL aggregate functions and what each computes.

    COUNT (number of rows/values), SUM (total of numeric values), AVG (arithmetic mean), MIN (smallest value), and MAX (largest value). By default they ignore NULLs; COUNT(*) counts all rows including those with NULLs.

  20. What is the crucial rule relating GROUP BY to the SELECT list, and how does HAVING differ from WHERE?

    Every non-aggregated column in SELECT must appear in GROUP BY. WHERE filters individual rows before grouping; HAVING filters groups after aggregation, so HAVING can reference aggregate functions like COUNT(*) > 5 while WHERE cannot.

Show the other 31 Databases and Data Modeling flashcards
  1. How does COUNT(*) differ from COUNT(column) and COUNT(DISTINCT column)?

    COUNT(*) counts all rows. COUNT(column) counts rows where that column is non-NULL. COUNT(DISTINCT column) counts the number of distinct non-NULL values in the column.

  2. What is a window function and how does it differ from a GROUP BY aggregate?

    A window function performs a calculation across a set of rows (a 'window') related to the current row via an OVER clause, but returns a value for every row without collapsing them. GROUP BY aggregates collapse each group into a single output row.

  3. Explain the roles of PARTITION BY and ORDER BY within an OVER() clause.

    PARTITION BY divides rows into independent groups within which the window function is computed separately (like a per-group reset). ORDER BY defines the ordering of rows inside each partition, which matters for ranking and running/cumulative calculations.

  4. Differentiate the ranking window functions ROW_NUMBER, RANK, and DENSE_RANK.

    ROW_NUMBER assigns a unique sequential number regardless of ties. RANK gives tied rows the same rank but leaves gaps afterward (e.g., 1,1,3). DENSE_RANK gives tied rows the same rank with no gaps (e.g., 1,1,2).

  5. What do the LAG and LEAD window functions do?

    LAG(col, n) returns the value of the column from n rows before the current row within the partition; LEAD(col, n) returns the value n rows after. They are used to compare a row with previous or following rows, e.g., period-over-period differences.

  6. What is a database view, and what distinguishes a materialized view from a standard view?

    A view is a named, stored SELECT query that behaves like a virtual table; it holds no data and is computed on access. A materialized view physically stores the query result on disk and must be refreshed to reflect underlying data changes, trading freshness for read speed.

  7. What is a stored procedure and how does it differ from a function in SQL?

    A stored procedure is a precompiled set of SQL statements stored in the database and invoked with CALL/EXECUTE; it can perform actions and return multiple results via output parameters. A function returns a single value (or table) and can typically be used inside SQL expressions.

  8. What is a database trigger?

    A trigger is a stored procedure that automatically executes in response to a table event—BEFORE or AFTER an INSERT, UPDATE, or DELETE. Triggers are used to enforce complex rules, maintain audit logs, or keep derived data consistent.

  9. In Entity-Relationship modeling, define entity, attribute, and relationship.

    An entity is a real-world object or concept about which data is stored (becomes a table). An attribute is a property of an entity (becomes a column). A relationship is an association between entities (e.g., 'a customer places an order'), often implemented via foreign keys.

  10. What are the three cardinality types of relationships in ER modeling?

    One-to-one (1:1), one-to-many (1:N), and many-to-many (M:N). A 1:N is implemented with a foreign key on the 'many' side; an M:N requires a junction/associative table holding foreign keys to both entities.

  11. What is a weak entity in ER modeling?

    A weak entity cannot be uniquely identified by its own attributes alone and depends on a related 'strong' (owner) entity. Its full key is a partial key combined with the owner's key, and it is connected by an identifying relationship.

  12. Define First Normal Form (1NF).

    A relation is in 1NF if every attribute holds only atomic (indivisible) single values, there are no repeating groups or arrays within a column, and each row is unique. Essentially, no multivalued or composite cells.

  13. Define Second Normal Form (2NF).

    A relation is in 2NF if it is in 1NF and every non-key attribute is fully functionally dependent on the whole primary key—there are no partial dependencies on part of a composite key. It becomes relevant only when the primary key is composite.

  14. Define Third Normal Form (3NF).

    A relation is in 3NF if it is in 2NF and has no transitive dependencies—no non-key attribute depends on another non-key attribute. Every non-key attribute must depend only on the primary key, informally 'the key, the whole key, and nothing but the key.'

  15. What is Boyce-Codd Normal Form (BCNF) and how does it strengthen 3NF?

    BCNF requires that for every non-trivial functional dependency $X \to Y$, $X$ must be a superkey. It is stricter than 3NF because it removes anomalies that remain when a non-key attribute determines part of a candidate key.

  16. What is a functional dependency, written $X \to Y$?

    A functional dependency $X \to Y$ means that each value of attribute set $X$ uniquely determines the value of attribute set $Y$; whenever two tuples agree on $X$ they must agree on $Y$. Functional dependencies are the basis for normalization.

  17. What update anomalies does normalization aim to eliminate?

    Insertion anomalies (cannot add data without unrelated data), update anomalies (redundant data must be changed in many places, risking inconsistency), and deletion anomalies (removing a row unintentionally loses other needed facts).

  18. What is denormalization and what are its main tradeoffs?

    Denormalization deliberately introduces redundancy (e.g., duplicated columns, precomputed aggregates) to reduce expensive joins and speed reads. The tradeoff is faster reads versus slower/complex writes, extra storage, and the risk of data inconsistency that must be managed.

  19. When is denormalization typically justified over a fully normalized schema?

    When read performance is critical and reads vastly outnumber writes, when joins are expensive at scale, or in analytical/reporting (OLAP) systems and caches. Normalized schemas are preferred for write-heavy transactional (OLTP) systems needing integrity.

  20. What is a schema migration and why is it version-controlled?

    A schema migration is a controlled, incremental change to the database structure (adding tables/columns, altering types, adding indexes). It is version-controlled so changes are reproducible, ordered, reviewable, and applied consistently across environments alongside application code.

  21. What is the difference between an 'up' migration and a 'down' (rollback) migration?

    An 'up' migration applies a schema change to move the database forward to a new version. A 'down' migration reverses that change to roll back to the previous version. Paired scripts allow safe forward and backward transitions.

  22. Describe the expand-and-contract (parallel change) pattern for zero-downtime migrations.

    Expand: add the new schema element (e.g., new column) without removing the old. Then deploy code that writes to both and backfill data. Contract: once all code uses the new element, remove the old one. This avoids breaking running application versions.

  23. What is a document store, and how does MongoDB represent data?

    A document store is a NoSQL database that stores semi-structured, self-contained documents. MongoDB stores documents as BSON (binary JSON) with flexible schemas, grouped into collections; related data can be nested (embedded) rather than split across joined tables.

  24. In MongoDB, contrast embedding documents versus referencing them.

    Embedding nests related data inside a single document for fast atomic reads of a whole entity (good for one-to-few, tightly coupled data). Referencing stores an ObjectId pointer to another document and requires a lookup/join, preferred for large, shared, or independently growing data.

  25. What is Redis and what core data structures does it provide?

    Redis is an in-memory key-value store known for very low latency. Beyond simple strings, it supports rich value types: lists, sets, sorted sets (with scores), hashes, bitmaps, HyperLogLogs, and streams, making it useful for caching, queues, leaderboards, and counters.

  26. Name common use cases where Redis is chosen as a key-value store.

    Caching (with TTL expiry), session storage, rate limiting, real-time leaderboards (sorted sets), pub/sub messaging, distributed locks, and job queues. Its in-memory design gives speed but limits total data to available RAM (with optional persistence).

  27. What kind of database is Cassandra, and what is its data model built around?

    Cassandra is a wide-column (column-family) NoSQL store designed for massive write throughput and horizontal scale. Its data model is query-driven: tables are organized around a partition key (which determines data distribution) plus clustering columns that order rows within a partition.

  28. How does Cassandra achieve high availability and scalability architecturally?

    Cassandra uses a masterless (peer-to-peer) ring architecture with consistent hashing to partition data across nodes, tunable replication factor, and tunable consistency levels (e.g., ONE, QUORUM, ALL). There is no single point of failure, favoring availability and partition tolerance.

  29. What is a graph database like Neo4j optimized for, and what are its core elements?

    A graph database is optimized for highly connected data and relationship traversal. Neo4j stores nodes (entities) and edges/relationships (typed, directed connections), both carrying properties. It excels at queries like shortest path, recommendations, and social/network analysis using the Cypher query language.

  30. According to the CAP theorem, what tradeoff must a distributed database make during a network partition?

    CAP states a distributed system can guarantee at most two of Consistency, Availability, and Partition tolerance. Since partitions are unavoidable, during one the system must choose between Consistency (reject/stale-free) and Availability (respond, possibly with stale data)—i.e., CP versus AP.

  31. List key criteria for choosing SQL (relational) versus NoSQL databases.

    Choose SQL for structured data, complex queries/joins, strong ACID transactions, and stable schemas (e.g., PostgreSQL, MySQL). Choose NoSQL for flexible/evolving schemas, very large scale, high write throughput, or specialized access patterns—document, key-value, wide-column, or graph—often trading strict consistency for scalability.

Backend Development Databases and Data Modeling FAQ

What is in the Backend Development Databases and Data Modeling syllabus?

Backend Development Databases and Data Modeling is split into 7 chapters: Relational Databases, SQL Query Language, Data Modeling and Normalization, NoSQL Databases, Transactions and Concurrency, ORMs and Query Builders and Database Performance and Scaling. Together they contain 31 topics.

How many chapters are in Backend Development Databases and Data Modeling?

7 chapters, containing 31 topics. The largest chapter is SQL Query Language, with 5 topics.

Are there flashcards for Backend Development Databases and Data Modeling?

Yes — a 51-card Databases and Data Modeling deck, printed in full in the flashcards section of this page and available in the Examius app with spaced repetition. The free plan covers one exam of your choice, including its flashcards; Examius Pro, a one-time purchase, unlocks every other exam and deck.