Skip to main content

Foundations of Schema Design in CockroachDB

In this course, we lay a foundation for best practices in schema design by giving you an overview of the unique CockroachDB schema features available. We then highlight some common design patterns and anti-patterns that are relevant when designing a schema for CockroachDB.

  • Course Number

    foundations-schema-design-cockroachdb
  • Self-Paced

  • Estimated Effort

    3 hours/week

About This Course

This course represents the first steps of learning about Schema Design with CockroachDB.

There are many ways to organize information in a database. CockroachDB is a distributed SQL database, which brings new capabilities to the world of relational SQL databases. How you organize information through schema design in CockroachDB can have positive or negative impacts on, for example, query performance or inserting new data. In this course, we lay a foundation for best practices in schema design by giving you an overview of the unique CockroachDB schema features available. We then highlight some common design patterns and anti-patterns that are relevant when designing a schema for CockroachDB.

Knowing what's available, and how to use it, will help you build better schema and provide you with the basic vocabulary of CockroachDB.

If you need help, our documentation can be used for reference on concepts and activities like how to create a table or definitions of the different data types.

The CockroachDB Community Slack has a #cockroach-university channel where you can interact with other learners and the Cockroach Labs Training Team directly.

Good luck, and enjoy the course!

Prerequisites

Before taking this course, you should have some familiarity with SQL. If you’ve never used CockroachDB before, we suggest you take our Practical First Steps with CockroachDB course.

Detailed course outline

  • Welcome
  • Lab environment setup
  • Chapter 1: Foundations 
    • Notes on Specialized Data Types in CockroachDB
    • Quiz: Notes on Specialized Data Types
    • CockroachDB Functions and Special Features
    • Quiz: CockroachDB Functions and Special Features
    • Column Constraints in CockroachDB
    • (Optional) Stories from the Field: Foreign Keys
    • JSON, Arrays, Inverted Indexes, and Computed Columns
    • Quiz: JSON, Arrays, Inverted Indexes, and Computed Columns
    • (Optional) Stories From the Field: Column Types
  • Chapter 2: Patterns and Anti-Patterns
    • Anti-Pattern: Auto-Incrementing Primary Key
    • Quiz: Primary Key
    • Lab: Creating a simple table
    • Lab: Creating a Table with No Explicit Primary Key
    • Lab: Adding an Explicit Primary Key to a Table
    • Lab: Fix a Hotspot with a Compound Primary Key
    • Creating a Hash-Sharded Table
    • Hash-Sharded Indexes: Advanced Considerations
    • Quiz: Hash-Sharded Primary Key/Primary Index
    • (Optional) Stories from the Field: Poor Choices
    • Lab: Hash-Sharding an Index
  • Final exam
Enroll