| | 1 | = ERModel v01 |
| | 2 | |
| | 3 | == Diagram |
| | 4 | [[Image(ERModel_v01.jpg)]] |
| | 5 | |
| | 6 | == Entities |
| | 7 | |
| | 8 | {{{User}}} |
| | 9 | |
| | 10 | This is the core entity that represents every person registered on [https://develop.finki.ukim.mk/projects/petsitter/#PetSitter PetSitter]. It acts as a supertype for {{{Admin}}}/{{{PetOwner}}}/{{{PetSitter}}} so we can store the common attributes only in {{{User}}}. |
| | 11 | |
| | 12 | '''Candidate keys:''' |
| | 13 | * {{{user_id}}} - '''Primary key'''; numeric id, most efficient for indexing |
| | 14 | * {{{username}}} - unique but not as efficient as {{{user_id}}} |
| | 15 | * {{{email}}} - unique but not as efficient as {{{user_id}}} |
| | 16 | |
| | 17 | '''Attributes:''' |
| | 18 | |
| | 19 | * {{{user_id}}} - Numeric (Required, Unique, Auto-generated integer). |
| | 20 | |
| | 21 | * {{{username}}} - Text (Required, Unique, 4-20 characters). |
| | 22 | |
| | 23 | * {{{first_name}}} - Text (Required). |
| | 24 | |
| | 25 | * {{{last_name}}} - Text (Required). |
| | 26 | |
| | 27 | * {{{password}}} - Text (Required, Hashed format, Min. 8 characters). |
| | 28 | |
| | 29 | * {{{email}}} - Text (Required, Unique, Standard email format). |
| | 30 | |
| | 31 | ---- |
| | 32 | |
| | 33 | {{{Admin}}} |
| | 34 | |
| | 35 | Subtype/specialization of {{{User}}} entity. Inherits from {{{User}}}. Has administrator privileges. |
| | 36 | |
| | 37 | '''Candidate keys:''' |
| | 38 | * {{{user_id}}} - Inherits {{{user_id}}} from {{{User}}} |
| | 39 | |
| | 40 | '''Attributes:''' |
| | 41 | |
| | 42 | * Inherits all attributes from {{{User}}} |
| | 43 | |
| | 44 | ---- |
| | 45 | |
| | 46 | {{{PetOwner}}} |
| | 47 | |
| | 48 | Subtype/specialization of {{{User}}} entity. Inherits from {{{User}}}. Is able to make bookings for their {{{Pet}}} and request a {{{PetSitter}}}. |
| | 49 | |
| | 50 | '''Candidate keys:''' |
| | 51 | * {{{user_id}}} - Inherits {{{user_id}}} from {{{User}}} |
| | 52 | |
| | 53 | '''Attributes:''' |
| | 54 | |
| | 55 | * Inherits all attributes from {{{User}}} |
| | 56 | |
| | 57 | ---- |
| | 58 | |
| | 59 | {{{PetSitter}}} |
| | 60 | |
| | 61 | Subtype/specialization of {{{User}}} entity. Inherits from {{{User}}}. Provides services to {{{PetOwner}}}. Is able to confirm or deny bookings. |
| | 62 | |
| | 63 | '''Candidate keys:''' |
| | 64 | * {{{user_id}}} - Inherits {{{user_id}}} from {{{User}}} |
| | 65 | |
| | 66 | '''Attributes:''' |
| | 67 | |
| | 68 | * Inherits all attributes from {{{User}}} |
| | 69 | |
| | 70 | ---- |
| | 71 | |
| | 72 | {{{Pet}}} |
| | 73 | |
| | 74 | The animal that will be taken care of. Track the identity, special needs, age of the pet in the booking. Linked to {{{PetType}}} to categorize animals more efficiently. |
| | 75 | |
| | 76 | '''Candidate keys:''' |
| | 77 | * {{{pet_id}}} - '''Primary key'''; Unique surrogate key. |
| | 78 | |
| | 79 | '''Attributes:''' |
| | 80 | |
| | 81 | * {{{pet_id}}} - Numeric (Required, Unique, Auto-generated integer). |
| | 82 | |
| | 83 | * {{{name}}} - Text (Required). |
| | 84 | |
| | 85 | * {{{photo}}} - Text/URL (Optional, URL format). |
| | 86 | |
| | 87 | * {{{age}}} - Numeric (Required, non-negative integer). |
| | 88 | |
| | 89 | * {{{password}}} - Text (Required, Hashed format, Min. 8 characters). |
| | 90 | |
| | 91 | * {{{special_needs}}} - Text (Optional). |
| | 92 | |
| | 93 | * {{{description}}} - Text (Optional). |
| | 94 | |
| | 95 | ---- |
| | 96 | |
| | 97 | {{{PetType}}} |
| | 98 | |
| | 99 | Entity used to categorize pets (for example Cat, Dog, Rabbit, Bird). Used for storing attributes that would repeat a lot of times in one single {{{Pet}}} entity. |
| | 100 | |
| | 101 | '''Candidate keys:''' |
| | 102 | * {{{pet_id}}} - '''Primary key'''; Unique surrogate key. |
| | 103 | * {{{species}}} - Unique but not as efficient as a numeric id key. |
| | 104 | |
| | 105 | '''Attributes:''' |
| | 106 | |
| | 107 | * {{{pettype_id}}} - Numeric (Required, Unique, Auto-generated integer). |
| | 108 | |
| | 109 | * {{{species}}} - Text (Required, Unique). |
| | 110 | |
| | 111 | * {{{average_lifespan}}} - Numeric (Optional). |
| | 112 | |
| | 113 | * {{{needs_outdoor_walk}}} - Boolean (Required, 0 or 1). |
| | 114 | |
| | 115 | |
| | 116 | ---- |
| | 117 | |
| | 118 | {{{Booking}}} |
| | 119 | |
| | 120 | The entity that connects {{{PetOwner}}}, {{{PetSitter}}}, {{{Pet}}} and the services requested for the {{{Pet}}} |
| | 121 | |
| | 122 | '''Candidate keys:''' |
| | 123 | * {{{booking_id}}} - '''Primary key'''; Unique surrogate key. |
| | 124 | |
| | 125 | '''Attributes:''' |
| | 126 | |
| | 127 | * {{{booking_id}}} - Numeric (Required, Unique, Auto-generated integer). |
| | 128 | |
| | 129 | * {{{status}}} - Text (Required, for example 'Pending', 'Confirmed', 'Completed', 'Rejected'). |
| | 130 | |
| | 131 | * {{{date_from}}} - Date (Required). |
| | 132 | |
| | 133 | * {{{date_to}}} - Date (Required). |
| | 134 | |
| | 135 | * {{{address}}} - Text (Required, location of the service). |
| | 136 | |
| | 137 | ---- |
| | 138 | |
| | 139 | {{{Review}}} |
| | 140 | |
| | 141 | The feedback that the {{{PetOwner}}} leaves for the {{{PetSitter}}} after a completed {{{Booking}}}. This is mandatory to maintain trust and establish quality on the platform. |
| | 142 | |
| | 143 | '''Candidate keys:''' |
| | 144 | * {{{review_id}}} - '''Primary key'''; Unique surrogate key. |
| | 145 | |
| | 146 | '''Attributes:''' |
| | 147 | |
| | 148 | * {{{review_id}}} - Numeric (Required, Unique, Auto-generated integer). |
| | 149 | |
| | 150 | * {{{rating}}} - Numeric (Required, Integer from 1 to 5). |
| | 151 | |
| | 152 | * {{{comment}}} - Text (Optional). |
| | 153 | |
| | 154 | ---- |
| | 155 | |
| | 156 | {{{Service}}} |
| | 157 | |
| | 158 | Defines the type of care offered for the {{{Pet}}}, for example walking, overnight stay or short visit. If needed new services can be added without changing the database schema. |
| | 159 | |
| | 160 | '''Candidate keys:''' |
| | 161 | * {{{service_id}}} - '''Primary key'''; Unique surrogate key. |
| | 162 | |
| | 163 | '''Attributes:''' |
| | 164 | |
| | 165 | * {{{service_id}}} - Numeric (Required, Unique, Auto-generated integer). |
| | 166 | |
| | 167 | * {{{type}}} - Text (Required). |
| | 168 | |
| | 169 | * {{{description}}} - Text (Optional). |
| | 170 | |
| | 171 | |
| | 172 | ---- |
| | 173 | |
| | 174 | {{{Payment}}} |
| | 175 | |
| | 176 | Defines the financial transaction related to a {{{Booking}}}. |
| | 177 | |
| | 178 | '''Candidate keys:''' |
| | 179 | * {{{payment_id}}} - '''Primary key'''; Unique surrogate key. |
| | 180 | |
| | 181 | '''Attributes:''' |
| | 182 | |
| | 183 | * {{{payment_id}}} - Numeric (Required, Unique, Auto-generated integer). |
| | 184 | |
| | 185 | * {{{amount}}} - Numeric (Required, positive integer > 0). |
| | 186 | |
| | 187 | * {{{payment_type}}} - Text (Required, for example Cash or Card). |
| | 188 | |
| | 189 | == Relations |
| | 190 | |
| | 191 | {{{manage - Admin to User}}} |
| | 192 | * M:N relation |
| | 193 | * an {{{Admin}}} can manage multiple users, and a {{{User}}} can be managed by multiple admins. |
| | 194 | |
| | 195 | ---- |
| | 196 | |
| | 197 | {{{leaves - PetOwner to Review}}} |
| | 198 | * 1:N relation |
| | 199 | * one {{{PetOwner}}} can leave many reviews to sitters, but each {{{Review}}} has one unique owner. |
| | 200 | |
| | 201 | ---- |
| | 202 | |
| | 203 | {{{receives - Review to PetSitter}}} |
| | 204 | * 1:N relation |
| | 205 | * one {{{PetSitter}}} can receive many reviews from clients, but each {{{Review}}} is meant for one unique {{{PetSitter}}}. |
| | 206 | |
| | 207 | |
| | 208 | ---- |
| | 209 | |
| | 210 | {{{is_a - Pet to PetType}}} |
| | 211 | * M:1 relation |
| | 212 | * many Pets can have one {{{PetType}}} (for example Cat), but each {{{Pet}}} has exactly one type. |
| | 213 | |
| | 214 | ---- |
| | 215 | |
| | 216 | {{{is_for - Pet to Booking}}} |
| | 217 | * N:N relation |
| | 218 | * a {{{Booking}}} can have two pets from the same owner, while a {{{Pet}}} can be part of many bookings during its life. |
| | 219 | |
| | 220 | ---- |
| | 221 | |
| | 222 | {{{books - PetOwner to Booking}}} |
| | 223 | * 1:N relation |
| | 224 | * a {{{PetOwner}}} can schedule many bookings, but each {{{Booking}}} is created by and owned by one unique {{{PetOwner}}}. |
| | 225 | |
| | 226 | ---- |
| | 227 | |
| | 228 | {{{is_booked - Booking to PetSitter}}} |
| | 229 | * 1:N relation |
| | 230 | * a {{{PetSitter}}} can be booked for many bookings, but each {{{Booking}}} is assigned to only one {{{PetSitter}}} at a time. |
| | 231 | |
| | 232 | ---- |
| | 233 | |
| | 234 | {{{provides - PetSitter to Service}}} |
| | 235 | * M:N relation |
| | 236 | * a {{{PetSitter}}} can provide multiple services (Walking, Overnight stay) and a {{{Service}}} (Walking) can be provided by many different sitters. |
| | 237 | |
| | 238 | ---- |
| | 239 | |
| | 240 | {{{requires - Booking to Service}}} |
| | 241 | * M:N relation |
| | 242 | * a {{{Booking}}} can require multiple services (Walking, Overnight stay) and a specific {{{Service}}} type can be requested in many different bookings. |
| | 243 | |
| | 244 | ---- |
| | 245 | |
| | 246 | {{{charged - Booking to Payment}}} |
| | 247 | * 1:1 relation |
| | 248 | * each {{{Booking}}} has exactly one {{{Payment}}} record, and each {{{Payment}}} record is associated with exactly one {{{Booking}}} |