Logo

Cake Planner

Backend

Database Schema

The Cake Planner Backend uses SQLite as its relational database. The database file is typically located at data/cakeplanner.sqlite.


Table of Contents


Description

This document describes the database schema for the Cake Planner Backend. The application uses an SQLite database.

Database Schema (overview)

The database is normalized to ensure data integrity.

Entity Relationship Diagram (ERD)

ERD

Tables

users

Stores user account information, including authentication details and preferences.

ColumnTypeDescription
idTEXTPrimary Key (UUID).
full_nameTEXTFull name of the user.
emailTEXTUnique email address.
password_hashTEXTArgon2id password hash.
languageTEXTPreferred UI language (e.g., 'en', 'de').
email_languageTEXTPreferred language for emails.
totp_secretTEXTSecret for 2FA (if enabled).
is_activeINTEGER1 if active, 0 if inactive.
is_adminINTEGER1 if global admin, 0 otherwise.
must_change_passwordINTEGER1 if user must change password next login.
temp_password_hashTEXTHash of a temporary password (forgot password flow).
temp_password_expiryTEXTExpiration timestamp of the temp password.
last_login_atTEXTTimestamp of last login.
created_atTEXTCreation timestamp.
updated_atTEXTUpdate timestamp.

groups

Represents groups (departments, teams) that can organize cake events.

ColumnTypeDescription
idTEXTPrimary Key (UUID).
nameTEXTName of the group.
descriptionTEXTOptional description.
created_atTEXTCreation timestamp.

group_members

Link table defining the many-to-many relationship between users and groups.

ColumnTypeDescription
user_idTEXTForeign Key to users.id.
group_idTEXTForeign Key to groups.id.
roleTEXTRole in group (e.g., 'member', 'admin').
joined_atTEXTTimestamp when user joined.

Primary Key: Composite (user_id, group_id)

events

Represents a "Cake Event" where a user brings a cake on a specific date.

ColumnTypeDescription
idTEXTPrimary Key (UUID).
group_idTEXTThe group this event belongs to.
baker_idTEXTThe user bringing the cake.
event_dateTEXTDate of the event (YYYY-MM-DD).
descriptionTEXTDescription of the cake/event.
photo_pathTEXTPath to the cover image.
created_atTEXTCreation timestamp.

ratings

Allows users to rate and comment on events.

ColumnTypeDescription
idTEXTPrimary Key (UUID).
event_idTEXTForeign Key to events.id.
rater_idTEXTForeign Key to users.id (the rater).
rating_valueINTEGER1 to 5 stars.
commentTEXTOptional text comment.
created_atTEXTCreation timestamp.

Constraints: A user can rate each event only once (UNIQUE event_id, rater_id).

event_photos

Stores additional photos uploaded to the gallery of an event.

ColumnTypeDescription
event_idTEXTForeign Key to events.id.
user_idTEXTForeign Key to users.id (uploader).
photo_pathTEXTPath to the uploaded photo.
uploaded_atTEXTUpload timestamp.

Primary Key: Composite (event_id, user_id). Currently, users can upload only one photo per event gallery (excluding the cover photo if they are the baker, which is stored in events).

Migration System

Database migrations are handled automatically in DatabaseManager::migrate().