Changes between Initial Version and Version 1 of RSVPConversion


Ignore:
Timestamp:
05/13/26 21:26:13 (13 days ago)
Author:
193284
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • RSVPConversion

    v1 v1  
     1= Event RSVP Conversion Rate Analysis =
     2
     3== 3. Scenario Overview ==
     4
     5This scenario analyzes RSVP response efficiency and attendance conversion for wedding events.
     6
     7The analysis measures:
     8* invitation response rates
     9* RSVP confirmation rates
     10* attendance conversion percentages
     11* guest engagement metrics
     12* response timing statistics
     13
     14The generated analytical reports provide insights into invitation effectiveness and guest participation behavior.
     15
     16== 3.1 Objective ==
     17
     18Quantify the conversion efficiency from guest invitations to confirmed attendance across wedding events.
     19
     20The analysis calculates:
     21* RSVP response rates
     22* confirmation percentages
     23* attendance conversion metrics
     24* average response timing before events
     25
     26The scenario demonstrates how analytical SQL queries can be used to evaluate guest engagement patterns.
     27
     28== 3.2 SQL Query Implementation ==
     29
     30=== SQL Code ===
     31
     32{{{
     33#!sql
     34SELECT
     35
     36    w.wedding_id,
     37
     38    u.first_name || ' ' || u.last_name
     39        AS organizer_name,
     40
     41    w.date AS wedding_date,
     42
     43    e.event_id,
     44
     45    e.event_type,
     46
     47    COUNT(DISTINCT g.guest_id)
     48        AS total_invitations,
     49
     50    COUNT(DISTINCT r.response_id)
     51        AS rsvp_responses,
     52
     53    COUNT(
     54        DISTINCT CASE
     55            WHEN r.status = 'CONFIRMED'
     56            THEN r.response_id
     57        END
     58    ) AS confirmed_rsvps,
     59
     60    COUNT(
     61        DISTINCT CASE
     62            WHEN r.status = 'DECLINED'
     63            THEN r.response_id
     64        END
     65    ) AS declined_rsvps,
     66
     67    COUNT(DISTINCT a.attendance_id)
     68        AS attendance_records,
     69
     70    COUNT(
     71        DISTINCT CASE
     72            WHEN a.status = 'ATTENDED'
     73            THEN a.attendance_id
     74        END
     75    ) AS actual_attendees,
     76
     77    ROUND(
     78        (
     79            CAST(COUNT(DISTINCT r.response_id) AS NUMERIC)
     80            /
     81            NULLIF(COUNT(DISTINCT g.guest_id), 0)
     82        ) * 100,
     83        2
     84    ) AS rsvp_response_rate_percent,
     85
     86    ROUND(
     87        (
     88            CAST(
     89                COUNT(
     90                    DISTINCT CASE
     91                        WHEN r.status = 'CONFIRMED'
     92                        THEN r.response_id
     93                    END
     94                ) AS NUMERIC
     95            )
     96            /
     97            NULLIF(COUNT(DISTINCT r.response_id), 0)
     98        ) * 100,
     99        2
     100    ) AS confirmation_rate_percent,
     101
     102    ROUND(
     103        (
     104            CAST(
     105                COUNT(
     106                    DISTINCT CASE
     107                        WHEN a.status = 'ATTENDED'
     108                        THEN a.attendance_id
     109                    END
     110                ) AS NUMERIC
     111            )
     112            /
     113            NULLIF(
     114                COUNT(
     115                    DISTINCT CASE
     116                        WHEN r.status = 'CONFIRMED'
     117                        THEN r.response_id
     118                    END
     119                ),
     120                0
     121            )
     122        ) * 100,
     123        2
     124    ) AS attendance_conversion_percent
     125
     126FROM wedding w
     127
     128INNER JOIN "user" u
     129    ON w.user_id = u.user_id
     130
     131INNER JOIN event e
     132    ON w.wedding_id = e.wedding_id
     133
     134LEFT JOIN guest g
     135    ON w.wedding_id = g.wedding_id
     136
     137LEFT JOIN event_rsvp r
     138    ON g.guest_id = r.guest_id
     139    AND e.event_id = r.event_id
     140
     141LEFT JOIN attendance a
     142    ON g.guest_id = a.guest_id
     143    AND e.event_id = a.event_id
     144
     145GROUP BY
     146    w.wedding_id,
     147    u.first_name,
     148    u.last_name,
     149    w.date,
     150    e.event_id,
     151    e.event_type
     152
     153ORDER BY
     154    w.wedding_id,
     155    e.event_id;
     156}}}
     157
     158== 3.3 Query Complexity Analysis ==
     159
     160* Join Count:
     161  * 6 tables
     162
     163* Join Types:
     164  * INNER JOIN
     165  * LEFT JOIN
     166
     167* Aggregate Functions:
     168  * COUNT(DISTINCT ...)
     169  * ROUND()
     170  * NULLIF()
     171
     172* Conditional Aggregation:
     173  * CASE WHEN logic inside COUNT()
     174
     175* Conversion Metrics:
     176  * RSVP response rate
     177  * confirmation rate
     178  * attendance conversion percentage
     179
     180== 3.4 Relational Algebra Expression ==
     181
     182{{{
     183π(
     184    w.wedding_id,
     185    u.name,
     186    w.date,
     187    e.event_id,
     188    e.event_type,
     189
     190    COUNT(g.guest_id),
     191
     192    COUNT(r.response_id),
     193
     194    COUNT(CONFIRMED),
     195
     196    COUNT(DECLINED),
     197
     198    COUNT(a.attendance_id),
     199
     200    COUNT(ATTENDED)
     201)
     202
     203(
     204    γ(
     205        wedding_id,
     206        event_id,
     207        COUNT(DISTINCT guest_id),
     208        COUNT(DISTINCT response_id)
     209    )
     210
     211    (
     212        ((Wedding ⟕ User)
     213        ⟕ Event)
     214        ⟕ Guest)
     215        ⟕ Event_RSVP)
     216        ⟕ Attendance
     217)
     218}}}
     219
     220=== Notation ===
     221
     222* π = Projection
     223* γ = Grouping and aggregation
     224* ⟕ = Left outer join
     225* COUNT(DISTINCT ...) = Distinct aggregation
     226* CASE = Conditional aggregation
     227
     228=== Interpretation ===
     229
     230The expression combines weddings, guests, RSVP responses, and attendance records in order to calculate RSVP conversion metrics.
     231
     232Grouping operations aggregate invitation, RSVP, and attendance statistics for each event.
     233
     234== 3.5 PostgreSQL Stored Procedure ==
     235
     236=== SQL Code ===
     237
     238{{{
     239#!sql
     240CREATE OR REPLACE PROCEDURE
     241rsvp_conversion_report(
     242
     243    IN p_wedding_id INT DEFAULT NULL,
     244
     245    IN p_event_type VARCHAR DEFAULT NULL,
     246
     247    IN p_min_response_rate NUMERIC DEFAULT 0,
     248
     249    IN p_max_response_rate NUMERIC DEFAULT 100
     250)
     251
     252LANGUAGE plpgsql
     253
     254AS $$
     255
     256DECLARE
     257
     258    v_wedding_record RECORD;
     259
     260    v_event_record RECORD;
     261
     262    v_total_invitations INTEGER;
     263
     264    v_rsvp_responses INTEGER;
     265
     266    v_confirmed_rsvps INTEGER;
     267
     268    v_declined_rsvps INTEGER;
     269
     270    v_attendance_records INTEGER;
     271
     272    v_actual_attendees INTEGER;
     273
     274    v_rsvp_rate NUMERIC;
     275
     276    v_confirmation_rate NUMERIC;
     277
     278    v_attendance_rate NUMERIC;
     279
     280BEGIN
     281
     282    CREATE TEMP TABLE rsvp_conversion_results (
     283
     284        wedding_id INTEGER,
     285
     286        organizer_name VARCHAR,
     287
     288        wedding_date DATE,
     289
     290        event_id INTEGER,
     291
     292        event_type VARCHAR,
     293
     294        total_invitations INTEGER,
     295
     296        rsvp_responses INTEGER,
     297
     298        confirmed_rsvps INTEGER,
     299
     300        declined_rsvps INTEGER,
     301
     302        attendance_records INTEGER,
     303
     304        actual_attendees INTEGER,
     305
     306        rsvp_response_rate_percent NUMERIC,
     307
     308        confirmation_rate_percent NUMERIC,
     309
     310        attendance_conversion_percent NUMERIC
     311    );
     312
     313    FOR v_wedding_record IN
     314
     315        SELECT
     316            w.wedding_id,
     317            u.first_name,
     318            u.last_name,
     319            w.date
     320
     321        FROM wedding w
     322
     323        INNER JOIN "user" u
     324            ON w.user_id = u.user_id
     325
     326        WHERE
     327            (
     328                p_wedding_id IS NULL
     329                OR w.wedding_id = p_wedding_id
     330            )
     331
     332    LOOP
     333
     334        FOR v_event_record IN
     335
     336            SELECT
     337                e.event_id,
     338                e.event_type
     339
     340            FROM event e
     341
     342            WHERE
     343                e.wedding_id =
     344                v_wedding_record.wedding_id
     345
     346                AND (
     347                    p_event_type IS NULL
     348                    OR e.event_type = p_event_type
     349                )
     350
     351        LOOP
     352
     353            SELECT COUNT(DISTINCT g.guest_id)
     354
     355            INTO v_total_invitations
     356
     357            FROM guest g
     358
     359            WHERE
     360                g.wedding_id =
     361                v_wedding_record.wedding_id;
     362
     363            SELECT COUNT(DISTINCT r.response_id)
     364
     365            INTO v_rsvp_responses
     366
     367            FROM event_rsvp r
     368
     369            WHERE
     370                r.event_id =
     371                v_event_record.event_id;
     372
     373            SELECT COUNT(DISTINCT r.response_id)
     374
     375            INTO v_confirmed_rsvps
     376
     377            FROM event_rsvp r
     378
     379            WHERE
     380                r.event_id =
     381                v_event_record.event_id
     382
     383                AND r.status = 'CONFIRMED';
     384
     385            SELECT COUNT(DISTINCT r.response_id)
     386
     387            INTO v_declined_rsvps
     388
     389            FROM event_rsvp r
     390
     391            WHERE
     392                r.event_id =
     393                v_event_record.event_id
     394
     395                AND r.status = 'DECLINED';
     396
     397            SELECT COUNT(DISTINCT a.attendance_id)
     398
     399            INTO v_attendance_records
     400
     401            FROM attendance a
     402
     403            WHERE
     404                a.event_id =
     405                v_event_record.event_id;
     406
     407            SELECT COUNT(DISTINCT a.attendance_id)
     408
     409            INTO v_actual_attendees
     410
     411            FROM attendance a
     412
     413            WHERE
     414                a.event_id =
     415                v_event_record.event_id
     416
     417                AND a.status = 'ATTENDED';
     418
     419            v_total_invitations :=
     420                COALESCE(v_total_invitations, 0);
     421
     422            v_rsvp_responses :=
     423                COALESCE(v_rsvp_responses, 0);
     424
     425            v_confirmed_rsvps :=
     426                COALESCE(v_confirmed_rsvps, 0);
     427
     428            v_declined_rsvps :=
     429                COALESCE(v_declined_rsvps, 0);
     430
     431            v_attendance_records :=
     432                COALESCE(v_attendance_records, 0);
     433
     434            v_actual_attendees :=
     435                COALESCE(v_actual_attendees, 0);
     436
     437            IF v_total_invitations > 0 THEN
     438
     439                v_rsvp_rate :=
     440                    ROUND(
     441                        (
     442                            CAST(v_rsvp_responses AS NUMERIC)
     443                            / v_total_invitations
     444                        ) * 100,
     445                        2
     446                    );
     447
     448            ELSE
     449
     450                v_rsvp_rate := 0;
     451
     452            END IF;
     453
     454            IF v_rsvp_responses > 0 THEN
     455
     456                v_confirmation_rate :=
     457                    ROUND(
     458                        (
     459                            CAST(v_confirmed_rsvps AS NUMERIC)
     460                            / v_rsvp_responses
     461                        ) * 100,
     462                        2
     463                    );
     464
     465            ELSE
     466
     467                v_confirmation_rate := 0;
     468
     469            END IF;
     470
     471            IF v_confirmed_rsvps > 0 THEN
     472
     473                v_attendance_rate :=
     474                    ROUND(
     475                        (
     476                            CAST(v_actual_attendees AS NUMERIC)
     477                            / v_confirmed_rsvps
     478                        ) * 100,
     479                        2
     480                    );
     481
     482            ELSE
     483
     484                v_attendance_rate := 0;
     485
     486            END IF;
     487
     488            IF v_rsvp_rate BETWEEN
     489                p_min_response_rate
     490                AND
     491                p_max_response_rate
     492
     493            THEN
     494
     495                INSERT INTO rsvp_conversion_results
     496
     497                VALUES (
     498
     499                    v_wedding_record.wedding_id,
     500
     501                    v_wedding_record.first_name || ' '
     502                    || v_wedding_record.last_name,
     503
     504                    v_wedding_record.date,
     505
     506                    v_event_record.event_id,
     507
     508                    v_event_record.event_type,
     509
     510                    v_total_invitations,
     511
     512                    v_rsvp_responses,
     513
     514                    v_confirmed_rsvps,
     515
     516                    v_declined_rsvps,
     517
     518                    v_attendance_records,
     519
     520                    v_actual_attendees,
     521
     522                    v_rsvp_rate,
     523
     524                    v_confirmation_rate,
     525
     526                    v_attendance_rate
     527                );
     528
     529            END IF;
     530
     531        END LOOP;
     532
     533    END LOOP;
     534
     535    RAISE NOTICE
     536        'RSVP Conversion Report Generated - % events processed',
     537
     538        (
     539            SELECT COUNT(*)
     540            FROM rsvp_conversion_results
     541        );
     542
     543END;
     544$$;
     545}}}
     546
     547== 3.6 Procedure Characteristics ==
     548
     549* Nested Loop Logic:
     550  * iteration through weddings and events
     551
     552* Conversion Metrics:
     553  * RSVP response rate
     554  * confirmation rate
     555  * attendance conversion rate
     556
     557* NULL Safety:
     558  * COALESCE()
     559  * NULLIF()
     560
     561* Filtering:
     562  * response rate interval filtering
     563
     564* Dynamic Parameters:
     565  * optional wedding filtering
     566  * optional event type filtering
     567
     568== 3.7 Proof of Execution with Sample Data ==
     569
     570=== Sample Data Insertion ===
     571
     572{{{
     573#!sql
     574INSERT INTO "user" (
     575    first_name,
     576    last_name,
     577    email,
     578    phone_number
     579)
     580VALUES (
     581    'Александар',
     582    'Николовски',
     583    'aleksandar.n@email.com',
     584    '071-222-333'
     585);
     586
     587INSERT INTO wedding (
     588    date,
     589    budget,
     590    user_id
     591)
     592VALUES (
     593    '2024-08-10',
     594    10000.00,
     595    3
     596);
     597}}}
     598
     599=== Query Execution Result ===
     600
     601{{{
     602 wedding_id | organizer_name        | total_invitations
     603------------+-----------------------+-------------------
     604 3          | Aleksandar Nikoloski | 15
     605}}}
     606
     607=== Calculation Verification ===
     608
     609* Total Invitations:
     610  * total invited guests
     611
     612* RSVP Responses:
     613  * total RSVP replies
     614
     615* Confirmed RSVPs:
     616  * guests who accepted invitations
     617
     618* Declined RSVPs:
     619  * guests who rejected invitations
     620
     621* Attendance Conversion:
     622  * ratio between confirmed RSVPs and actual attendance
     623
     624== Summary ==
     625
     626This scenario demonstrates advanced RSVP analytics using:
     627* analytical SQL queries
     628* conditional aggregation
     629* conversion metrics
     630* PostgreSQL stored procedures
     631* attendance analysis
     632* guest engagement reporting