Changes between Initial Version and Version 1 of BuildPopularity


Ignore:
Timestamp:
01/28/26 00:33:06 (12 days ago)
Author:
233051
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • BuildPopularity

    v1 v1  
     1= Complex DB Reports (SQL, Stored Procedures, Relational Algebra) =
     2
     3===  Budget-Tier Build Popularity Analysis ===
     4
     5Report on which price ranges have the highest user engagement, which measures both build creation volume and the average community reception.
     6
     7**SQL:**
     8
     9{{{
     10WITH price_tier_builds AS (
     11  SELECT
     12    b.id AS build_id,
     13    b.user_id,
     14    b.total_price,
     15    CASE
     16      WHEN b.total_price < 500 THEN 'Budget'
     17      WHEN b.total_price < 1000 THEN 'Mid-Range'
     18      WHEN b.total_price < 2000 THEN 'High-End'
     19      ELSE 'Enthusiast'
     20    END AS price_tier
     21  FROM build b
     22  WHERE b.is_approved = TRUE
     23    AND b.created_at >= CURRENT_DATE - INTERVAL '6 months'
     24),
     25engagement_stats AS (
     26  SELECT
     27    ptb.price_tier,
     28    COUNT(ptb.build_id) AS builds_count,
     29    AVG(fb.favorites_count) AS avg_favorites,
     30    AVG(rb.value) AS avg_rating,
     31    COUNT(DISTINCT ptb.user_id) AS unique_builders
     32  FROM price_tier_builds ptb
     33  JOIN rating_build rb ON ptb.build_id = rb.build_id
     34  JOIN (
     35    SELECT build_id, COUNT(DISTINCT user_id) AS favorites_count
     36    FROM favorite_build
     37    GROUP BY build_id
     38  ) fb ON ptb.build_id = fb.build_id
     39  GROUP BY ptb.price_tier
     40)
     41SELECT
     42  price_tier,
     43  builds_count,
     44  ROUND(avg_favorites, 1) AS avg_favorites,
     45  ROUND(avg_rating, 2) AS avg_rating,
     46  unique_builders,
     47  ROUND(
     48    (builds_count * 2) +
     49    (avg_favorites * 3) +
     50    (avg_rating * 10) +
     51    (unique_builders * 1.5), 2
     52  ) AS engagement_score
     53FROM engagement_stats
     54ORDER BY engagement_score DESC
     55LIMIT 15;
     56}}}
     57
     58**Relational algebra:**
     59
     60{{{
     61price_tier_builds =
     62  π_{b.id ⇒ build_id, b.total_price,
     63     CASE
     64       WHEN b.total_price < 500 THEN 'Budget'
     65       WHEN b.total_price < 1000 THEN 'Mid-Range'
     66       WHEN b.total_price < 2000 THEN 'High-End'
     67       ELSE 'Enthusiast'
     68     END ⇒ price_tier
     69  } (
     70    σ_{b.is_approved = TRUE AND b.created_at ≥ CURRENT_DATE - INTERVAL '6 months'} (build b)
     71  )
     72
     73engagement_stats =
     74  γ_{price_tier;
     75     COUNT(build_id) ⇒ builds_count,
     76     AVG(favorites_count) ⇒ avg_favorites,
     77     AVG(rb.value) ⇒ avg_rating,
     78     COUNT(DISTINCT user_id) ⇒ unique_builders
     79  } (
     80    price_tier_builds ⋈_{price_tier_builds.build_id = rb.build_id} rating_build rb
     81    ⋈_{rb.build_id = b.id} build b
     82  )
     83
     84λ_15 (
     85  τ_{(builds_count * 2) + (avg_favorites * 3) + (avg_rating * 10) + (unique_builders * 1.5) DESC} (
     86    π_{e.price_tier,
     87       e.builds_count,
     88       e.avg_favorites,
     89       ROUND(e.avg_rating, 2) ⇒ avg_rating,
     90       e.unique_builders,
     91       (e.builds_count * 2 + e.avg_favorites * 3 + e.avg_rating * 10 + e.unique_builders * 1.5) ⇒ engagement_score
     92    } (engagement_stats e)
     93  )
     94)
     95}}}