Changes between Version 1 and Version 2 of DatabaseProgramming


Ignore:
Timestamp:
05/26/26 11:15:32 (6 hours ago)
Author:
231550
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DatabaseProgramming

    v1 v2  
    1 == Procedures/Functions/Triggers ==
     1== !Procedures/Functions/Triggers ==
    22
    33-- 1. FUNCTION: Calculate total calories for a user on a specific date
     
    323323END;
    324324$$ LANGUAGE plpgsql;
     325
     3261. !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.