🌍 SQL & Databases · subject
SQL & Databases Data Modeling and Database Design Syllabus
The Data Modeling and Database Design syllabus for SQL & Databases in full: 6 chapters and 23 topics, every one listed below, plus 51 Data Modeling and Database Design flashcards with answers.
Data Modeling and Database Design syllabus: all 6 chapters
Expand any chapter to see its topics and sub-topics.
-
Conceptual and Logical Modeling
4 topics- Entity-Relationship Modeling
- ER Diagram Notations
- Weak Entities and Identifying Relationships
- Generalization and Specialization
-
Normalization
5 topics- Functional Dependencies
- First Through Third Normal Form
- Boyce-Codd Normal Form (BCNF)
- Higher Normal Forms (4NF, 5NF)
- Anomalies and Redundancy
-
Denormalization and Trade-offs
3 topics- When to Denormalize
- Read vs Write Trade-offs
- Materialized Aggregates
-
Physical Database Design
4 topics- Mapping Logical to Physical Schema
- Choosing Data Types and Storage
- Partitioning Strategies
- Naming Conventions and Standards
-
Schema Patterns and Anti-Patterns
4 topics- Many-to-Many and Junction Tables
- Modeling Hierarchies
- Slowly Changing Dimensions
- Common Anti-Patterns (EAV, Polymorphic FKs)
-
Schema Evolution and Migrations
3 topics- Versioned Migrations
- Backward-Compatible Changes
- Zero-Downtime Schema Changes
SQL & Databases Data Modeling and Database Design flashcards — 51 questions with answers
What is Entity-Relationship (ER) modeling?
A conceptual, top-down data-modeling technique that represents the real-world problem domain as a collection of entities (things of interest), the attributes that describe them, and the relationships that connect them, independent of any specific DBMS or physical implementation.
In ER modeling, define an entity, an attribute, and a relationship.
An entity is a distinguishable real-world object or concept about which data is stored (e.g., Student). An attribute is a property that describes an entity or relationship (e.g., Name). A relationship is an association among two or more entities (e.g., Student enrolls in Course).
Distinguish an entity type from an entity instance (entity set).
An entity type is the schema-level definition/template (e.g., Employee with attributes ID, Name). An entity instance is a single occurrence of that type. The entity set is the collection of all instances of the entity type at a given time.
List the main categories of attributes in ER modeling.
Simple (atomic) vs. composite; single-valued vs. multivalued; stored vs. derived; and key attributes (uniquely identify an instance). A null value may indicate not-applicable, unknown, or missing.
What is a derived attribute versus a stored attribute?
A stored attribute's value is physically kept in the database. A derived attribute's value is computed from other attributes when needed (e.g., Age derived from DateOfBirth), so it is not stored to avoid redundancy.
In classic Chen ER notation, what shapes represent entities, attributes, and relationships?
Rectangles represent entities, ellipses (ovals) represent attributes, and diamonds represent relationships. Lines connect them; double/dashed ovals denote multivalued/derived attributes, and underlined attribute names denote keys.
How are multivalued and composite attributes drawn in Chen notation?
A multivalued attribute is a double-lined ellipse; a derived attribute is a dashed ellipse; a composite attribute is an ellipse connected to its component sub-attribute ellipses; a key attribute has its name underlined.
What does cardinality ratio mean, and what are its four standard types in binary relationships?
Cardinality ratio specifies the maximum number of relationship instances an entity can participate in. The four types are one-to-one ($1{:}1$), one-to-many ($1{:}N$), many-to-one ($N{:}1$), and many-to-many ($M{:}N$).
In ER modeling, distinguish total participation from partial participation.
Total (mandatory) participation means every entity instance must participate in the relationship, drawn as a double line. Partial (optional) participation means some instances may not participate, drawn as a single line. Together with cardinality this forms (min, max) constraints.
What do the (min, max) participation constraints on an entity in a relationship express?
They give the minimum and maximum number of relationship instances a single entity instance can take part in. min $=0$ means partial participation; min $\geq 1$ means total participation; max gives the cardinality limit.
What is a weak entity, and how does it differ from a strong (regular) entity?
A weak entity cannot be uniquely identified by its own attributes alone and has no key of its own; it depends on an owner (strong/identifying) entity for its existence and identification. A strong entity has its own primary key and exists independently.
Define an identifying relationship and a partial key for a weak entity.
An identifying (existence-dependent) relationship is the association that connects a weak entity to its owner strong entity. A partial key (discriminator) is the set of attributes that uniquely identifies weak-entity instances only within the context of a single owner.
How is the full primary key of a weak entity formed?
By combining the primary key of its owner (identifying) entity with the weak entity's own partial key (discriminator): $\text{PK}_{\text{weak}} = \text{PK}_{\text{owner}} \cup \text{partial key}$.
How are weak entities and identifying relationships drawn in Chen notation?
A weak entity is a double-lined rectangle, the identifying relationship is a double-lined diamond, the partial key attribute has a dashed underline, and the weak entity has total participation (double line) in the identifying relationship.
What is generalization in ER/EER modeling?
A bottom-up abstraction process that combines two or more lower-level entity types sharing common attributes into a single higher-level (generalized) superclass entity type, factoring out the shared attributes.
What is specialization, and how does it relate to inheritance?
Specialization is the top-down process of defining subclasses (subtypes) of a superclass based on distinguishing characteristics. Subclasses inherit all attributes and relationships of the superclass and add their own specific ones (attribute/relationship inheritance).
Define the disjoint vs. overlapping constraint in specialization/generalization.
The disjointness constraint states whether an entity may belong to more than one subclass. Disjoint (d) means an instance is a member of at most one subclass; overlapping (o) means an instance may belong to several subclasses simultaneously.
Define the total vs. partial completeness constraint in a specialization.
Completeness specifies whether every superclass member must belong to some subclass. Total (double line) requires every superclass instance to be a member of at least one subclass; partial (single line) allows a superclass instance to belong to none.
What is a functional dependency (FD)?
A constraint between two sets of attributes; $X \to Y$ (X functionally determines Y) means that any two tuples agreeing on the values of X must also agree on the values of Y. X is the determinant.
State Armstrong's three inference axioms for functional dependencies.
Reflexivity: if $Y \subseteq X$ then $X \to Y$. Augmentation: if $X \to Y$ then $XZ \to YZ$. Transitivity: if $X \to Y$ and $Y \to Z$ then $X \to Z$. These are sound and complete for deriving all FDs.
Show the other 31 Data Modeling and Database Design flashcards
What is the closure $X^{+}$ of a set of attributes, and what is it used for?
$X^{+}$ is the set of all attributes functionally determined by $X$ under a given set of FDs. It is used to test whether $X \to Y$ holds (check $Y \subseteq X^{+}$) and to determine whether $X$ is a superkey (when $X^{+}$ = all attributes).
Distinguish full functional dependency, partial dependency, and transitive dependency.
Full FD: $Y$ depends on the whole of a composite key $X$, not any proper subset. Partial dependency: $Y$ depends on only part of a composite candidate key. Transitive dependency: $X \to Z$ holds via a non-key attribute ($X \to Y \to Z$ where $Y$ is non-prime).
Define prime and non-prime (non-key) attributes.
A prime attribute is a member of at least one candidate key of the relation. A non-prime (non-key) attribute is one that belongs to no candidate key. These definitions underpin the 2NF, 3NF, and BCNF conditions.
State the requirement for First Normal Form (1NF).
A relation is in 1NF if every attribute contains only atomic (indivisible) single values and there are no repeating groups or multivalued/composite attributes; each cell holds one value from its domain and each row is unique.
State the requirement for Second Normal Form (2NF).
A relation is in 2NF if it is in 1NF and every non-prime attribute is fully functionally dependent on every candidate key (i.e., no partial dependency of a non-prime attribute on part of a composite key).
State the requirement for Third Normal Form (3NF).
A relation is in 3NF if it is in 2NF and has no transitive dependency of a non-prime attribute on a candidate key. Equivalently, for every nontrivial FD $X \to A$, either $X$ is a superkey or $A$ is a prime attribute.
State the condition for Boyce-Codd Normal Form (BCNF).
A relation is in BCNF if for every nontrivial functional dependency $X \to Y$, the determinant $X$ is a superkey. BCNF is stricter than 3NF because it drops the 3NF allowance that $A$ may be a prime attribute.
How does BCNF differ from 3NF, and what is a key trade-off?
3NF permits an FD $X \to A$ where $A$ is prime even if $X$ is not a superkey; BCNF forbids this, requiring every determinant to be a superkey. Trade-off: a 3NF decomposition is always dependency-preserving and lossless, but a BCNF decomposition may not preserve all dependencies.
What is Fourth Normal Form (4NF), and what dependency does it address?
4NF addresses multivalued dependencies (MVDs). A relation is in 4NF if it is in BCNF and for every nontrivial MVD $X \twoheadrightarrow Y$, $X$ is a superkey. It eliminates redundancy from independent multivalued facts stored in one relation.
Define a multivalued dependency (MVD).
$X \twoheadrightarrow Y$ holds if, for a fixed value of $X$, the set of $Y$ values is independent of the values of the remaining attributes. MVDs represent independent one-to-many facts and generalize functional dependencies.
What is Fifth Normal Form (5NF / Project-Join Normal Form), and what dependency does it address?
5NF addresses join dependencies. A relation is in 5NF if it cannot be losslessly decomposed into smaller relations except by projections implied by its candidate keys; every join dependency is a consequence of the candidate keys, eliminating remaining redundancy.
What are the three main modification anomalies caused by redundancy?
Insertion anomaly (cannot add data without unrelated missing data), deletion anomaly (removing a row unintentionally loses other facts), and update anomaly (a redundant value must be changed in many places, risking inconsistency).
What are the two essential properties a good relational decomposition must satisfy?
Lossless-join (non-additive) property: reconstructing by natural join yields exactly the original relation with no spurious tuples. Dependency preservation: the FDs of the original can be enforced by checking constraints on the individual decomposed relations.
State the lossless-join test for a binary decomposition of $R$ into $R_1$ and $R_2$.
The decomposition is lossless if and only if the common attributes form a key of at least one relation: $(R_1 \cap R_2) \to R_1$ or $(R_1 \cap R_2) \to R_2$. Equivalently, the shared attributes are a superkey of $R_1$ or of $R_2$.
What is denormalization, and why is it done?
Denormalization deliberately introduces controlled redundancy into a normalized schema (e.g., duplicating columns, pre-joining tables, storing derived values) to improve read/query performance by reducing the number of joins and aggregations at query time.
When is denormalization typically appropriate?
When workloads are read-heavy, queries repeatedly join or aggregate the same tables, latency requirements are strict, data changes infrequently, and the extra cost/risk of maintaining redundant data (via triggers, jobs, or application logic) is acceptable.
Summarize the read vs. write trade-off between normalization and denormalization.
Normalization optimizes writes and integrity (each fact stored once, minimal update cost, no anomalies) but can slow reads that need many joins. Denormalization optimizes reads (fewer joins) at the expense of slower/more complex writes and the risk of inconsistency.
What is a materialized aggregate (materialized view), and how does it differ from a regular view?
A materialized view physically stores the precomputed result (e.g., aggregated totals) on disk, giving fast reads. A regular (virtual) view stores only the query definition and recomputes results on each access. The materialized copy must be refreshed to stay current.
What are the main refresh strategies for materialized aggregates, and their trade-off?
Complete refresh (recompute all), incremental/fast refresh (apply only changes via logs), on-commit, and on-demand/scheduled refresh. Trade-off: fresher data means more maintenance overhead on writes; staleness reduces write cost but risks serving out-of-date aggregates.
What is the difference between a logical schema and a physical schema?
The logical schema is the DBMS-independent design of relations, attributes, keys, and constraints (what data and relationships exist). The physical schema specifies how data is actually stored: file organization, data types, indexes, partitioning, and storage parameters.
Give the core rules for mapping ER constructs to a relational (physical) schema.
Each strong entity becomes a table with its attributes and primary key. Weak entities become tables including the owner's PK as part of a composite key. $1{:}N$ relationships add the PK of the 1-side as a foreign key on the N-side; $M{:}N$ relationships and multivalued attributes become separate tables.
What guidelines govern choosing appropriate data types and storage sizes for columns?
Pick the smallest type that safely holds the full value range and precision; use exact numeric (DECIMAL) for money instead of floating point; match string length to real needs; use native DATE/TIMESTAMP for temporal data; and prefer domain-accurate types to enforce integrity and reduce storage and I/O.
Why should exact numeric types be preferred over floating-point for monetary values?
Floating-point types (FLOAT/REAL) store values as binary approximations, so amounts like $0.10$ cannot be represented exactly and rounding errors accumulate. Fixed-precision DECIMAL/NUMERIC stores the exact decimal value, guaranteeing accurate sums and comparisons for currency.
What is table partitioning, and what problem does it solve?
Partitioning splits one logical table into multiple smaller physical segments (partitions) based on a partition key, while keeping a single logical view. It improves manageability, query performance via partition pruning, and enables parallelism and cheaper archiving/deletion of whole partitions.
Compare horizontal partitioning with vertical partitioning.
Horizontal partitioning divides a table by rows (each partition holds a subset of rows, same columns), e.g., by date. Vertical partitioning divides by columns (each partition holds a subset of columns for all rows), separating frequently accessed columns from rarely used ones.
Name the common horizontal partitioning strategies and their basis.
Range partitioning (rows assigned by value ranges, e.g., dates), list partitioning (by an explicit set of key values, e.g., region), hash partitioning (by a hash function on the key for even distribution), and composite partitioning (a combination such as range-hash).
State common naming-convention best practices for database schemas.
Use consistent, descriptive names; pick one case style (e.g., snake_case); avoid reserved words and spaces; be consistent with singular vs. plural table names; use meaningful foreign-key names and standard prefixes/suffixes (e.g., _id, pk_, fk_); and avoid abbreviations that obscure meaning.
How is a many-to-many ($M{:}N$) relationship represented in a relational schema?
With a separate junction (associative/bridge/link) table whose primary key is the combination of the foreign keys referencing the two related tables. Each row records one association pairing, plus any attributes describing the relationship itself.
What is a junction table's primary key, and what else can it hold?
Its primary key is typically the composite of the two foreign keys (or a surrogate key with a unique constraint on that pair). Besides the two FKs, it can store relationship attributes such as a quantity, price, role, or timestamp that belong to the association, not to either entity.
Describe the adjacency-list versus path-enumeration models for representing hierarchies.
Adjacency list: each row stores a parent_id foreign key pointing to its immediate parent (simple, but deep traversal needs recursion). Path enumeration: each row stores its full ancestor path as a string (e.g., '/1/4/9/'), making ancestor/descendant queries easy but complicating updates and integrity.
Describe the nested-set and closure-table models for storing hierarchies.
Nested set: each node stores left/right numeric bounds so subtrees are contiguous ranges (fast reads, expensive inserts). Closure table: a separate table stores one row for every ancestor-descendant pair with depth, enabling efficient hierarchy queries and easy updates at the cost of extra storage.
SQL & Databases Data Modeling and Database Design FAQ
What is in the SQL & Databases Data Modeling and Database Design syllabus?
SQL & Databases Data Modeling and Database Design is split into 6 chapters: Conceptual and Logical Modeling, Normalization, Denormalization and Trade-offs, Physical Database Design, Schema Patterns and Anti-Patterns and Schema Evolution and Migrations. Together they contain 23 topics.
How many chapters are in SQL & Databases Data Modeling and Database Design?
6 chapters, containing 23 topics. The largest chapter is Normalization, with 5 topics.
Are there flashcards for SQL & Databases Data Modeling and Database Design?
Yes — a 51-card Data Modeling and Database Design 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.