Changes between Version 1 and Version 2 of UseCase04


Ignore:
Timestamp:
05/17/26 19:59:35 (8 days ago)
Author:
181201
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • UseCase04

    v1 v2  
    66
    77'''Description:'''
    8 A Pet Owner finds a Pet Sitter they like and requests a booking. They must select the specific service they want. The system creates the booking and links the requested services using a secure database transaction.
     8A Pet Owner finds a Pet Sitter they like and requests a booking. The system creates the booking and links the selected pets using a secure database transaction.
    99
    1010'''Scenario:'''
    11  1. Pet Owner views the profile of a sitter (e.g., `sitter_filip`) and clicks "Request Booking".
    12  2. System provides the specific services that this sitter offers to display in the booking form:
     11 1. Pet Owner views the profile of a sitter and clicks "Book Now".
     12 2. Owner fills out the dates, location, selects the pets, and submits.
     13 3. System creates the booking with a 'Pending' status:
    1314{{{
    1415#!sql
    15 SELECT s.service_id, s.type, s.description
    16 FROM services s
    17 JOIN sitter_services ss ON s.service_id = ss.service_id
    18 WHERE ss.sitter_id = (SELECT user_id FROM users WHERE username = 'sitter_filip');
     16INSERT INTO bookings (status, date_from, date_to, address, owner_id, sitter_id)
     17VALUES (
     18    'Pending', '2026-06-10', '2026-06-12', 'ul. Partizanska br. 10',
     19    (SELECT user_id FROM users WHERE username = 'owner_bojan'),
     20    (SELECT user_id FROM users WHERE username = 'sitter_filip')
     21);
    1922}}}
    20  3. Owner fills out the dates, location, selects the service, and submits.
    21  4. System creates the booking with a 'PENDING' status and attaches the requested service simultaneously:
    22 {{{
    23 #!sql
    24 BEGIN;
    25 
    26 WITH new_booking AS (
    27     INSERT INTO bookings (status, date_from, date_to, address, owner_id, sitter_id)
    28     VALUES (
    29         'PENDING', '2026-06-10', '2026-06-12', 'ul. Partizanska br. 10',
    30         (SELECT user_id FROM users WHERE username = 'owner_bojan'),
    31         (SELECT user_id FROM users WHERE username = 'sitter_filip')
    32     )
    33     RETURNING booking_id
    34 )
    35 INSERT INTO booking_services (booking_id, service_id)
    36 SELECT nb.booking_id, (SELECT service_id FROM services WHERE type = 'Dog Walking')
    37 FROM new_booking nb;
    38 
    39 COMMIT;
    40 }}}