| | 1 | = Entity-Relationship Model v.01 = |
| | 2 | |
| | 3 | == Diagram == |
| | 4 | |
| | 5 | [[Image(diagrams/ERModel_v01.png, width=100%)]] |
| | 6 | |
| | 7 | == Data Requirements == |
| | 8 | |
| | 9 | === Entities === |
| | 10 | |
| | 11 | ==== Users ==== |
| | 12 | '''Description:''' Users represents all individuals who interact with the system. This includes teaching staff who reserve resources for lectures and research, students who view availability and access permitted resources, and faculty administrators who manage the system. The entity is central to tracking who makes reservations and who approves them. |
| | 13 | |
| | 14 | '''Candidate Keys:''' |
| | 15 | * Primary key: user_id (chosen as a surrogate key for efficiency and to avoid issues with changing natural identifiers) |
| | 16 | * Alternative candidates: email (unique per user, but may change) |
| | 17 | |
| | 18 | '''Attributes:''' |
| | 19 | ||'''Attribute'''||'''Data Type'''||'''Constraints'''||'''Description'''|| |
| | 20 | ||user_id||INTEGER||PK, NOT NULL||Unique identifier for each user|| |
| | 21 | ||first_name||VARCHAR(128)||NOT NULL||User's first name|| |
| | 22 | ||last_name||VARCHAR(128)||NOT NULL||User's family name|| |
| | 23 | ||email||VARCHAR(128)||NOT NULL, UNIQUE||Institutional email address used for login|| |
| | 24 | ||password||VARCHAR(128)||NOT NULL||Hashed password for authentication|| |
| | 25 | |
| | 26 | ==== UserTypes ==== |
| | 27 | '''Description:''' UserTypes categorizes users into different roles within the system. This entity enables role-based access control, distinguishing between teaching staff, students, and faculty administrators. Each role has different permissions for viewing, reserving, and managing resources. |
| | 28 | |
| | 29 | '''Candidate Keys:''' |
| | 30 | * Primary key: type_id (surrogate key for referential integrity) |
| | 31 | * Alternative candidates: type_name (unique, but surrogate preferred for foreign key references) |
| | 32 | |
| | 33 | '''Attributes:''' |
| | 34 | ||'''Attribute'''||'''Data Type'''||'''Constraints'''||'''Description'''|| |
| | 35 | ||type_id||INTEGER||PK, NOT NULL||Unique identifier for each user type|| |
| | 36 | ||type_name||VARCHAR(128)||NOT NULL, UNIQUE||Name of the role (e.g., 'Student', 'Teaching Staff', 'Administrator')|| |
| | 37 | ||description||VARCHAR(128)||NOT NULL||Detailed description of the role's permissions and purpose|| |
| | 38 | |
| | 39 | ==== Resources ==== |
| | 40 | '''Description:''' Resources represents all physical and digital items that can be reserved within the faculty. Physical resources include laboratory equipment, projectors, rooms, and specialized tools. Digital resources may include software licenses, virtual machines, or online services. This entity is central to the reservation system. |
| | 41 | |
| | 42 | '''Candidate Keys:''' |
| | 43 | * Primary key: resource_id (surrogate key for efficiency) |
| | 44 | * Alternative candidates: name (if unique within the system) |
| | 45 | |
| | 46 | '''Attributes:''' |
| | 47 | ||'''Attribute'''||'''Data Type'''||'''Constraints'''||'''Description'''|| |
| | 48 | ||resource_id||INTEGER||PK, NOT NULL||Unique identifier for each resource|| |
| | 49 | ||name||VARCHAR(128)||NOT NULL||Descriptive name of the resource|| |
| | 50 | ||description||VARCHAR(128)||NOT NULL||Detailed description including specifications, capacity, or usage instructions|| |
| | 51 | |
| | 52 | ==== ResourceTypes ==== |
| | 53 | '''Description:''' ResourceTypes categorizes resources into different types for easier navigation and filtering. Examples include 'Laboratory Equipment', 'Classroom', 'Software License', 'Projector', etc. The is_physical attribute distinguishes between physical resources (that have a location) and digital resources. |
| | 54 | |
| | 55 | '''Candidate Keys:''' |
| | 56 | * Primary key: type_id (surrogate key for referential integrity) |
| | 57 | * Alternative candidates: type_name (unique, but surrogate preferred) |
| | 58 | |
| | 59 | '''Attributes:''' |
| | 60 | ||'''Attribute'''||'''Data Type'''||'''Constraints'''||'''Description'''|| |
| | 61 | ||type_id||INTEGER||PK, NOT NULL||Unique identifier for each resource type|| |
| | 62 | ||type_name||VARCHAR(128)||NOT NULL, UNIQUE||Name of the category (e.g., 'Projector', 'Laboratory', 'Software')|| |
| | 63 | ||is_physical||VARCHAR(128)||NOT NULL||Indicates if resources of this type are physical ('Y') or digital ('N')|| |
| | 64 | |
| | 65 | ==== Locations ==== |
| | 66 | '''Description:''' Locations stores information about physical places where resources can be found. This enables users to know where to pick up or use a resource. Only physical resources are linked to locations; digital resources do not require this association. |
| | 67 | |
| | 68 | '''Candidate Keys:''' |
| | 69 | * Primary key: location_id (surrogate key for efficiency) |
| | 70 | * Alternative candidates: (building, room) composite key |
| | 71 | |
| | 72 | '''Attributes:''' |
| | 73 | ||'''Attribute'''||'''Data Type'''||'''Constraints'''||'''Description'''|| |
| | 74 | ||location_id||INTEGER||PK, NOT NULL||Unique identifier for each location|| |
| | 75 | ||building||VARCHAR(128)||NOT NULL||Building name or code (e.g., 'TMF', 'FINKI-A')|| |
| | 76 | ||room||VARCHAR(128)||NOT NULL||Room number or name within the building|| |
| | 77 | |
| | 78 | ==== Reservations ==== |
| | 79 | '''Description:''' Reservations is the core transactional entity that records each booking of a resource by a user. It tracks the time period, status (pending, approved, rejected, completed), and purpose of each reservation. This entity connects users with resources and enables conflict detection and usage analytics. |
| | 80 | |
| | 81 | '''Candidate Keys:''' |
| | 82 | * Primary key: reservation_id (surrogate key for unique identification) |
| | 83 | * Alternative candidates: None suitable (combination of user, resource, and time could work but is complex) |
| | 84 | |
| | 85 | '''Attributes:''' |
| | 86 | ||'''Attribute'''||'''Data Type'''||'''Constraints'''||'''Description'''|| |
| | 87 | ||reservation_id||INTEGER||PK, NOT NULL||Unique identifier for each reservation|| |
| | 88 | ||start_time||TIMESTAMP||NOT NULL||When the reservation begins|| |
| | 89 | ||end_time||TIMESTAMP||NOT NULL||When the reservation ends (must be after start_time)|| |
| | 90 | ||status||VARCHAR(128)||NOT NULL||Current status: 'pending', 'approved', 'rejected', 'completed', 'cancelled'|| |
| | 91 | ||purpose||VARCHAR(128)||NOT NULL||Description of why the resource is being reserved|| |
| | 92 | ||created_at||TIMESTAMP||NOT NULL||When the reservation was created in the system|| |
| | 93 | |
| | 94 | ==== AvailabilitySlots ==== |
| | 95 | '''Description:''' AvailabilitySlots defines recurring time windows when resources are available for reservation. Rather than storing availability for each specific date, this entity stores patterns (e.g., "Mondays 9:00-17:00") that apply weekly. This simplifies availability management and reduces data redundancy. |
| | 96 | |
| | 97 | '''Candidate Keys:''' |
| | 98 | * Primary key: slot_id (surrogate key for efficiency) |
| | 99 | * Alternative candidates: None suitable (same day/time combination may apply to different resources) |
| | 100 | |
| | 101 | '''Attributes:''' |
| | 102 | ||'''Attribute'''||'''Data Type'''||'''Constraints'''||'''Description'''|| |
| | 103 | ||slot_id||INTEGER||PK, NOT NULL||Unique identifier for each availability slot|| |
| | 104 | ||day_of_week||VARCHAR(128)||NOT NULL||Day name (e.g., 'Monday', 'Tuesday') or number (1-7)|| |
| | 105 | ||start_time||TIME||NOT NULL||When the availability window starts on that day|| |
| | 106 | ||end_time||TIME||NOT NULL||When the availability window ends (must be after start_time)|| |
| | 107 | |
| | 108 | ==== RecurrencePatterns ==== |
| | 109 | '''Description:''' RecurrencePatterns enables reservations to repeat automatically according to defined rules. This is useful for recurring events like weekly lectures or monthly equipment maintenance. Instead of creating multiple individual reservations, a single reservation can reference a pattern that defines how it repeats. |
| | 110 | |
| | 111 | '''Candidate Keys:''' |
| | 112 | * Primary key: pattern_id (surrogate key for unique identification) |
| | 113 | * Alternative candidates: None suitable |
| | 114 | |
| | 115 | '''Attributes:''' |
| | 116 | ||'''Attribute'''||'''Data Type'''||'''Constraints'''||'''Description'''|| |
| | 117 | ||pattern_id||INTEGER||PK, NOT NULL||Unique identifier for each recurrence pattern|| |
| | 118 | ||pattern_type||VARCHAR(128)||NOT NULL||Type of recurrence: 'daily', 'weekly', 'biweekly', 'monthly'|| |
| | 119 | ||interval_days||INTEGER||NOT NULL||Number of days between occurrences|| |
| | 120 | ||end_date||DATE||NULL||When the recurrence ends (NULL means indefinite)|| |
| | 121 | |
| | 122 | === Relationships === |
| | 123 | |
| | 124 | ==== has_type (Users - UserTypes) ==== |
| | 125 | '''Description:''' Each user is assigned exactly one user type that determines their role and permissions in the system. A user type can be assigned to many users. This is a mandatory relationship for users (total participation) since every user must have a defined role. |
| | 126 | |
| | 127 | '''Cardinality:''' N:1 (Many users to one user type) |
| | 128 | |
| | 129 | '''Participation:''' |
| | 130 | * Users: Total (every user must have a type) |
| | 131 | * UserTypes: Partial (a type may exist without assigned users) |
| | 132 | |
| | 133 | ==== makes (Users - Reservations) ==== |
| | 134 | '''Description:''' Users create reservations for resources. One user can make multiple reservations over time, but each reservation is made by exactly one user. This relationship tracks who requested each reservation. |
| | 135 | |
| | 136 | '''Cardinality:''' 1:N (One user makes many reservations) |
| | 137 | |
| | 138 | '''Participation:''' |
| | 139 | * Users: Partial (not all users make reservations) |
| | 140 | * Reservations: Total (every reservation has a creator) |
| | 141 | |
| | 142 | ==== approves (Users - Reservations) ==== |
| | 143 | '''Description:''' Faculty administrators approve or reject reservations. This relationship is separate from 'makes' to distinguish between the user who requested a reservation and the administrator who processed it. One administrator can approve many reservations. |
| | 144 | |
| | 145 | '''Cardinality:''' 1:N (One administrator approves many reservations) |
| | 146 | |
| | 147 | '''Participation:''' |
| | 148 | * Users: Partial (only administrators approve) |
| | 149 | * Reservations: Partial (pending reservations have no approver yet) |
| | 150 | |
| | 151 | ==== reserved_in (Reservations - Resources) ==== |
| | 152 | '''Description:''' Each reservation is for exactly one resource. A resource can have many reservations over time (though not overlapping for the same time period). This is a mandatory relationship for reservations since every booking must specify what is being reserved. |
| | 153 | |
| | 154 | '''Cardinality:''' N:1 (Many reservations to one resource) |
| | 155 | |
| | 156 | '''Participation:''' |
| | 157 | * Reservations: Total (every reservation must be for a resource) |
| | 158 | * Resources: Partial (a resource may have no reservations) |
| | 159 | |
| | 160 | ==== categorized_as (Resources - ResourceTypes) ==== |
| | 161 | '''Description:''' Each resource belongs to exactly one resource type for categorization purposes. This enables filtering and determines whether the resource is physical (requires location) or digital. The relationship is mandatory for resources. |
| | 162 | |
| | 163 | '''Cardinality:''' N:1 (Many resources to one resource type) |
| | 164 | |
| | 165 | '''Participation:''' |
| | 166 | * Resources: Total (every resource must have a type) |
| | 167 | * ResourceTypes: Partial (a type may exist without resources) |
| | 168 | |
| | 169 | ==== located_at (Resources - Locations) ==== |
| | 170 | '''Description:''' Physical resources are associated with a location where they can be found or used. Digital resources do not have locations. One location can house multiple resources (e.g., a lab room with multiple pieces of equipment). |
| | 171 | |
| | 172 | '''Cardinality:''' N:1 (Many resources to one location) |
| | 173 | |
| | 174 | '''Participation:''' |
| | 175 | * Resources: Partial (only physical resources have locations) |
| | 176 | * Locations: Partial (a location may have no resources assigned) |
| | 177 | |
| | 178 | ==== available_during (Resources - AvailabilitySlots) ==== |
| | 179 | '''Description:''' This many-to-many relationship defines when each resource is available for reservation. A resource can have multiple availability slots (e.g., available Monday-Friday 8:00-18:00), and the same slot pattern can apply to multiple resources. |
| | 180 | |
| | 181 | '''Cardinality:''' M:N (Many resources to many availability slots) |
| | 182 | |
| | 183 | '''Participation:''' |
| | 184 | * Resources: Partial (some resources may be available anytime) |
| | 185 | * AvailabilitySlots: Partial (slots are defined independently) |
| | 186 | |
| | 187 | ==== follows (Reservations - RecurrencePatterns) ==== |
| | 188 | '''Description:''' Reservations can optionally follow a recurrence pattern for repeating bookings. When a reservation references a pattern, the system generates or recognizes repeated occurrences according to the pattern rules. Most reservations are one-time and do not use this relationship. |
| | 189 | |
| | 190 | '''Cardinality:''' N:1 (Many reservations to one pattern) |
| | 191 | |
| | 192 | '''Participation:''' |
| | 193 | * Reservations: Partial (only recurring reservations have patterns) |
| | 194 | * RecurrencePatterns: Partial (patterns exist independently) |
| | 195 | |
| | 196 | == Entity-Relationship Model History == |
| | 197 | |
| | 198 | ||'''Version'''||'''Date'''||'''Changes'''|| |
| | 199 | ||v01||2025-01-19||Initial version with 8 entities and 8 relationships|| |
| | 200 | |
| | 201 | == Attachments == |
| | 202 | |
| | 203 | * [[attachment:diagrams/ERModel_v01.xml|ERModel_v01.xml]] (TerraER source file) |
| | 204 | * [[attachment:diagrams/ERModel_v01.png|ERModel_v01.png]] (Exported diagram image) |