Skip to main content

Schemas and Data Modeling

Schemas in Dubhe Engine define the structure of your game entities and their components, providing a type-safe way to model your application’s data layer.

What are Schemas?

Schemas are the blueprint for your application’s data structure. They define:
  • Components: Data containers that hold specific attributes
  • Systems: Logic that operates on components
  • Entities: Game objects that combine multiple components

Defining Components

Components are the building blocks of your entities. Here’s how to define them:

Schema Configuration

Define your schemas in the dubhe.config.js file:

Common Data Types

Dubhe Engine supports all Move primitive types and collections:

Relationships Between Components

You can model relationships between entities using references:

Schema Generation

The Dubhe CLI automatically generates Move code from your schema definitions:

Best Practices

Component Design Principles
  1. Single Responsibility: Each component should represent one logical aspect
  2. Composition over Inheritance: Combine components to create complex entities
  3. Data Normalization: Avoid duplicating data across components
  4. Performance Considerations: Keep frequently accessed data in separate components

Example: Game Character

Migration and Updates

When you need to update schemas:
  1. Add new fields (backwards compatible)
  2. Create migration functions for breaking changes
  3. Version your schemas for complex applications

Next Steps

ECS Architecture

Learn about Entity Component Systems

Contract Development

Build your first Move contract