1. Core System Tables
These tables manage the users and the master list of all requests, serving as the backbone for both the Customer View and Service Provider View.
Table: Users
Supports authentication for Guests and Staff.
| Field Name | Data Type | Description |
|---|---|---|
| user_id | INT (PK) | Unique Identifier |
| role | ENUM | 'GUEST', 'STAFF', 'ADMIN' - Distinguishes between Customer and Service Provider views. |
| name | VARCHAR | User Name |
| room_number | VARCHAR | Assigned Room - Crucial for delivery/service location. |
| language_pref | VARCHAR | Language Code - Supports multilingual translation features. |
Table: Master_Requests
The central list used by Staff to view "Open" tasks and by Guests to track "My Requests".
| Field Name | Data Type | Description |
|---|---|---|
| request_id | INT (PK) | Unique Request ID |
| guest_id | INT (FK) | Linked to Users - Identifies the requester. |
| service_type | ENUM | 'HOUSEKEEPING', 'DINING', 'TRANSPORT', 'FRONT_DESK', 'MAINTENANCE' - Categorizes the request for routing. |
| status | ENUM | 'PENDING', 'ASSIGNED', 'IN_PROGRESS', 'COMPLETED' - Real-time status updates for the guest. |
| assigned_staff_id | INT (FK) | Linked to Users - The Service Provider handling the task. |
| created_at | DATETIME | Timestamp - Used for SLA tracking. |
2. Service-Specific Tables
These tables store the specific data required for the top 5 services, linked back to the Master Request table.
Service 1: Housekeeping (Amenities)
| Field Name | Data Type | Description |
|---|---|---|
| detail_id | INT (PK) | Unique ID |
| request_id | INT (FK) | Linked to Master_Requests |
| item_name | ENUM | 'TOWELS', 'TOILETRIES', 'COFFEE_REFILL', 'FAN' |
| quantity | INT | Number of items |
| allergy_note | VARCHAR | Specific cleaning chemical allergies |
Service 2: Room Service (On-Demand Dining)
| Field Name | Data Type | Description |
|---|---|---|
| order_id | INT (PK) | Unique ID |
| request_id | INT (FK) | Linked to Master_Requests |
| menu_item_id | INT | Linked to a Menu Catalog |
| special_instructions | TEXT | 'No onions', 'Gluten-free' etc. |
| delivery_time | DATETIME | Scheduled Time |
Service 3: Transportation
| Field Name | Data Type | Description |
|---|---|---|
| booking_id | INT (PK) | Unique ID |
| request_id | INT (FK) | Linked to Master_Requests |
| pickup_type | ENUM | 'TAXI', 'AIRPORT_SHUTTLE', 'LIMO' |
| destination | VARCHAR | Drop-off location |
| pickup_time | DATETIME | Requested time |
| flight_number | VARCHAR | External API data link for tracking delays |
Service 4: Front Desk Services
| Field Name | Data Type | Description |
|---|---|---|
| fd_id | INT (PK) | Unique ID |
| request_id | INT (FK) | Linked to Master_Requests |
| request_type | ENUM | 'LATE_CHECKOUT', 'UPGRADE', 'LUGGAGE_ASSIST' |
| requested_time | TIME | Proposed checkout/pickup time |
| luggage_count | INT | Number of bags |
| upgrade_pref | VARCHAR | Desired Room Type |
Service 5: Maintenance & General Repairs
| Field Name | Data Type | Description |
|---|---|---|
| ticket_id | INT (PK) | Unique ID |
| request_id | INT (FK) | Linked to Master_Requests |
| issue_category | ENUM | 'PLUMBING', 'ELECTRICAL', 'NOISE', 'CLIMATE' |
| description | TEXT | User description of issue |
| is_automated | BOOLEAN | Did a sensor trigger this or a guest? |
| severity | ENUM | 'LOW', 'MEDIUM', 'HIGH' |
How the Views Utilize These Tables
Customer View (The Guest)
- Action: When a guest logs in, the app queries Users to get their profile.
- Requesting: When they click "Order Towels" (One-Touch Housekeeping), the app creates a row in Master_Requests (Status: PENDING) and a row in Housekeeping_Details (Item: Towels).
- Viewing: The "My Activity" screen filters Master_Requests where guest_id = Current User, showing the status (e.g., "IN_PROGRESS") so they don't have to call the desk.
Service Provider View (The Staff)
- Action: When a staff member logs in, they see a dashboard.
- Viewing: The dashboard queries Master_Requests where status is NOT 'COMPLETED'.
-
Filtering:
Housekeeping Staff see requests where service_type = 'HOUSEKEEPING'.
Engineers see requests where service_type = 'MAINTENANCE'.
- Fulfillment: When staff delivers the item, they update the status in Master_Requests to 'COMPLETED', which triggers a notification to the Guest View.
Hospitality Service Management Firebase Schema
Based on the provided source material, "creating tables" in Google Cloud Platform (GCP) Firebase (specifically Cloud Firestore, the standard NoSQL database for mobile apps) involves writing data to collections. Unlike SQL, you do not run CREATE TABLE commands. Instead, you create documents within collections.
Part 1: Node.js Initialization Script
This script initializes the collections and seeds them with sample data to represent the schema structure. It ensures the Core System Tables and Service-Specific Tables are linked correctly using the Firebase Admin SDK.
const admin = require('firebase-admin');
const serviceAccount = require('./path/to/serviceAccountKey.json');
admin.initializeApp({
credential: admin.credential.cert(serviceAccount)
});
const db = admin.firestore();
async function createHospitalitySchema() {
// ======================================================
// 1. CORE SYSTEM TABLES (Users & Master_Requests) [1], [2]
// ======================================================
// --- Table: Users [1] ---
// Creating a Guest Profile
const guestRef = db.collection('users').doc('guest_123');
await guestRef.set({
role: 'GUEST', // Source [1]
name: 'John Doe',
room_number: '101', // Source [1]
language_pref: 'en' // Source [1]
});
// Creating a Staff Profile
const staffRef = db.collection('users').doc('staff_456');
await staffRef.set({
role: 'STAFF', // Source [1]
name: 'Alice Manager',
department: 'HOUSEKEEPING'
});
console.log("Users created.");
// --- Table: Master_Requests [2] ---
// The central list used by Staff to view "Open" tasks
const requestRef = db.collection('master_requests').doc('req_001');
await requestRef.set({
guest_id: 'guest_123', // Linked to Users [2]
service_type: 'HOUSEKEEPING',// Source [2]
status: 'PENDING', // Source [2]
assigned_staff_id: null, // Initially unassigned [2]
created_at: admin.firestore.FieldValue.serverTimestamp()
});
console.log("Master Request created.");
// ======================================================
// 2. SERVICE-SPECIFIC TABLES (Top 5 Services) [3] - [4]
// ======================================================
// --- Service 1: Housekeeping Details [3] ---
// Focus: Extra towels, toiletries
await db.collection('housekeeping_details').add({
request_id: 'req_001', // FK to Master_Requests [3]
item_name: 'TOWELS', // ENUM Source [3]
quantity: 2,
allergy_note: 'None' // Source [3]
});
// --- Service 2: Dining Orders [5] ---
// Focus: On-demand dining, dietary restrictions
await db.collection('dining_orders').add({
request_id: 'req_002', // Link to a dining master request
menu_item_id: 55, // Linked to Menu Catalog [5]
special_instructions: 'Gluten-free', // Source [5]
delivery_time: '2023-10-27T19:00:00Z' // Source [5]
});
// --- Service 3: Transport Bookings [6] ---
// Focus: Airport Pickups, Flight Data
await db.collection('transport_bookings').add({
request_id: 'req_003',
pickup_type: 'AIRPORT_SHUTTLE', // Source [6]
destination: 'JFK Airport',
flight_number: 'UA990', // Source [6]
pickup_time: '2023-10-28T08:00:00Z'
});
// --- Service 4: Front Desk Requests [4] ---
// Focus: Late Check-Out, Upgrades
await db.collection('front_desk_requests').add({
request_id: 'req_004',
request_type: 'LATE_CHECKOUT', // Source [4]
requested_time: '14:00',
upgrade_pref: 'Sea View Suite' // Source [4]
});
// --- Service 5: Maintenance Tickets [4], [7] ---
// Focus: Repairs, Workflow Automation
await db.collection('maintenance_tickets').add({
request_id: 'req_005',
issue_category: 'PLUMBING', // Source [4]
description: 'Sink is leaking', // Source [4]
severity: 'MEDIUM', // Source [4]
is_automated: false // Source [4]
});
console.log("Service specific tables populated.");
}
createHospitalitySchema();
Part 2: Firestore Security Rules (Schema Validation)
Since NoSQL is schema-less by default, you use Security Rules to enforce the data types and ENUM constraints defined in your source tables (e.g., ensuring status is only 'PENDING' or 'COMPLETED').
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// --- Table: Users [1] ---
match /users/{userId} {
allow read, write: if request.auth != null;
// Enforce Role ENUM [1]
allow create: if request.resource.data.role in ['GUEST', 'STAFF', 'ADMIN'];
}
// --- Table: Master_Requests [2] ---
match /master_requests/{requestId} {
allow read, write: if request.auth != null;
// Enforce Data Integrity
allow create: if
// Service Type ENUM [2]
request.resource.data.service_type in ['HOUSEKEEPING', 'DINING', 'TRANSPORT', 'FRONT_DESK', 'MAINTENANCE'] &&
// Status ENUM [2]
request.resource.data.status in ['PENDING', 'ASSIGNED', 'IN_PROGRESS', 'COMPLETED'];
}
// --- Service 1: Housekeeping Details [3] ---
match /housekeeping_details/{detailId} {
allow read, write: if request.auth != null;
// Enforce Item Name ENUM [3]
allow create: if request.resource.data.item_name in ['TOWELS', 'TOILETRIES', 'COFFEE_REFILL', 'FAN'];
}
// --- Service 3: Transport Bookings [6] ---
match /transport_bookings/{bookingId} {
allow read, write: if request.auth != null;
// Enforce Pickup Type ENUM [6]
allow create: if request.resource.data.pickup_type in ['TAXI', 'AIRPORT_SHUTTLE', 'LIMO'];
}
// --- Service 4: Front Desk Requests [4] ---
match /front_desk_requests/{fdId} {
allow read, write: if request.auth != null;
// Enforce Request Type ENUM [4]
allow create: if request.resource.data.request_type in ['LATE_CHECKOUT', 'UPGRADE', 'LUGGAGE_ASSIST'];
}
// --- Service 5: Maintenance Tickets [4] ---
match /maintenance_tickets/{ticketId} {
allow read, write: if request.auth != null;
// Enforce Issue Category and Severity ENUMs [4]
allow create: if
request.resource.data.issue_category in ['PLUMBING', 'ELECTRICAL', 'NOISE', 'CLIMATE'] &&
request.resource.data.severity in ['LOW', 'MEDIUM', 'HIGH'];
}
// Default fallback for Dining Orders and others not strictly restricted above
match /{document=**} {
allow read, write: if request.auth != null;
}
}
}