Step 4: Database Model

This chapter defines the data layer behind pipeline reliability. Step 3 covered operations; Step 4 explains how state is stored, moved, and validated.

4.1 Datastore topology

  1. data/review.db - operational queue and editor-driven lifecycle state.
  2. data/photos_info_revamp.db - local mirror of published catalog rows.
  3. Remote MySQL table photos_info_revamp - website-facing published metadata.

Design intent: run-time decisions happen in local SQLite; remote systems are touched only in approved publish flow.

4.2 Quick field cheat sheet

Use this for fast orientation. Detailed per-column definitions are listed later in the full dictionary.

AreaKey fieldsWhy it matters
Queue identity and routing id, Folder, File_Name, Path, ollama_path Tracks where each image is and which filename/path the pipeline is currently using.
Queue quality and decision QR, QC_Status, Review_Status Determines review readiness, quality class, and whether publish is allowed.
Published record identity id (catalog key), File_Name (upsert key), Path, Thumb_Path Keeps website-facing records stable and prevents duplicate publish entries.
Published metadata Caption, alt_text, Keywords, Location, DateTime, Camera Provides searchability, accessibility, and contextual quality on the website.
Lineage and audit Original_File_Name Maintains traceability from final published asset back to source input name.

Important: review_queue.id is operational only; publish identity is resolved in photos_info_revamp.id.

4.3 Core operational table: review_queue

The table is initialized from data/init/review_queue.sql in the automation repository. A local docs copy is available at docs/review_queue.sql. Each row represents one image moving from ingest through review to publish decision.

Column groups

4.4 Lifecycle semantics in queue rows

Status values are stage-driven and operator-driven. Common states in active code paths include:

Operational rule: queue state should be interpreted together with logs, not as a stand-alone signal.

4.5 Publish-side model and key mapping

During publish, db_uploader.py selects approved rows and writes to remote MySQL using File_Name as the stable unique key for upsert behavior.

Consequence: review_queue.id is an operational ID only; it is not the publish catalog primary key.

A local docs copy of the publish schema is available at docs/photos_info_revamp.sql.

4.6 Auxiliary review ledger

Editor flows can upsert into st_items (when available) for rating and review-history support. This ledger is useful for analysis and future model learning, but it is not required for publish writes.

4.7 Integrity rules to preserve

4.8 Operational SQL diagnostics

-- queue volume by status
SELECT COALESCE(Review_Status, 'NULL') AS status, COUNT(*) AS n
FROM review_queue
GROUP BY COALESCE(Review_Status, 'NULL')
ORDER BY n DESC;

-- pending rows waiting editor decision
SELECT id, File_Name, QC_Status
FROM review_queue
WHERE COALESCE(Review_Status,'Pending')='Pending'
ORDER BY id DESC;

-- approved rows ready for uploader
SELECT id, File_Name, Folder
FROM review_queue
WHERE Review_Status='Approved'
ORDER BY id ASC;

-- error rows requiring triage
SELECT id, File_Name, Review_Status, QC_Status
FROM review_queue
WHERE Review_Status='Error' OR QC_Status IN ('ResizeFailed')
ORDER BY id DESC;

4.9 Schema sources in automation repository

Keep init SQL aligned with runtime code whenever schema or column semantics change.

4.10 Column dictionary (from SQL)

The following definitions map each column to its operational meaning.

review_queue columns (docs/review_queue.sql)
  • id (INTEGER) - local queue row identifier (autoincrement).
  • Folder (TEXT) - category/folder key used by workflow and publish paths.
  • File_Name (TEXT) - deterministic working filename used for publish mapping.
  • Path (TEXT) - local full image path in current processing state.
  • ollama_path (TEXT) - temp resized image path for local caption model input.
  • Thumb_Path (TEXT) - thumbnail path when available.
  • DateTime (TEXT) - capture datetime from EXIF or derived metadata.
  • Camera (TEXT) - camera model string.
  • Lens_model (TEXT) - lens model string.
  • Width (INTEGER) - image width in pixels.
  • Height (INTEGER) - image height in pixels.
  • Exposure (TEXT) - exposure time text (for example 1/320).
  • Aperture (TEXT) - aperture text (for example f/5.6).
  • ISO (INTEGER) - ISO value from EXIF.
  • Focal_length (INTEGER) - focal length value.
  • Keywords (TEXT) - keyword list/string for search and metadata publish.
  • Caption (TEXT) - main caption text.
  • alt_text (TEXT) - accessibility/SEO alternate text.
  • Location (TEXT) - location label used in metadata context.
  • Subject (TEXT) - subject label used for naming/metadata context.
  • nima_score (REAL) - NIMA-based quality feature.
  • blur_score (REAL) - blur quality feature.
  • brightness_score (REAL) - brightness quality feature.
  • contrast_score (REAL) - contrast quality feature.
  • QR (REAL) - aggregate quality rating score.
  • QC_Status (TEXT) - quality classification/state.
  • Review_Status (TEXT) - lifecycle status (Queued/Pending/Approved/Error/etc.).
  • Original_File_Name (TEXT) - original imported filename before automation naming.
  • brisque_score (REAL) - BRISQUE quality feature.
  • clip_aesthetic_score (REAL) - CLIP aesthetic feature.
photos_info_revamp columns (docs/photos_info_revamp.sql)
  • id (INTEGER) - publish catalog primary key.
  • Folder (TEXT) - published folder/category key.
  • File_Name (TEXT) - published filename and upsert key in publish pipeline.
  • Path (TEXT) - public/remote image path URL.
  • Thumb_Path (TEXT) - public/remote thumbnail URL.
  • DateTime (TEXT) - capture datetime metadata.
  • Camera (TEXT) - camera metadata.
  • Lens_model (TEXT) - lens metadata.
  • Width (INTEGER) - width in pixels.
  • Height (INTEGER) - height in pixels.
  • Exposure (TEXT) - exposure value text.
  • Aperture (TEXT) - aperture text.
  • ISO (INTEGER) - ISO value.
  • Focal_length (INTEGER) - focal length value.
  • Keywords (TEXT) - searchable keyword metadata.
  • Caption (TEXT) - published caption.
  • alt_text (TEXT) - published alt text.
  • Location (TEXT) - published location metadata.
  • QR (INTEGER) - quality/ranking score field in this schema export.
  • QC_Status (TEXT) - quality class in published metadata.
  • Original_File_Name (TEXT) - original source filename (required).
  • nima_score (REAL) - NIMA quality metric.
  • blur_score (REAL) - blur metric.
  • brightness_score (REAL) - brightness metric.
  • contrast_score (REAL) - contrast metric.
  • brisque_score (REAL) - BRISQUE metric.
  • clip_aesthetic_score (REAL) - CLIP aesthetic metric.

4.11 Continuation path

Step 4 defines storage and state contracts. Step 5 defines how to extend these components safely as a developer.

© 2026 Amir Darzi
Privacy Policy  |  Photography site | W3C-Valid  |  Cookie settings