Database Labs

Interactive exercises bridging database theory and execution.

Database Labs

Understanding database concepts is only the first step. To truly master them, you must bridge the gap between abstract theory and practical execution.

Work in Progress

Lab exercises are currently conceptual. A fully interactive sandbox environment will be available soon.

The Theory → Execution Loop

In taichi112.works, we believe in a tight feedback loop:

  1. Concept: Learn the core principle.
  2. Execution: Write the code (or mental model).
  3. Result: Observe the structural or performance impact.

Lab Roadmap

These workshop-style tasks are designed to guide you through practical database engineering. No real database migrations are required yet—these are conceptual exercises.

Workshop Overview

LabTheory FocusExpected OutputSafety Note
1. Data Modeling BasicsRelationships & KeysSketch of tables and columns.No code execution.
2. Schema Design ReviewNormalizationRedesigned multi-table layout.No code execution.
3. Query PerformanceN+1 Problem & JoinsMental map of batched queries.Read-only concepts.
4. Agent-Safe WorkflowHuman-in-the-loopDiagram of approval flow.Prevent destructive queries.

Scenario: Project Tracker

To tie all these concepts together, consider a simple Project Tracker application.

A user wants to track projects and the tasks within them. As we build this, we encounter every major database concept:

  • We identify the core objects we need to store (User, Project, Task).
  • We design how they connect (a User owns Projects, a Project contains Tasks).
  • We enforce rules (Tasks must have titles, Projects belong to a valid User).
  • We ensure the system doesn't lose data if the server crashes while saving.
  • We make sure the dashboard loads instantly even with thousands of tasks.
  • We design a workflow so an AI assistant can help manage projects without accidentally deleting everything.
StepWhat we doKnowledge usedRelated pageWhy it matters
1. IdeationIdentify EntitiesEntity, Table, ColumnOverviewDecides what data to store.
2. DesignConnect EntitiesPrimary Key, Foreign KeySchema DesignDefines structural relationships.
3. ValidationEnforce RulesConstraint, NormalizationFoundationsPrevents invalid or duplicate data.
4. SafetyProtect OperationsTransaction, RollbackReliabilityEnsures data integrity during failures.
5. SpeedOptimize QueriesIndex, Join, N+1 QueryPerformanceKeeps the application fast at scale.
6. AI AgentsSafe AutomationHuman-in-the-loopAgentic ApplicationsPrevents destructive AI actions.

Knowledge Map

This table summarizes the core vocabulary used throughout the database modules.

KeywordUsed whenRead moreWhy it matters
Entity / RelationshipIdeation & DesignSchema DesignDefines what data exists and how it connects.
Primary Key / Foreign KeyConnecting tablesSchema DesignLinks data together securely.
ConstraintValidating dataFoundationsEnforces rules so bad data never saves.
Transaction / RollbackHandling failuresReliabilityEnsures all-or-nothing data operations.
Index / N+1 Query / PaginationSpeeding up queriesPerformanceKeeps applications fast at scale.
Human Approval / Read-only AccessAI workflowsAgentic ApplicationsProtects databases from autonomous destruction.

Lab 1: Data Modeling Basics

Goal: Design a simple relationship between Users and Projects.

  • Mental Exercise: Sketch out what tables and columns are needed to track which users own which projects.
  • Execution: Define the Primary Keys and Foreign Keys needed to make this relationship reliable.

Lab 2: Schema Design Review

Goal: Identify flaws in an existing schema.

  • Mental Exercise: Look at a table that stores User data and Project data in the same row (violating normalization).
  • Execution: Redesign the table into two separate, related tables to prevent data duplication.

Lab 3: Query Performance Thinking

Goal: Retrieve nested data efficiently without causing bottlenecks.

  • Mental Exercise: How do we get a user and all of their active projects in a single step without overwhelming the database (avoiding the N+1 problem)?
  • Execution: Understand the difference between querying in a loop versus using a proper database Join.

Lab 4: Agent-Safe Database Workflow

Goal: Design a safe approval flow for an AI agent.

  • Mental Exercise: An AI agent proposes a dangerous query: DELETE FROM Users WHERE last_login < 2020. This query is strictly for review training and should not be executed directly.
  • Execution: Outline the conceptual human-in-the-loop review steps required to intercept, review, and reject this destructive query before it ever reaches the database.

Next Step: Return to the Database Systems Overview to review the core concepts.