Changes between Version 1 and Version 2 of P3


Ignore:
Timestamp:
01/03/26 14:13:23 (2 weeks ago)
Author:
193284
Comment:

Added P3 SQL application scenarios

Legend:

Unmodified
Added
Removed
Modified
  • P3

    v1 v2  
    1 = Phase P3
     1= P3 – Application Scenarios for Database Access (SQL)
    22
    3 == Content
    4 To be defined.
     3== Description
     4This phase demonstrates typical application scenarios for accessing the Wedding Planner database using SQL queries.
     5The scenarios reflect real tasks such as creating weddings, managing events and guests, tracking attendance, and handling venue bookings.
     6
     7== Assumptions
     8 * Primary keys are generated by the system (or assigned manually for the examples).
     9 * table_number in Attendance is optional because not all events require seating arrangements.
     10 * Status values are stored as text (e.g., 'planned', 'confirmed', 'cancelled', 'attending').
     11
     12== Scenario 1: Register a new user
     13Create a new user who will manage weddings in the system.
     14
     15{{{
     16INSERT INTO User (user_id, first_name, last_name, email, phone_number, gender, birthday)
     17VALUES (10, 'Jana', 'Trpkovska', 'jana@mail.com', '070123456', 'F', '2002-05-10');
     18}}}
     19
     20== Scenario 2: Create a wedding for a user
     21A user creates a wedding record.
     22
     23{{{
     24INSERT INTO Wedding (wedding_id, date, budget, notes, user_id)
     25VALUES (1, '2026-06-20', 15000, 'Summer wedding', 10);
     26}}}
     27
     28== Scenario 3: Add events for a wedding
     29Create wedding-related events such as ceremony and reception.
     30
     31{{{
     32INSERT INTO Event (event_id, event_type, date, start_time, end_time, status, wedding_id)
     33VALUES
     34(1, 'Ceremony', '2026-06-20', '12:00:00', '13:00:00', 'planned', 1),
     35(2, 'Reception', '2026-06-20', '15:00:00', '21:00:00', 'planned', 1);
     36}}}
     37
     38== Scenario 4: Add guests to a wedding
     39Add invited guests to the wedding.
     40
     41{{{
     42INSERT INTO Guest (guest_id, first_name, last_name, email, wedding_id)
     43VALUES
     44(101, 'Ana', 'Petrova', 'ana.p@mail.com', 1),
     45(102, 'Marko', 'Iliev', 'marko.i@mail.com', 1),
     46(103, 'Elena', 'Stojanova', NULL, 1);
     47}}}
     48
     49== Scenario 5: Record attendance for an event
     50Track guest attendance for a specific event (e.g., reception). table_number is optional.
     51
     52{{{
     53INSERT INTO Attendance (attendance_id, status, role, table_number, guest_id, event_id)
     54VALUES
     55(1, 'attending', 'guest', 5, 101, 2),
     56(2, 'attending', 'best_man', 1, 102, 2),
     57(3, 'pending', 'guest', NULL, 103, 2);
     58}}}
     59
     60== Scenario 6: List all weddings for a specific user
     61Retrieve weddings managed by a given user.
     62
     63{{{
     64SELECT w.wedding_id, w.date, w.budget, w.notes
     65FROM Wedding w
     66WHERE w.user_id = 10
     67ORDER BY w.date;
     68}}}
     69
     70== Scenario 7: List all events for a wedding
     71Show all events for a selected wedding.
     72
     73{{{
     74SELECT e.event_id, e.event_type, e.date, e.start_time, e.end_time, e.status
     75FROM Event e
     76WHERE e.wedding_id = 1
     77ORDER BY e.date, e.start_time;
     78}}}
     79
     80== Scenario 8: Show guest list for a wedding
     81Retrieve all guests invited to a wedding.
     82
     83{{{
     84SELECT g.guest_id, g.first_name, g.last_name, g.email
     85FROM Guest g
     86WHERE g.wedding_id = 1
     87ORDER BY g.last_name, g.first_name;
     88}}}
     89
     90== Scenario 9: Attendance overview for an event (JOIN)
     91List guests with their attendance status and seating (if available) for a specific event.
     92
     93{{{
     94SELECT g.first_name, g.last_name, a.status, a.role, a.table_number
     95FROM Attendance a
     96JOIN Guest g ON a.guest_id = g.guest_id
     97WHERE a.event_id = 2
     98ORDER BY a.role, g.last_name;
     99}}}
     100
     101== Scenario 10: Update an event status
     102Example: the ceremony is confirmed.
     103
     104{{{
     105UPDATE Event
     106SET status = 'confirmed'
     107WHERE event_id = 1;
     108}}}
     109
     110== Scenario 11: Add venue types and venues
     111Define venue types and store available venues.
     112
     113{{{
     114INSERT INTO Venue_Type (type_id, type_name)
     115VALUES
     116(1, 'Restaurant'),
     117(2, 'Hotel'),
     118(3, 'Event Hall');
     119}}}
     120
     121{{{
     122INSERT INTO Venue (venue_id, name, location, city, address, capacity, menu, phone_number, price_per_guest)
     123VALUES
     124(1, 'Royal Hall', 'Center', 'Skopje', 'Main Street 10', 250, 'Standard Menu', '021234567', 25.00),
     125(2, 'Lakeview Hotel', 'Lake Area', 'Ohrid', 'Lake Road 5', 180, NULL, '046111222', 30.00);
     126}}}
     127
     128== Scenario 12: Book a venue for a wedding (Venue_booking)
     129Create a booking record for a specific venue and time interval.
     130
     131{{{
     132INSERT INTO Venue_booking (booking_id, date, start_time, end_time, status, price, wedding_id, venue_id)
     133VALUES (1, '2026-06-20', '15:00:00', '21:00:00', 'confirmed', 4500.00, 1, 1);
     134}}}
     135
     136== Scenario 13: Venue booking overview for a wedding (JOIN)
     137Show booking details including venue name.
     138
     139{{{
     140SELECT v.name, vb.date, vb.start_time, vb.end_time, vb.status, vb.price
     141FROM Venue_booking vb
     142JOIN Venue v ON vb.venue_id = v.venue_id
     143WHERE vb.wedding_id = 1
     144ORDER BY vb.date, vb.start_time;
     145}}}
     146
     147== Scenario 14: Count guests per wedding (aggregate query)
     148Useful for planning and estimating costs.
     149
     150{{{
     151SELECT w.wedding_id, COUNT(g.guest_id) AS total_guests
     152FROM Wedding w
     153LEFT JOIN Guest g ON w.wedding_id = g.wedding_id
     154GROUP BY w.wedding_id
     155ORDER BY w.wedding_id;
     156}}}
     157
     158== Scenario 15: Estimated venue cost based on guest count
     159Estimate total cost = price_per_guest * number_of_guests (for a selected venue and wedding).
     160
     161{{{
     162SELECT w.wedding_id,
     163       v.name AS venue_name,
     164       v.price_per_guest,
     165       COUNT(g.guest_id) AS guest_count,
     166       (v.price_per_guest * COUNT(g.guest_id)) AS estimated_total_cost
     167FROM Wedding w
     168JOIN Guest g ON w.wedding_id = g.wedding_id
     169JOIN Venue v ON v.venue_id = 1
     170WHERE w.wedding_id = 1
     171GROUP BY w.wedding_id, v.name, v.price_per_guest;
     172}}}
     173
     174== Conclusion
     175These SQL scenarios demonstrate how the database supports the main wedding planning operations:
     176user and wedding management, event scheduling, guest tracking, attendance recording, and venue bookings.