HealthMetricAggregations table
The HealthMetricAggregations table in the FitStack - V2 schema has 25 columns, with 1 foreign key to Users.
Rollups over DeviceHealthData. Composite PK `(Id, IntervalStart)`. **Prefer serving coaches from here, not from DeviceHealthData.** An aggregate is what a coach actually needs, and it leaks far less than raw per-sample data — a good default for the `activity.summary` scope.
Columns (25)
| Column | Type | Constraints | Description |
|---|---|---|---|
| Id | uuid | not null | |
| IntervalStart | timestamp with time zone | not null | |
| IntervalEnd | timestamp with time zone | not null | |
| UserId | text | not null, references Users.Id | |
| MetricType | integer | not null | |
| Unit | integer | not null | |
| Interval | integer | not null | `TimeInterval`. |
| MinValue | numeric | ||
| MaxValue | numeric | ||
| AvgValue | numeric | ||
| SumValue | numeric | ||
| FirstValue | numeric | ||
| LastValue | numeric | ||
| TrendValue | numeric | ||
| MedianValue | numeric | ||
| StandardDeviation | numeric | ||
| DataPointCount | integer | not null | |
| FirstDataPointTime | timestamp with time zone | ||
| LastDataPointTime | timestamp with time zone | ||
| IsComplete | boolean | not null | |
| LastComputedAt | timestamp with time zone | not null | |
| CreatedAt | timestamp with time zone | not null | |
| ModifiedAt | timestamp with time zone | ||
| IsDeleted | boolean | not null | |
| DeletedAt | timestamp with time zone |
Indexes (1)
(UserId, MetricType, IntervalStart)(IX_HealthMetricAggregations_User_Metric_Start)
Relationships
HealthMetricAggregations.UserIdreferencesUsers.Id