| | 1 | = Use-case 0002 Implementation - Create reservation request = |
| | 2 | |
| | 3 | == Initiating actor == |
| | 4 | |
| | 5 | Room Requester |
| | 6 | |
| | 7 | == Other actors == |
| | 8 | |
| | 9 | Reservation Approver |
| | 10 | |
| | 11 | == Description of the use-case goals == |
| | 12 | |
| | 13 | The goal of this use-case is to allow a room requester to create a new reservation request. The reservation may include a room, requested equipment, or both. In this prototype demonstration, the requester creates a reservation for a selected room and time interval. |
| | 14 | |
| | 15 | The prototype follows the instruction that the user should not be expected to remember database identifiers. Instead of manually entering user_id or room_id, the application lists available users and rooms, and the requester selects the appropriate values from the displayed lists. |
| | 16 | |
| | 17 | == Scenario == |
| | 18 | |
| | 19 | The Room Requester chooses the option ''Create reservation request'' from the main menu. |
| | 20 | The system displays a list of users. |
| | 21 | The Room Requester selects the requester from the list. |
| | 22 | The system asks for the reservation date. |
| | 23 | The Room Requester enters the date. |
| | 24 | The system asks for the start time and end time. |
| | 25 | The Room Requester enters the requested time interval. |
| | 26 | The system asks whether the reservation should include a room. |
| | 27 | The Room Requester chooses to include a room. |
| | 28 | The system asks for minimum capacity, room type, and optional required equipment in the room. |
| | 29 | The system displays available rooms that satisfy the selected criteria. |
| | 30 | The Room Requester selects one of the available rooms from the list. |
| | 31 | The system asks whether additional/general equipment should be requested. |
| | 32 | The Room Requester chooses whether to request additional equipment. |
| | 33 | The system inserts a new record into the ''project.reservations'' table with status ''pending''. |
| | 34 | If requested equipment is selected, the system inserts corresponding records into the ''project.reservation_equipment'' table. |
| | 35 | The system displays the created reservation details. |
| | 36 | |
| | 37 | == Screenshots == |
| | 38 | |
| | 39 | The following screenshot shows the selection of the requester and reservation parameters. |
| | 40 | |
| | 41 | [[Image(uc0002_choose_user_room.png, width=100%)]] |
| | 42 | |
| | 43 | The following screenshot shows the successfully created reservation request. |
| | 44 | |
| | 45 | [[Image(uc0002_reservation_created.png, width=100%)]] |
| | 46 | |
| | 47 | The following screenshot shows database verification in DBeaver after the reservation was created and later approved. |
| | 48 | |
| | 49 | [[Image(dbeaver_reservations_result.png, width=100%)]] |
| | 50 | |
| | 51 | == SQL commands used by the system == |
| | 52 | |
| | 53 | The system first reads the list of possible requesters. |
| | 54 | |
| | 55 | {{{ |
| | 56 | SELECT |
| | 57 | user_id, |
| | 58 | full_name, |
| | 59 | username, |
| | 60 | role, |
| | 61 | email |
| | 62 | FROM project.users |
| | 63 | ORDER BY user_id; |
| | 64 | }}} |
| | 65 | |
| | 66 | The system then searches for available rooms for the selected reservation date and time interval. |
| | 67 | |
| | 68 | {{{ |
| | 69 | SELECT |
| | 70 | r.room_id, |
| | 71 | r.room_code, |
| | 72 | r.capacity, |
| | 73 | r.type, |
| | 74 | b.name AS building_name, |
| | 75 | b.address |
| | 76 | FROM project.rooms r |
| | 77 | JOIN project.buildings b |
| | 78 | ON b.building_id = r.building_id |
| | 79 | WHERE r.capacity >= ? |
| | 80 | AND (? IS NULL OR r.type = ?) |
| | 81 | AND NOT EXISTS ( |
| | 82 | SELECT 1 |
| | 83 | FROM project.reservations res |
| | 84 | WHERE res.room_id = r.room_id |
| | 85 | AND res.reservation_date = ? |
| | 86 | AND res.status IN ('pending', 'approved') |
| | 87 | AND ? < res.end_time |
| | 88 | AND ? > res.start_time |
| | 89 | ) |
| | 90 | ORDER BY r.capacity, r.room_code; |
| | 91 | }}} |
| | 92 | |
| | 93 | After the requester selects a room, the system inserts the new reservation request. |
| | 94 | |
| | 95 | {{{ |
| | 96 | INSERT INTO project.reservations ( |
| | 97 | room_id, |
| | 98 | user_id, |
| | 99 | reservation_date, |
| | 100 | start_time, |
| | 101 | end_time, |
| | 102 | status |
| | 103 | ) |
| | 104 | VALUES (?, ?, ?, ?, ?, 'pending') |
| | 105 | RETURNING reservation_id; |
| | 106 | }}} |
| | 107 | |
| | 108 | If the requester also selects additional equipment, the system inserts records into ''project.reservation_equipment''. |
| | 109 | |
| | 110 | {{{ |
| | 111 | INSERT INTO project.reservation_equipment ( |
| | 112 | reservation_id, |
| | 113 | equipment_id, |
| | 114 | requested_quantity |
| | 115 | ) |
| | 116 | VALUES (?, ?, ?); |
| | 117 | }}} |
| | 118 | |
| | 119 | == Database usage explanation == |
| | 120 | |
| | 121 | This use-case reads data from the following tables: |
| | 122 | |
| | 123 | ''project.users'' – to allow the requester to be selected from a list. |
| | 124 | ''project.rooms'' – to display available rooms. |
| | 125 | ''project.buildings'' – to display the building name and address. |
| | 126 | ''project.reservations'' – to check room availability and to insert the new reservation. |
| | 127 | ''project.equipment'' – if additional equipment is requested. |
| | 128 | ''project.reservation_equipment'' – if equipment is included in the reservation request. |
| | 129 | |
| | 130 | This use-case modifies the database by inserting a new record into ''project.reservations''. The created reservation initially has the status ''pending''. |
| | 131 | |
| | 132 | == Result of the implementation == |
| | 133 | |
| | 134 | The prototype successfully creates a new reservation request. In the demonstrated test, the system created reservation ID 9 for requester Nikola Sarafimov, room LAB-1, date 2026-03-01, and time interval 09:00–10:00. The reservation was created with status ''pending'', which means it can later be reviewed by an approver. |