Repository navigation
Database Schema
Dave Walker edited this page Nov 10, 2026
·
7 revisions
ReefTag stores image references, footage dates, geographical locations, species, identified individuals and locations of animals awaiting identification in a local SQLite database.
The model contains seven principal entities:
| Table Name | Description |
|---|---|
LOCATION |
A named geographical location with region, country and optional coordinates |
FOLDER |
A folder containing images, with footage date and optional geographical location |
IMAGE |
An image with saved observations or examination status; its date comes from its folder |
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 |
- A
LOCATIONcan be assigned to multipleFOLDERrecords; a folder can have no location - A
FOLDERcan contain manyIMAGErecords; its date and location is shared by all associated images - 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 |
Name of the location |
Region |
Administrative region |
Country |
Country of the location |
Latitude |
Optional latitude in decimal degrees |
Longitude |
Optional longitude in decimal degrees |
| Field | Meaning |
|---|---|
Id |
SQLite-generated integer primary key |
Path |
Full path to the folder |
Date |
Footage date shared by images in this folder, in YYYY-MM-DD format |
LocationId |
Nullable foreign key referencing LOCATION.Id
|
- The folder is the source of both the observation date and geographical location for its images
- Changing either property changes the value attributed to all images in that folder
| Field | Meaning |
|---|---|
Id |
SQLite-generated integer primary key |
Name |
Image filename and extension |
FurtherExamination |
0 or 1, indicating whether the image has been flagged for further examination |
FolderId |
Integer foreign key referencing FOLDER.Id and identifying its containing folder |
- An image is identified by its parent folder path, name and extension
- Images with matching filenames in different folders have separate
IMAGErecords
| 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
|
| 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
| 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 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
| 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 animal at a recorded position in one image
- Deleting an unknown marker removes its
PENDING_IDENTIFICATIONrecord
Coordinates for identifications and unknown markers 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
| Relationship | Cardinality | Purpose |
|---|---|---|
LOCATION → FOLDER
|
One to many (optional on folder) | One location may be associated with several folders |
FOLDER → IMAGE
|
One to many | A folder supplies the date and location of its images |
IMAGE → IDENTIFICATION
|
One to many | A image may contain several annotated animals |
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 animals 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.