NutritionLogs table

The NutritionLogs table in the FitStack - V2 schema has 33 columns, keyed by Id, with 5 foreign keys to Users, Products, Meals, MealPlans and 1 more. 1 column in ScheduledItems references it.

THE ONLY TABLE IN THE `nutrition` SCHEMA. Everything else nutrition-related is in `public`. The split buys nothing and costs a schema qualifier on every query — either move it to `public` or move MealLogs and Meals in with it.

Columns (33)

Columns of the NutritionLogs table
ColumnTypeConstraintsDescription
Iduuidprimary key, not null
UserIdcharacter varying(450)not null, references Users.IdCASCADE.
ProductIduuidnot null, references Products.IdRESTRICT. Required.
MealIduuidreferences Meals.IdSET NULL.
MealPlanIduuidreferences MealPlans.IdSET NULL.
RecipeIduuidreferences Recipes.IdSET NULL.
StartTimetimestamp with time zonenot nullThe C# `ConsumedAt` is a computed alias of this.
EndTimetimestamp with time zone
SourcePlatformintegernot null
Sourceintegernot null
RecordingMethodintegernot null
SourceIdentifiercharacter varying(200)
MealTypecharacter varying(50)not nullStored as TEXT here, unlike MealLogs.MealType which is an integer. Same enum, two encodings.
ServingsConsumednumeric(10,4)not null
Confidencenumeric(5,2)
TotalCaloriesnumeric(10,2)
TotalProteinnumeric(10,2)
TotalCarbohydratesnumeric(10,2)
TotalFatnumeric(10,2)
TotalFibernumeric(10,2)
TotalSugarnumeric(10,2)
TotalSodiumnumeric(10,2)
TotalCholesterolnumeric(10,2)
TotalSaturatedFatnumeric(10,2)
IsSnackbooleannot null
IsBeveragebooleannot null
TimeOfDayinterval
Metadatatext
Notescharacter varying(1000)
CreatedAttimestamp with time zonenot null
ModifiedAttimestamp with time zone
IsDeletedbooleannot null
DeletedAttimestamp with time zone

Indexes (6)

  • (UserId) (IX_NutritionLogs_UserId)
  • (ProductId) (IX_NutritionLogs_ProductId)
  • (MealId) (IX_NutritionLogs_MealId)
  • (MealPlanId) (IX_NutritionLogs_MealPlanId)
  • (RecipeId) (IX_NutritionLogs_RecipeId)
  • (MealType) (IX_NutritionLogs_MealType)

Relationships