Skip to content

Data Model

Raphael Mack edited this page Nov 4, 2018 · 18 revisions

The data which is stored by ActivityDiary is made available via ContentProvider and described by a corresponding contract class. The app itself shall access the data only via content provider, to prevent access from multiple threads on the database.

The data model consists of the following entities and their attributes:

  • DiaryActivities (not the Android UI-Activities, that's why we prefix the name with Diary)
    • TEXT: name
    • INT: color (in 32bit ARGB format)
    • INT: id (_ID, primary key, autoincremented)
    • INT: deleted (_DELETED, default: 0, 1 means deleted)
    • aliases (in case the name is not obvious and the same activity should be found by different names, not yet used)
    • hierarchical structure (link to parent, not yet used)
    • required conditions (not yet used)
    • activation conditions (with probability, not yet used)
    • (?actions like set ringtone volume?, not yet used)
  • Conditions (to autodetect activities, planned by nyi)
    • TEXT: name (not yet used)
    • INT: id (_ID, primary key, autoincrement) (not yet used)
    • TEXT?: type (location, acceleration, WLAN, BT, time, calendar entries, NFC) (not yet used)
    • TEXT: parameter (e.g. SSID for WLAN) (not yet used)
  • Diary
    • INT: id (_ID, primnary key, autoincrement)
    • INT: deleted (_DELETED, default: 0, 1 means deleted)
    • INT: start (milliseconds since epoch of the start of this entry)
    • INT: end (milliseconds since epoch of the end of this entry)
    • TEXT: note Manual log (text linked to an activity _NOTE)
  • DiaryImage
    • INT: id (_ID, primnary key, autoincrement)
    • INT: deleted (_DELETED, default: 0, 1 means deleted)
    • TEXT: uri (URI) string specifying the image resource
    • INT: diary_id (DIARY_ID, foreign key into Diary table)
  • Locations (only filled if configured)
    • INT: id (primary key, autoincrement)
    • REAL: latitude (not NULL)
    • REAL: longitude (not NULL)
    • REAL: altitude (not NULL)
    • INT: timestamp (millis since epoch, not NULL)
    • REAL: speed (meters/sec over ground, NULL means unknown)
    • REAL: hacc (estimated horizontal accuracy in in 1/10 meters, NULL means unknown)
    • REAL: vacc (estimated vertical accuracy in in 1/10 meters, NULL means unknown)
    • REAL: sacc (estimated speed accuracy in in 1/10 meters/sec, NULL means unknown)
  • Templates (planned, but nyi)
    • _id (ID)
    • Activities with Conditions, but they are not active
    • on adding of a new activity the templates shall be searched for a fitting template and the template conditions to be suggested but values to be filled.

Available on the ContentProvider, but not stored in the database:

  • DiaryStats
    • TEXT: name
    • INT: color (32 bit ARGB)
    • INT: duration (in millis)
    • FLOAT: portion (in % of the selected result)

An additional idea might be to add tags. E. g. the activity "planting" could have a tag attached for linking it to "potato" or "tomato", while the activity "harvesting" could share the same tag... And maybe "attributes" which can be any kind of number that allows to track data as the amount of harvested potato, etc.

Clone this wiki locally