Repository navigation
Database Schema
ReefTag stores image references, species, identified species and locations of animals awaiting identification in a local SQLite database. The application uses yoyo-migrations for initial schema creation and subsequent changes. Pending migrations are automatically applied when the application starts.
The model contains five principal entities:
| Table Name | Description |
|---|---|
IMAGE |
a image with saved observations or examination status, including its footage date |
SPECIES |
a reusable species-catalogue entry, with common and scientific names and an optional category |
CATEGORY |
a named category that may be assigned to multiple species |
IDENTIFICATION |
one identified individual at a recorded position within one image |
PENDING_IDENTIFICATION |
one animal that has been marked in a image but not yet identified |
- An
IMAGEcan have manyIDENTIFICATIONandPENDING_IDENTIFICATIONrecords - A
SPECIEScan be referred to by manyIDENTIFICATIONrecords - A
CATEGORYcan be associated with manySPECIESrecords, though the association is optional for each species - Each
IDENTIFICATIONreferences exactly oneIMAGEand oneSPECIES - Each
PENDING_IDENTIFICATIONreferences oneIMAGEand has no species assigned
| Field | Meaning |
|---|---|
id |
SQLite-generated integer primary key |
Name |
Resolved absolute image path, including filename and extension; the image's identity |
Date |
Original footage date, recorded as a date value (ISO YYYY-MM-DD was specified in the brief) |
FurtherExamination |
0 or 1, indicating whether the image has been flagged for further examination |
- Images with matching filenames in different folders have separate
IMAGErecords - Adding a pending identification sets
FurtherExaminationto1 - An image with one or more pending identifications cannot have this flag switched off through the UI
- Once no pending identifications remain, the flag can again be changed manually
- Clearing the last pending identification restores manual control of the flag
| Field | Meaning |
|---|---|
id |
SQLite-generated integer primary key |
CommonName |
Common name supplied by the observer |
ScientificName |
Scientific name supplied by the observer |
CategoryId |
Nullable integer foreign key referencing CATEGORY.Id
|
- The species catalogue is shared across all images
- A single species can be used for any number of identifications
- Names are not automatically verified against an external taxonomy
- A species may have no category
- Categories are managed separately and reused across the species catalogue
| Field | Meaning |
|---|---|
Id |
SQLite-generated integer primary key |
Name |
Category name; cannot be empty |
- Category names must be unique
- A category can only be deleted when no species references it
- Changing a category name leaves the associated species in that category
| Field | Meaning |
|---|---|
id |
SQLite-generated integer primary key |
ImageId |
Integer foreign key referencing IMAGE.id
|
SpeciesId |
Integer foreign key referencing SPECIES.id
|
Number |
Number shown beside the fish marker; scoped to an individual image |
X |
Horizontal pixel coordinate in the original image |
Y |
Vertical pixel coordinate in the original image |
- An identification represents one observed individual in one image
- Several
IDENTIFICATIONrecords can point to the sameSPECIESrecord, even in the sameIMAGE
This table was introduced in v1.2.0 to store fish locations awaiting species identification.
| Field | Meaning |
|---|---|
id |
SQLite-generated integer primary key |
ImageId |
Integer foreign key referencing IMAGE.id
|
X |
Horizontal pixel coordinate in the original image |
Y |
Vertical pixel coordinate in the original image |
- A pending identification represents a single unknown fish at a recorded position in one image
- It does not reference
SPECIESand does not have a marker number - Deleting an unknown marker removes its
PENDING_IDENTIFICATIONrecord - Identifying that fish removes the pending record and creates an
IDENTIFICATIONrecord using the normal identified-fish workflow
Coordinates are stored against the original image, not the size or position of the preview displayed on screen:
- Origin: the upper-left corner,
(0, 0) -
Xincreases from left to right -
Yincreases from top to bottom - Zooming, panning and brightness adjustments do not modify the stored coordinates or source image
Both identified and pending markers use these original-image coordinates. Only identified markers have per-image numbers; pending markers are shown as unnumbered red question marks.
The intended relationships are:
| Relationship | Cardinality | Purpose |
|---|---|---|
IMAGE → IDENTIFICATION
|
One to many | A image may contain several annotated fish |
SPECIES → IDENTIFICATION
|
One to many | One species may appear in many observations |
CATEGORY → SPECIES
|
One to many (optional on species) | A category can classify many species; a species can have no category |
IMAGE → PENDING_IDENTIFICATION
|
One to many | A image may contain several fish awaiting identification |
The path to the SQLite file is supplied via the REEFTAG_DB_PATH environment variable. This should be an absolute file path, for example:
export REEFTAG_DB_PATH="$HOME/Documents/ReefTag/reeftag.db"The application creates and migrates the schema as needed on startup using yoyo-migrations so users should not need to run SQL scripts to initialise a new installation or apply schema changes.