Database schema and entity relationships for Pixel Create
This ERD represents the database structure for the Pixel Create pixel art application, designed to support local persistence using Room Database with potential for cloud synchronization.
For detailed descriptions and source code links for all entity classes and DAO interfaces, see the Entity Classes page.
Stores user account information, authentication details, and personalized settings that persist across devices.
Key Attributes:
userId: Primary key, unique identifierusername, email: Account credentialsdefaultCanvasWidth/Height: User preference for new projectsthemePreference: Light/dark mode settinggridVisibility, zoomSensitivity: Tool preferencesRelationships:
The central entity representing a pixel art creation. Contains metadata about canvas size, timestamps, and thumbnail preview.
Key Attributes:
projectId: Primary keyprojectName: User-defined namecanvasWidth/Height: Pixel dimensions of the canvasthumbnailImage: Small preview for gallery displayisDeleted: Soft-delete flag for recoveryRelationships:
Represents individual drawing layers within a project, supporting complex artwork with stacking and visibility controls.
Key Attributes:
layerId: Primary keylayerOrder: Stacking position (Z-index)isVisible: Show/hide toggleisLocked: Prevent editingopacity: Transparency level (0.0 - 1.0)Relationships:
Stores individual pixel color data. Each pixel is tied to a specific layer and position.
Key Attributes:
pixelId: Primary keyxCoordinate, yCoordinate: Position on the canvascolorValue: ARGB or hex color valuelastModified: Timestamp for tracking changesRelationships:
Design Note: For large canvases, storing each pixel individually may require optimization (e.g., sparse storage for transparent pixels, compression, or delta encoding).
User-created color collections for consistent artwork styling.
Key Attributes:
paletteId: Primary keypaletteName: User-defined nameisDefault: Flag for system-provided paletteslastUsed: For sorting recently used palettesRelationships:
Individual colors within a palette.
Key Attributes:
colorId: Primary keycolorValue: ARGB or hex representationcolorOrder: Display order within palettecolorName: Optional user-defined label (e.g., “Sky Blue”)Relationships:
Periodic backups of project state to prevent data loss.
Key Attributes:
snapshotId: Primary keysnapshotData: Serialized project state (could be JSON or binary)fileSize: Storage trackingRelationships:
Design Note: Consider retention policy (e.g., keep last 10 snapshots, delete older than 30 days).
Logs every export operation for tracking and re-export functionality.
Key Attributes:
exportId: Primary keyfileName: Generated or user-specified namefilePath: Location in device storagefileFormat: PNG, JPG, etc.resolution, scaleFactor: Export dimensionsRelationships:
| Relationship | Cardinality | Description |
|---|---|---|
| User → Project | 1:N | One user creates many projects |
| User → Palette | 1:N | One user creates many palettes |
| Project → Layer | 1:N | One project has many layers (minimum 1) |
| Layer → Pixel | 1:N | One layer contains many pixels |
| Project → AutosaveSnapshot | 1:N | One project has many snapshots |
| Project → ExportHistory | 1:N | One project has many export records |
| Palette → PaletteColor | 1:N | One palette contains many colors (minimum 1) |
The Room database schema is stored in:
app/schemas/edu.cnm.deepdive.myproject.service.LocalDatabase/1.json
DDL output location (configured in build.gradle.kts):
docs/sql/ddl.sql
The schema follows 3NF (Third Normal Form):
projectId in Layer, AutosaveSnapshot, ExportHistorylayerId in PixelpaletteId in PaletteColor(xCoordinate, yCoordinate, layerId) for pixel lookupsuserId in Project and PaletteIf animation features are added:
If collaboration features are added: