Hotel management
Both diagrams. Every relationship. All modeling assumptions.
15 entities and tables, 26 relationships and foreign keys, 39 relational columns, two junction tables and one weak entity. This file includes both vector diagrams and works offline.
The accepted model is retained and extended with one new weak entity, ROOM_FEATURE. This document contains 15 entity/table definitions, 26 relationships/foreign keys, 39 relational columns, two junction tables and one weak-entity table.
New weak entity: ROOM_FEATURE
A feature is a room-owned occurrence, such as a feature code recorded for a particular room. It is not a shared feature catalogue. The code identifies a feature only within its owning room.
| Column | Provisional type | Relational role |
|---|---|---|
| room_id | BIGINT | PK component + NOT NULL FK to ROOM.room_id |
| feature_code | VARCHAR(64) | PK component + NOT NULL; local discriminator |
Primary key: (room_id, feature_code). The same code may occur in different rooms; the same pair may occur only once. A room has 0..N features and every feature belongs to exactly one room. No surrogate feature ID is added.
Chen notation: double rectangle = weak entity; double diamond = identifying relationship; double line = total participation; dashed underline = partial key. The ROOM identifier is inherited through ownership.
Lifecycle assumption: NO ACTION on owner deletion and key updates. Remove dependent feature rows first; an owner cannot be deleted while references remain. Existence dependence does not itself imply cascading deletion.
Chen ER diagram
All 15 entities and 26 relationships, including ROOM_FEATURE and its identifying relationship.
Zoom in to read the labels, then scroll within the diagram. Fit diagram restores the full view.
Relational table model
Primary keys, foreign keys, junction tables and weak identity. Arrowheads point to the foreign-key rows.
Zoom in to read the labels, then scroll within the diagram. Fit diagram restores the full view.
Relationship register
All original relationships (r01-r25), plus the new identifying relationship (r26).
| ID | Parent / relationship | Child / foreign key | Per parent | Per child |
|---|---|---|---|---|
| r01 | HOTELDEFINES | ROOM_TYPEhotel_id | 1..N | 1..1 |
| r02 | HOTELCONTAINS | ROOMhotel_id | 0..N | 1..1 |
| r03 | ROOM_TYPECLASSIFIES | ROOMroom_type_id | 0..N | 1..1 |
| r04 | GUESTMAKES | RESERVATIONbooked_by_guest_id | 0..N | 1..1 |
| r05 | HOTELRECEIVES | RESERVATIONhotel_id | 0..N | 1..1 |
| r06 | RESERVATIONRECEIVES | PAYMENTreservation_id | 0..N | 1..1 |
| r07 | RESERVATIONALLOCATES | RESERVATION_ROOMreservation_id | 1..N | 1..1 |
| r08 | ROOMRESERVED_IN | RESERVATION_ROOMroom_id | 0..N | 1..1 |
| r09 | RESERVATIONINCLUDES | STAY_GUESTreservation_id | 1..N | 1..1 |
| r10 | GUESTAPPEARS_IN | STAY_GUESTguest_id | 0..N | 1..1 |
| r11 | HOTELHAS | DEPARTMENThotel_id | 0..N | 1..1 |
| r12 | DEPARTMENTOWNS | SERVICEdepartment_id | 0..N | 1..1 |
| r13 | HOTELOFFERS | SERVICEhotel_id | 0..N | 1..1 |
| r14 | RESERVATIONINCURS | SERVICE_USAGEreservation_id | 0..N | 1..1 |
| r15 | GUESTBILLED_TO | SERVICE_USAGEguest_id | 0..N | 1..1 |
| r16 | ROOMPOSTED_TO | SERVICE_USAGEroom_id | 0..N | 1..1 |
| r17 | SERVICEAPPEARS_IN | SERVICE_USAGEservice_id | 0..N | 1..1 |
| r18 | HOTELEMPLOYS | EMPLOYEEhotel_id | 0..N | 1..1 |
| r19 | DEPARTMENTCONTAINS | EMPLOYEEdepartment_id | 0..N | 1..1 |
| r20 | ROOMSCHEDULES | HOUSEKEEPING_TASKroom_id | 0..N | 1..1 |
| r21 | EMPLOYEEPERFORMS | HOUSEKEEPING_TASKperformed_by_employee_id | 0..N | 0..1 |
| r22 | ROOMHAS | MAINTENANCE_REQUESTroom_id | 0..N | 1..1 |
| r23 | HOTELOWNS | MAINTENANCE_REQUESThotel_id | 0..N | 1..1 |
| r24 | EMPLOYEEREPORTS | MAINTENANCE_REQUESTreported_by_employee_id | 0..N | 0..1 |
| r25 | EMPLOYEEASSIGNED_TO | MAINTENANCE_REQUESTassigned_to_employee_id | 0..N | 0..1 |
| r26 | ROOMIDENTIFIES | ROOM_FEATUREroom_id | 0..N | 1..1 |
The booking guest is separate from the staying guests; inclusion among staying guests is not required. Reporting and assignment are independent employee roles. The r26 identifying relationship is mapped into ROOM_FEATURE.room_id, without a separate relationship table.
Mapping assumptions
Implementation choices and key semantics
M1. Scope and attribute selection
The supplied diagrams contained key attributes only. Preserve those keys and all 25 direct source links. Add only ROOM_FEATURE and its identifying link. Names, addresses, dates, amounts, prices and status fields are not invented.
M2. Identifier and code types
IDs use provisional BIGINT values, externally assigned. Sequence/identity generation and whether IDs must be positive are unspecified. feature_code uses provisional VARCHAR(64). The target DBMS, collation, code length enforcement and validation policy must be chosen before implementation.
M3. Foreign key placement
Every shown 1:N link maps to an FK on its child/N side. Relationship diamonds do not each become a table. Required child participation becomes NOT NULL; optional child participation becomes a nullable FK.
M4. Composite keys and event identity
RESERVATION_ROOM has PK (reservation_id, room_id); STAY_GUEST has PK (reservation_id, guest_id). Each component can repeat independently, but a pair cannot. ROOM_FEATURE adds the third composite PK. SERVICE_USAGE retains its own service_usage_id; repeated usages of the same four referenced objects are allowed.
M5. Nullable roles
Only HOUSEKEEPING_TASK.performed_by_employee_id, MAINTENANCE_REQUEST.reported_by_employee_id and MAINTENANCE_REQUEST.assigned_to_employee_id are nullable. Each role has at most one employee; reporter and assignee may be the same person. Employee FKs are not UNIQUE, so an employee can appear on many tasks and requests.
M6. Delete and update actions
All FKs, including the new weak-entity owner FK, use NO ACTION for deletes and key updates. No cascade, SET NULL, archiving or retention behavior was supplied. Do not infer these lifecycle policies from optionality or weakness.
M7. Drawing conventions
Arrows run from the referenced PK row to the child FK row; the arrowhead points to the FK. SQL REFERENCES reads in the reverse direction. Dashed amber arrows indicate nullable FKs. Bridge arcs are crossings without joins. PK/FK marks both roles; NN means NOT NULL. Blue marks junctions, not weak entities.
Integrity assumptions
What the keys enforce, and what needs transaction rules
I1. Parent minimum-child rules
The source requires each HOTEL to have at least one ROOM_TYPE, and each RESERVATION to have at least one RESERVATION_ROOM and one STAY_GUEST. Ordinary foreign keys and NOT NULL constraints check children against parents; they do not ensure parents have children. Apply these three checks at transaction completion using application logic or DBMS-specific deferred constraints/triggers. Draft reservations would need explicitly revised minimums.
I2. Consistent hotel ownership
Assume that every ownership path refers to the same hotel. In particular: ROOM.hotel_id agrees with its ROOM_TYPE; SERVICE.hotel_id and EMPLOYEE.hotel_id agree with their DEPARTMENT; and MAINTENANCE_REQUEST.hotel_id agrees with its ROOM. These are intended cross-table consistency rules, not additional independently enforced FKs.
I3. Same-hotel activity and staffing
Assume allocated rooms belong to the reservation hotel; a SERVICE_USAGE reservation, room and service share a hotel; an optional housekeeping performer belongs to the room hotel; and any maintenance reporter or assignee belongs to the request hotel. The model does not infer a hotel membership rule for GUEST.
I4. Faithful mapping and normalization
Direct HOTEL links are retained in ROOM, SERVICE, EMPLOYEE and MAINTENANCE_REQUEST even though hotel ownership is also derivable through ROOM_TYPE, DEPARTMENT or ROOM. These duplicated ownership paths can introduce transitive dependencies. This source-faithful conversion is therefore not claimed to be strict 3NF. A separate 3NF variant could remove those four direct hotel columns and derive them through joins; that change is outside this revision.
I5. Audit queries are not constraints
Read-only integrity queries can detect the three minimum-child violations and the intended same-hotel violations. Such queries audit data; they do not enforce these rules. A query that returns no rows has passed that audit at that moment; the query does not prevent later inconsistent writes. Ordinary FK checks alone do not enforce these assumptions.
I6. Weak identity and existence dependence
ROOM_FEATURE cannot exist without a referenced ROOM and cannot be identified by feature_code alone. The composite PK enforces local uniqueness. The mandatory FK prevents an orphan, and NO ACTION prevents deleting or changing a referenced owner key until the dependent rows are handled. Rooms may have no feature rows.
Rules still to decide
No business decisions are silently filled in
U1. Guest and room membership for usage
Whether a billed guest must appear in STAY_GUEST for the same reservation, and whether a charged room must appear in RESERVATION_ROOM, were not supplied. These extra membership constraints are not added.
U2. Time and availability
Reservation, arrival and departure dates; room occupancy periods; extensions; and overlapping/double-booking rules are unspecified. A reservation-room pair contains no temporal detail in the current key-only model.
U3. Money and accounting
Payment amounts, currencies, prices, taxes, balances, refunds and settlement rules are unspecified. PAYMENT may have 0..N rows per reservation; no financial completeness or balance rule can be inferred.
U4. Workflows and lifecycle
Draft/unallocated reservations, cancellations, reassignment histories, task statuses, audit history, soft deletion and archival policies need business definitions. Current parent minimums apply to the modeled committed state.
U5. Non-key attributes and validation
Names, contact details, room numbers, descriptions and other business attributes need a later data dictionary. Apart from the supplied keys, no candidate keys or extra UNIQUE constraints are assumed.
U6. Feature-code policy
Feature-code case sensitivity, empty strings, allowed characters, generation and length policy remain open. A code denotes a local room-owned feature, not a global catalogue item. If a shared catalogue is required later, model it separately instead of treating it as the weak entity.
Model checks
Both drawings include the same 15 entities/tables and all 26 links. The relational mapping has 39 columns, 26 FKs, three nullable FKs and three composite PKs. SQLite tests check key/FK behavior and weak ownership; SQLite does not enforce the declared VARCHAR(64) length. These checks validate the mapping, not unspecified business rules.