Refactor database schema for tag management in PhotoTagger

Enhance the tagging system by introducing a normalized structure with a separate `tags` table for unique tag definitions and a `phototaglinkage` table to manage the many-to-many relationship between photos and tags. Update the logic for inserting and retrieving tags to improve data integrity and prevent duplicates. Additionally, update the README to reflect these changes and document the new folder view features.
This commit is contained in:
tanyar09
2025-10-01 15:10:23 -04:00
parent 0f599d3d16
commit 6bfc44a6c9
2 changed files with 55 additions and 10 deletions
+23 -2
View File
@@ -184,7 +184,8 @@ python3 photo_tagger.py tag-manager
This GUI provides a file explorer-like interface for managing photo tags with advanced column resizing and multiple view modes.
**🎯 Tag Manager Features:**
- 📊 **Multiple View Modes** - List view, icon view, and compact view for different needs
- 📊 **Multiple View Modes** - List view, icon view, compact view, and folder view for different needs
- 📁 **Folder Grouping** - Group photos by directory with expandable/collapsible folders
- 🔧 **Resizable Columns** - Drag column separators to resize both headers and data rows
- 👁️ **Column Visibility** - Right-click to show/hide columns in each view mode
- 🖼️ **Thumbnail Display** - Icon view shows photo thumbnails with metadata
@@ -211,6 +212,14 @@ This GUI provides a file explorer-like interface for managing photo tags with ad
-**Fast Loading** - Minimal data for quick browsing
- 🎯 **Focused Display** - Perfect for quick tag management
**Folder View:**
- 📁 **Directory Grouping** - Photos grouped by their directory path
- 🔽 **Expandable Folders** - Click folder headers to expand/collapse
- 📊 **Photo Counts** - Shows number of photos in each folder
- 🎯 **File Explorer Style** - Familiar tree-like interface
- 📄 **Photo Details** - Shows filename, processed status, date taken, face count, and tags
- 🖱️ **Easy Navigation** - Click anywhere on folder header to toggle
**🔧 Column Resizing:**
- 🖱️ **Drag to Resize** - Click and drag red separators between columns
- 📏 **Minimum Width** - Columns maintain minimum 50px width
@@ -224,6 +233,15 @@ This GUI provides a file explorer-like interface for managing photo tags with ad
- 🎯 **View-Specific** - Column settings saved per view mode
- 🔄 **Instant Updates** - Changes apply immediately
**📁 Folder View Usage:**
- 🖱️ **Click Folder Headers** - Click anywhere on a folder row to expand/collapse
- 🔽 **Expand/Collapse Icons** - ▶ indicates collapsed, ▼ indicates expanded
- 📊 **Photo Counts** - Each folder shows "(X photos)" in the header
- 🎯 **Root Directory** - Photos without a directory path are grouped under "Root"
- 📁 **Alphabetical Sorting** - Folders are sorted alphabetically by directory name
- 🖼️ **Photo Details** - Expanded folders show all photos with their metadata
- 🔄 **Persistent State** - Folder expansion state is maintained while browsing
**Left Panel (People):**
- 🔍 **Last Name Search** - Search box to filter people by last name (case-insensitive)
- 🔎 **Search Button** - Apply filter to show only matching people
@@ -365,7 +383,8 @@ The tool uses SQLite database (`data/photos.db` by default) with these tables:
- **photos** - Photo file paths and processing status
- **people** - Known people with separate first_name, last_name, and date_of_birth fields
- **faces** - Face encodings, locations, and quality scores
- **tags** - Custom tags for photos
- **tags** - Tag definitions (unique tag names)
- **phototaglinkage** - Links between photos and tags (many-to-many relationship)
- **person_encodings** - Face encodings for each person (for matching)
### Database Schema Improvements
@@ -374,6 +393,8 @@ The tool uses SQLite database (`data/photos.db` by default) with these tables:
- **Unique Constraint** - Prevents duplicate people with same name and birth date combination
- **No Comma Issues** - Names are stored without commas, displayed as "Last, First" format
- **Quality Scoring** - Faces table includes quality scores for better matching
- **Normalized Tag Structure** - Separate `tags` table for tag definitions and `phototaglinkage` table for photo-tag relationships
- **No Duplicate Tags** - Unique constraint prevents duplicate tag-photo combinations
- **Optimized Queries** - Efficient indexing and query patterns for fast performance
- **Data Integrity** - Proper foreign key relationships and constraints