Changes between Version 1 and Version 2 of DatabaseProgramming
- Timestamp:
- 05/26/26 11:15:32 (6 hours ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
DatabaseProgramming
v1 v2 1 == Procedures/Functions/Triggers ==1 == !Procedures/Functions/Triggers == 2 2 3 3 -- 1. FUNCTION: Calculate total calories for a user on a specific date … … 323 323 END; 324 324 $$ LANGUAGE plpgsql; 325 326 1. !get_user_daily_calories (Function) 327 328 * This function calculates a user's total caloric intake for a specific date by joining logged food portions with their respective nutritional content. It handles edge cases by converting empty log results into a baseline value of zero using COALESCE. Its main purpose is to serve as a reusable calculator for the application's dashboard. It isolates the mathematical conversion formula ($(\text{Calories} \times \text{Quantity}) / 100$) entirely within the database layer.
