Hotel / Database design
ER + RELATIONAL MODEL

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.

ColumnProvisional typeRelational role
room_idBIGINTPK component + NOT NULL FK to ROOM.room_id
feature_codeVARCHAR(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.

THE MODEL

Chen ER diagram

All 15 entities and 26 relationships, including ROOM_FEATURE and its identifying relationship.

Fit
Hotel management - connected Chen-style ER diagram 15 unique entities, 26 connected relationship diamonds, 16 full-key attribute ovals, one dashed-underlined partial key, and 52 endpoint participation labels. ROOM_FEATURE is a weak entity identified by ROOM and feature_code. Double lines mean mandatory participation. DATABASE DESIGN / HOTEL OPERATIONS Hotel management Chen-style ER diagram / 15 entities / 26 relationships / Includes one weak entity HOTEL HOTEL ROOM ROOM ROOM_TYPE ROOM_TYPE RESERVATION RESERVATION RESERVATION_ROOM RESERVATION_ROOM GUEST GUEST STAY_GUEST STAY_GUEST PAYMENT PAYMENT SERVICE_USAGE SERVICE_USAGE SERVICE SERVICE DEPARTMENT DEPARTMENT EMPLOYEE EMPLOYEE MAINTENANCE_REQUEST MAINTENANCE_REQUEST HOUSEKEEPING_TASK HOUSEKEEPING_TASK ROOM_FEATURE ROOM_FEATURE DEFINES DEFINES CONTAINS CONTAINS CLASSIFIES CLASSIFIES MAKES MAKES RECEIVES RECEIVES RECEIVES RECEIVES ALLOCATES ALLOCATES RESERVED IN RESERVED IN INCLUDES INCLUDES APPEARS IN APPEARS IN HAS HAS OWNS OWNS OFFERS OFFERS INCURS INCURS BILLED TO BILLED TO POSTED TO POSTED TO APPEARS IN APPEARS IN EMPLOYS EMPLOYS CONTAINS CONTAINS SCHEDULES SCHEDULES PERFORMS PERFORMS HAS HAS OWNS OWNS REPORTS REPORTS ASSIGNED TO ASSIGNED TO IDENTIFIES IDENTIFIES hotel_id hotel_id room_id room_id room_type_id room_type_id reservation_id reservation_id reservation_id reservation_id room_id room_id guest_id guest_id reservation_id reservation_id guest_id guest_id payment_id payment_id service_usage_id service_usage_id service_id service_id department_id department_id employee_id employee_id request_id request_id task_id task_id feature_code feature_code (1,1) (0,N) (1,1) (0,N) (1,N) (1,1) (1,1) (0,N) (1,1) (0,N) (1,N) (1,1) (0,N) (1,N) (1,1) (1,1) (0,N) (0,N) (1,1) (1,1) (0,N) (1,1) (1,1) (0,N) (1,1) (0,N) (1,1) (0,1) (0,N) (1,1) (1,1) (1,1) (0,N) (0,N) (0,N) (0,N) (1,1) (0,N) (1,1) (0,N) (0,1) (0,N) (1,1) (0,N) (1,1) (0,N) (1,1) (0,1) (0,N) (0,N) (1,1) (0,N) READING THE MAP (min,max) counts links for one instance of the nearby entity; N means many. Optional Mandatory Underlined oval = key Blue = link / event entity WEAK ENTITY Double rectangle + double diamond = owner-dependent identity; dashed underline = partial key.

Zoom in to read the labels, then scroll within the diagram. Fit diagram restores the full view.

THE MODEL

Relational table model

Primary keys, foreign keys, junction tables and weak identity. Arrowheads point to the foreign-key rows.

Fit
Hotel management - complete relational mapping Fifteen relational tables with thirty-nine columns, primary keys, twenty-six foreign keys, two composite-key junction tables, one weak table and three optional staff roles. Arrows run from referenced primary-key rows to foreign-key rows. DATABASE DESIGN / HOTEL OPERATIONS Hotel management Relational model / 15 tables / 39 columns / 26 foreign keys Referenced PK to FK row Nullable FK PK = primary key PK/FK = part of a composite key NN = NOT NULL Blue = junction table Bridge arc = crossing, no join IDs: BIGINT; feature code: VARCHAR(64) ROOM_TYPE.hotel_id REFERENCES HOTEL.hotel_id HOUSEKEEPING_TASK.room_id REFERENCES ROOM.room_id ROOM.hotel_id REFERENCES HOTEL.hotel_id MAINTENANCE_REQUEST.assigned_to_employee_id REFERENCES EMPLOYEE.employee_id SERVICE_USAGE.room_id REFERENCES ROOM.room_id MAINTENANCE_REQUEST.reported_by_employee_id REFERENCES EMPLOYEE.employee_id RESERVATION_ROOM.reservation_id REFERENCES RESERVATION.reservation_id STAY_GUEST.guest_id REFERENCES GUEST.guest_id MAINTENANCE_REQUEST.hotel_id REFERENCES HOTEL.hotel_id RESERVATION_ROOM.room_id REFERENCES ROOM.room_id RESERVATION.booked_by_guest_id REFERENCES GUEST.guest_id SERVICE.hotel_id REFERENCES HOTEL.hotel_id SERVICE_USAGE.guest_id REFERENCES GUEST.guest_id SERVICE_USAGE.service_id REFERENCES SERVICE.service_id PAYMENT.reservation_id REFERENCES RESERVATION.reservation_id MAINTENANCE_REQUEST.room_id REFERENCES ROOM.room_id STAY_GUEST.reservation_id REFERENCES RESERVATION.reservation_id HOUSEKEEPING_TASK.performed_by_employee_id REFERENCES EMPLOYEE.employee_id RESERVATION.hotel_id REFERENCES HOTEL.hotel_id ROOM.room_type_id REFERENCES ROOM_TYPE.room_type_id EMPLOYEE.department_id REFERENCES DEPARTMENT.department_id SERVICE.department_id REFERENCES DEPARTMENT.department_id SERVICE_USAGE.reservation_id REFERENCES RESERVATION.reservation_id DEPARTMENT.hotel_id REFERENCES HOTEL.hotel_id EMPLOYEE.hotel_id REFERENCES HOTEL.hotel_id ROOM_FEATURE.room_id REFERENCES ROOM.room_id Crossing without a join Crossing without a join Crossing without a join HOTEL HOTEL KEY COLUMN TYPE NULL PK hotel_id BIGINT NN GUEST GUEST KEY COLUMN TYPE NULL PK guest_id BIGINT NN ROOM_TYPE ROOM_TYPE KEY COLUMN TYPE NULL PK room_type_id BIGINT NN FK hotel_id BIGINT NN DEPARTMENT DEPARTMENT KEY COLUMN TYPE NULL PK department_id BIGINT NN FK hotel_id BIGINT NN ROOM ROOM KEY COLUMN TYPE NULL PK room_id BIGINT NN FK hotel_id BIGINT NN FK room_type_id BIGINT NN SERVICE SERVICE KEY COLUMN TYPE NULL PK service_id BIGINT NN FK department_id BIGINT NN FK hotel_id BIGINT NN EMPLOYEE EMPLOYEE KEY COLUMN TYPE NULL PK employee_id BIGINT NN FK hotel_id BIGINT NN FK department_id BIGINT NN RESERVATION RESERVATION KEY COLUMN TYPE NULL PK reservation_id BIGINT NN FK booked_by_guest_id BIGINT NN FK hotel_id BIGINT NN PAYMENT PAYMENT KEY COLUMN TYPE NULL PK payment_id BIGINT NN FK reservation_id BIGINT NN RESERVATION_ROOM RESERVATION_ROOM JUNCTION KEY COLUMN TYPE NULL PK/FK reservation_id BIGINT NN PK/FK room_id BIGINT NN STAY_GUEST STAY_GUEST JUNCTION KEY COLUMN TYPE NULL PK/FK reservation_id BIGINT NN PK/FK guest_id BIGINT NN SERVICE_USAGE SERVICE_USAGE EVENT KEY COLUMN TYPE NULL PK service_usage_id BIGINT NN FK room_id BIGINT NN FK reservation_id BIGINT NN FK service_id BIGINT NN FK guest_id BIGINT NN HOUSEKEEPING_TASK HOUSEKEEPING_TASK KEY COLUMN TYPE NULL PK task_id BIGINT NN FK room_id BIGINT NN FK performed_by_employee_id BIGINT NULL MAINTENANCE_REQUEST MAINTENANCE_REQUEST KEY COLUMN TYPE NULL PK request_id BIGINT NN FK room_id BIGINT NN FK hotel_id BIGINT NN FK reported_by_employee_id BIGINT NULL FK assigned_to_employee_id BIGINT NULL ROOM_FEATURE ROOM_FEATURE WEAK KEY COLUMN TYPE NULL PK/FK room_id BIGINT NN PK feature_code VARCHAR(64) NN PARENT MINIMUMS HOTEL: at least 1 ROOM_TYPE. RESERVATION: at least 1 RESERVATION_ROOM and 1 STAY_GUEST. Source keys and links preserved. ROOM_FEATURE added as a weak entity with the composite PK shown. Minimum-child and same-hotel rules: see notes.

Zoom in to read the labels, then scroll within the diagram. Fit diagram restores the full view.

CARDINALITY + FOREIGN KEYS

Relationship register

All original relationships (r01-r25), plus the new identifying relationship (r26).

Bounds count links for one instance of the named entity: 0..N = optional, many; 1..N = at least one; 1..1 = exactly one; 0..1 = optional, at most one.
IDParent / relationshipChild / foreign keyPer parentPer child
r01HOTELDEFINESROOM_TYPEhotel_id1..N1..1
r02HOTELCONTAINSROOMhotel_id0..N1..1
r03ROOM_TYPECLASSIFIESROOMroom_type_id0..N1..1
r04GUESTMAKESRESERVATIONbooked_by_guest_id0..N1..1
r05HOTELRECEIVESRESERVATIONhotel_id0..N1..1
r06RESERVATIONRECEIVESPAYMENTreservation_id0..N1..1
r07RESERVATIONALLOCATESRESERVATION_ROOMreservation_id1..N1..1
r08ROOMRESERVED_INRESERVATION_ROOMroom_id0..N1..1
r09RESERVATIONINCLUDESSTAY_GUESTreservation_id1..N1..1
r10GUESTAPPEARS_INSTAY_GUESTguest_id0..N1..1
r11HOTELHASDEPARTMENThotel_id0..N1..1
r12DEPARTMENTOWNSSERVICEdepartment_id0..N1..1
r13HOTELOFFERSSERVICEhotel_id0..N1..1
r14RESERVATIONINCURSSERVICE_USAGEreservation_id0..N1..1
r15GUESTBILLED_TOSERVICE_USAGEguest_id0..N1..1
r16ROOMPOSTED_TOSERVICE_USAGEroom_id0..N1..1
r17SERVICEAPPEARS_INSERVICE_USAGEservice_id0..N1..1
r18HOTELEMPLOYSEMPLOYEEhotel_id0..N1..1
r19DEPARTMENTCONTAINSEMPLOYEEdepartment_id0..N1..1
r20ROOMSCHEDULESHOUSEKEEPING_TASKroom_id0..N1..1
r21EMPLOYEEPERFORMSHOUSEKEEPING_TASKperformed_by_employee_id0..N0..1
r22ROOMHASMAINTENANCE_REQUESTroom_id0..N1..1
r23HOTELOWNSMAINTENANCE_REQUESThotel_id0..N1..1
r24EMPLOYEEREPORTSMAINTENANCE_REQUESTreported_by_employee_id0..N0..1
r25EMPLOYEEASSIGNED_TOMAINTENANCE_REQUESTassigned_to_employee_id0..N0..1
r26ROOMIDENTIFIESROOM_FEATUREroom_id0..N1..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.

MODELING NOTES

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.

MODELING NOTES

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.

MODELING NOTES

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.