| | 1 | = UC0002 Prototype Implementation - Make a Resource Reservation = |
| | 2 | |
| | 3 | '''Initiating actor:''' Teaching Staff |
| | 4 | |
| | 5 | '''Other actors:''' Faculty Administrator (receives pending reservation for approval) |
| | 6 | |
| | 7 | A teaching staff member selects a resource from a list, enters the desired date, time, and purpose. The system validates the availability window, checks for scheduling conflicts, and if the slot is free, creates a new reservation with status ''pending''. |
| | 8 | |
| | 9 | == Scenario == |
| | 10 | |
| | 11 | 1. The user selects ''Make a Resource Reservation'' from the main menu. The system displays all resources as a numbered list. The user selects ''Classroom 101''. |
| | 12 | {{{ |
| | 13 | SELECT r.resource_id, r.name, r.description, |
| | 14 | r.available_from, r.available_to, r.available_weekends, |
| | 15 | rt.type_name, l.building, l.room |
| | 16 | FROM resources r |
| | 17 | JOIN resource_types rt ON r.type_id = rt.type_id |
| | 18 | LEFT JOIN locations l ON r.location_id = l.location_id |
| | 19 | ORDER BY rt.type_name, r.name; |
| | 20 | }}} |
| | 21 | |
| | 22 | 2. The system shows the resource details and existing reservations for the next 7 days. |
| | 23 | {{{ |
| | 24 | SELECT res.start_time, res.end_time, res.status, res.purpose, |
| | 25 | u.first_name || ' ' || u.last_name AS reserved_by |
| | 26 | FROM reservations res |
| | 27 | JOIN users u ON res.user_id = u.user_id |
| | 28 | WHERE res.resource_id = 1 |
| | 29 | AND res.status IN ('approved', 'pending') |
| | 30 | AND res.start_time >= CURRENT_DATE AND res.start_time < CURRENT_DATE + 7 |
| | 31 | ORDER BY res.start_time; |
| | 32 | }}} |
| | 33 | |
| | 34 | 3. The user enters the reservation details: date 2026-02-13, time 10:00 to 12:00, purpose ''Operating Systems Lecture''. |
| | 35 | |
| | 36 | 4. The system validates the availability window. |
| | 37 | {{{ |
| | 38 | Reservation date (YYYY-MM-DD): 2026-02-13 |
| | 39 | Start time (HH:MM): 10:00 |
| | 40 | End time (HH:MM): 12:00 |
| | 41 | Purpose: Operating Systems Lecture |
| | 42 | }}} |
| | 43 | |
| | 44 | 5. The system checks for conflicting reservations and finds none. |
| | 45 | {{{ |
| | 46 | SELECT res.reservation_id, res.start_time, res.end_time, |
| | 47 | res.purpose, |
| | 48 | u.first_name || ' ' || u.last_name AS reserved_by |
| | 49 | FROM reservations res |
| | 50 | JOIN users u ON res.user_id = u.user_id |
| | 51 | WHERE res.resource_id = 1 |
| | 52 | AND res.status IN ('approved', 'pending') |
| | 53 | AND res.start_time < '2026-02-13 12:00:00' |
| | 54 | AND res.end_time > '2026-02-13 10:00:00'; |
| | 55 | }}} |
| | 56 | |
| | 57 | 6. The user confirms the reservation. The system inserts the new reservation with status ''pending'': |
| | 58 | {{{ |
| | 59 | INSERT INTO reservations |
| | 60 | (start_time, end_time, status, purpose, created_at, user_id, resource_id) |
| | 61 | VALUES ('2026-02-13 10:00:00', '2026-02-13 12:00:00', 'pending', |
| | 62 | 'Operating Systems Lecture', CURRENT_TIMESTAMP, 3, 1) |
| | 63 | RETURNING reservation_id, status, created_at; |
| | 64 | }}} |
| | 65 | |
| | 66 | The system confirms the reservation was created: |
| | 67 | {{{ |
| | 68 | Reservation created successfully! |
| | 69 | Reservation ID: 34 |
| | 70 | Status: pending (awaiting administrator approval) |
| | 71 | }}} |
| | 72 | |
| | 73 | == Alternative: Conflict Detected == |
| | 74 | |
| | 75 | 5a. If the user had requested 2026-02-06 from 09:00 to 11:00, the conflict check would find an overlapping reservation. The system displays the conflicts and offers to try a different time. |
| | 76 | {{{ |
| | 77 | CONFLICT: 1 overlapping reservation(s) found: |
| | 78 | ID | Start | End | Purpose | Reserved by |
| | 79 | ---+------------------+------------------+----------------------------+------------------ |
| | 80 | 24 | 2026-02-06 08:00 | 2026-02-06 10:00 | Morning lecture - Operatin | Elena Stojanova |
| | 81 | |
| | 82 | Try a different time? (y/n): |
| | 83 | }}} |