| | 1 | = Use-case 0001 - Search available rooms = |
| | 2 | |
| | 3 | '''Initiating actor:''' |
| | 4 | |
| | 5 | Room Requester |
| | 6 | |
| | 7 | '''Other actors:''' |
| | 8 | |
| | 9 | None |
| | 10 | |
| | 11 | '''Description of the use-case goals:''' |
| | 12 | |
| | 13 | The goal of this use case is to allow a room requester to search for rooms that are available for a selected date and time interval. The requester may also filter rooms by capacity, room type, and required equipment. The system reads data from the rooms, buildings, room_equipment, equipment, and reservations tables. The result is a list of rooms that satisfy the requested conditions and do not already have an active overlapping reservation. |
| | 14 | |
| | 15 | '''Scenario:''' |
| | 16 | |
| | 17 | The Room Requester enters the desired reservation date, start time, end time, minimum capacity, and room type. |
| | 18 | The system searches for rooms that satisfy the requested capacity and type. |
| | 19 | The system checks existing reservations and excludes rooms that already have a pending or approved reservation in an overlapping time interval. |
| | 20 | The system displays the available rooms to the actor. |
| | 21 | If the actor also requests specific equipment, the system filters rooms according to the equipment assigned to them. |
| | 22 | The actor chooses one of the available rooms or changes the search criteria. |
| | 23 | |
| | 24 | '''SQL commands used by the system:''' |
| | 25 | |
| | 26 | Search available rooms for a selected date, time interval, capacity, and type: |
| | 27 | |
| | 28 | {{{ |
| | 29 | SELECT |
| | 30 | r.room_id, |
| | 31 | r.room_code, |
| | 32 | r.capacity, |
| | 33 | r.type, |
| | 34 | b.name AS building_name, |
| | 35 | b.address |
| | 36 | FROM project.rooms r |
| | 37 | JOIN project.buildings b |
| | 38 | ON b.building_id = r.building_id |
| | 39 | WHERE r.capacity >= 30 |
| | 40 | AND r.type IN ('classroom', 'meeting_room') |
| | 41 | AND NOT EXISTS ( |
| | 42 | SELECT 1 |
| | 43 | FROM project.reservations res |
| | 44 | WHERE res.room_id = r.room_id |
| | 45 | AND res.reservation_date = DATE '2026-02-15' |
| | 46 | AND res.status IN ('pending', 'approved') |
| | 47 | AND TIME '10:00' < res.end_time |
| | 48 | AND TIME '12:00' > res.start_time |
| | 49 | ) |
| | 50 | ORDER BY r.capacity, r.room_code; |
| | 51 | }}} |
| | 52 | |
| | 53 | Search available rooms that also contain a specific equipment type: |
| | 54 | |
| | 55 | {{{ |
| | 56 | SELECT |
| | 57 | r.room_id, |
| | 58 | r.room_code, |
| | 59 | r.capacity, |
| | 60 | r.type, |
| | 61 | b.name AS building_name, |
| | 62 | e.name AS equipment_name, |
| | 63 | re.quantity |
| | 64 | FROM project.rooms r |
| | 65 | JOIN project.buildings b |
| | 66 | ON b.building_id = r.building_id |
| | 67 | JOIN project.room_equipment re |
| | 68 | ON re.room_id = r.room_id |
| | 69 | JOIN project.equipment e |
| | 70 | ON e.equipment_id = re.equipment_id |
| | 71 | WHERE r.capacity >= 20 |
| | 72 | AND e.name = 'Projector' |
| | 73 | AND NOT EXISTS ( |
| | 74 | SELECT 1 |
| | 75 | FROM project.reservations res |
| | 76 | WHERE res.room_id = r.room_id |
| | 77 | AND res.reservation_date = DATE '2026-02-15' |
| | 78 | AND res.status IN ('pending', 'approved') |
| | 79 | AND TIME '10:00' < res.end_time |
| | 80 | AND TIME '12:00' > res.start_time |
| | 81 | ) |
| | 82 | ORDER BY r.room_code; |
| | 83 | }}} |