# Database Structure

This page gives you a complete overview of the database used in this template. Each **data type**, **field**, and **option set** is documented to help you understand how the system works, what data it stores, and how you can extend or customize it.

Whether you're making changes to workflows, privacy rules, or adding new features, this reference will help you avoid confusion and ensure you're working with the correct structure.

***

## Data Types Overview

Each table in the database corresponds to a logical object in the system: reservations, rooms, users, menu items, etc. Below, you'll find a breakdown of all `Data Types` with their fields and purpose.

### **Allergen**

This datatype stores information about common allergens that may be present in products listed in your digital menu. It helps ensure better transparency for customers and allows establishments to communicate potential allergens clearly on dishes and drinks.

| Field name      | Type             | Description                                                       |
| --------------- | ---------------- | ----------------------------------------------------------------- |
| `name`          | text             | The name of the allergen (e.g. Gluten, Dairy).                    |
| `products`      | List of Products | A list of products that contain this allergen.                    |
| `Creator`       | User             | (Built-in) The user who created the allergen entry.               |
| `Modified Date` | date             | (Built-in) Date the allergen entry was last modified.             |
| `Created Date`  | date             | (Built-in) Date the allergen entry was initially created.         |
| `Slug`          | text             | (Built-in) Automatically generated slug used in URLs (if needed). |

***

### BlockedDate

This datatype is used to define specific days during which bookings are not allowed. These blocked dates help the establishment manage availability, closures, holidays, or internal events. They can also be linked to certain booking types if only specific actions are restricted on those dates.

| Field name        | Type                 | Description                                                                              |
| ----------------- | -------------------- | ---------------------------------------------------------------------------------------- |
| `BlockedRequests` | List of BookingTypes | Types of bookings (reservation or privatization) that are blocked on the specified date. |
| `date`            | date                 | The date when the block is effective.                                                    |
| `internalNote`    | text                 | A short description or internal note explaining the reason for the block.                |
| `Creator`         | User                 | (Built-in) The user who created the blocked date entry.                                  |
| `Modified Date`   | date                 | (Built-in) Date when this entry was last modified.                                       |
| `Created Date`    | date                 | (Built-in) Date when this blocked date entry was created.                                |
| `Slug`            | text                 | (Built-in) URL-friendly version of the entry name (optional use).                        |

***

### BookingRequest

This datatype handles all booking requests made by customers — whether for a standard reservation or a full privatization. It centralizes all key information such as date, time, guest count, type, associated customer, payment status, and internal notes. It is essential to operational planning and client communication.

| Field Name        | Type          | Description                                                               |
| ----------------- | ------------- | ------------------------------------------------------------------------- |
| `arrivalTime`     | date          | The exact starting time of the reservation or event.                      |
| `bookingType`     | BookingType   | Type of booking: either a standard reservation or a privatization.        |
| `chargeAmount`    | number        | The fee charged to the client for the booking.                            |
| `customer`        | Customer      | Linked customer who made the request.                                     |
| `customerNote`    | text          | Optional note added by the customer when making the request.              |
| `date`            | date          | The selected date for the booking.                                        |
| `departureTime`   | date          | The end time of the booking.                                              |
| `durationInHours` | number        | Automatically calculated duration between start and end.                  |
| `guestCount`      | number        | Number of expected guests.                                                |
| `internalNote`    | text          | Admin/staff-only note for internal tracking or clarifications.            |
| `room`            | Room          | The room selected by the customer for the reservation.                    |
| `status`          | BookingStatus | Current status of the booking (Pending, Accepted, Refused, etc.).         |
| `stripePaymentId` | text          | ID of the payment transaction processed via Stripe.                       |
| `Creator`         | User          | (Built-in) The user who created the booking (can be left blank in demo).  |
| `Modified Date`   | date          | (Built-in) Last modification timestamp.                                   |
| `Created Date`    | date          | (Built-in) Creation timestamp.                                            |
| `Slug`            | text          | (Built-in) Optional URL-safe identifier (used for SEO or custom routing). |

***

### Customer

This datatype represents each client who makes a booking through the platform. It stores their identity, contact information, and full booking history. It also includes internal notes and administrative flags (e.g., blacklisting). It’s a central element for customer management and client interaction tracking.

| Field Name       | Type                    | Description                                                      |
| ---------------- | ----------------------- | ---------------------------------------------------------------- |
| `bookingHistory` | List of BookingRequests | All booking requests associated with this customer.              |
| `email`          | text                    | Customer's email address.                                        |
| `firstName`      | text                    | Customer's first name.                                           |
| `internalNote`   | text                    | Admin/staff-only notes related to this customer.                 |
| `isBlacklisted`  | yes / no                | Indicates whether the customer is blacklisted. Defaults to "no". |
| `lastName`       | text                    | Customer's last name.                                            |
| `phoneNumber`    | text                    | Customer’s phone number.                                         |
| `Creator`        | User                    | (Built-in) The user who created the entry.                       |
| `Modified Date`  | date                    | (Built-in) Last time the entry was modified.                     |
| `Created Date`   | date                    | (Built-in) Date the customer profile was created.                |
| `Slug`           | text                    | (Built-in) Optional SEO-friendly identifier.                     |

***

### EmailTemplate

This datatype stores reusable email templates used throughout the app, especially for automated transactional emails (e.g. booking confirmations, rejections, etc.). Templates marked as `non-deletable` are essential to the app’s internal logic and should not be removed, as they are referenced directly by their unique IDs within workflows.

| Field Name      | Type     | Description                                                             |
| --------------- | -------- | ----------------------------------------------------------------------- |
| `body`          | text     | The content of the email (supports dynamic fields and HTML formatting). |
| `non-deletable` | yes / no | Prevents deletion if set to "yes"; used for critical system templates.  |
| `subject`       | text     | The subject line for the email.                                         |
| `title`         | text     | Internal name used for easy identification in the back office.          |
| `Creator`       | User     | (Built-in) The user who created the template.                           |
| `Modified Date` | date     | (Built-in) Last modification date.                                      |
| `Created Date`  | date     | (Built-in) Date the template was created.                               |
| `Slug`          | text     | (Built-in) Optional identifier for SEO or internal linking.             |

***

### Establishment

This data type is used to define the public profile of the establishment. It holds essential information like operating hours, contact information, logos, and social links. There should only be one instance of this entry in your database, serving as the global reference for your venue's configuration and public-facing data.

| **Field Name**       | **Type** | **Description**                                                          |
| -------------------- | -------- | ------------------------------------------------------------------------ |
| `address`            | text     | Physical address of the establishment.                                   |
| `bookingIntervalMin` | number   | Time interval (in minutes) between possible bookings.                    |
| `closingHour`        | number   | Hour (24h format) at which the venue closes.                             |
| `closingMinute`      | number   | Minute at which the venue closes.                                        |
| `facebookLink`       | text     | Link to the venue’s Facebook page.                                       |
| `instagramLink`      | text     | Link to the venue’s Instagram profile.                                   |
| `lastBookingHour`    | number   | Last hour a customer can book (before closing).                          |
| `lastBookingMinute`  | number   | Last minute a customer can book.                                         |
| `linkedinLink`       | text     | Link to the venue’s LinkedIn profile.                                    |
| `logo`               | file     | Main logo of the establishment (used in headers or landing page).        |
| `openingHour`        | number   | Hour (24h format) at which the venue opens.                              |
| `openingMinute`      | number   | Minute at which the venue opens.                                         |
| `publicEmail`        | text     | Public contact email displayed to clients.                               |
| `publicPhoneNumber`  | text     | Public contact phone number.                                             |
| `sendEmails`         | yes / no | Defines whether transactional emails are enabled for this establishment. |
| `squareLogo`         | file     | Square format logo used for mobile apps or avatars.                      |
| `websiteUrl`         | text     | Official website URL of the venue.                                       |
| `Slug`               | text     | SEO-friendly unique identifier for URLs (autogenerated).                 |

***

### Log

This data type is used to track and analyze user interactions within the booking module. It powers the **Data** section in the backoffice, enabling you to measure conversion rates and understand user behavior at each step of the booking process. Each log represents a tracked event.

| **Field Name** | **Type**     | **Description**                                                                              |
| -------------- | ------------ | -------------------------------------------------------------------------------------------- |
| `bookingType`  | BookingType  | Indicates which type of booking is being tracked (e.g., room, table, etc.).                  |
| `eventType`    | LogEventType | Defines what stage of the process the log refers to (e.g., opened calendar, submitted form). |
| `Slug`         | text         | SEO-friendly identifier (autogenerated, optional).                                           |

***

### MailHistory

This data type tracks all emails sent to customers. It is used to store a searchable archive of communications, ensuring full traceability. The `Created Date` is used as the timestamp for when the email was actually sent.

| **Field Name**   | **Type**       | **Description**                                          |
| ---------------- | -------------- | -------------------------------------------------------- |
| `body`           | text           | The full content of the email sent.                      |
| `bookingRequest` | BookingRequest | Reference to the related booking request, if applicable. |
| `recipient`      | Customer       | The customer who received the email.                     |
| `subject`        | text           | Subject line of the email.                               |
| `template`       | EmailTemplate  | The email template used to generate the email content.   |
| `Slug`           | text           | (Optional) SEO-friendly unique identifier.               |

***

### Product

This data type stores all the menu items or products available in your establishment. It supports allergen tracking, category classification, and publishing control, making it ideal for online menus or internal item management.

| **Field Name** | **Type**          | **Description**                                                     |
| -------------- | ----------------- | ------------------------------------------------------------------- |
| `allergens`    | List of Allergens | Allergens associated with the product (e.g., gluten, nuts, etc.).   |
| `category`     | ProductCategory   | The product’s category (e.g., drink, main dish, dessert).           |
| `description`  | text              | A short description of the product.                                 |
| `isPublished`  | yes / no          | Indicates whether the product is visible in the public-facing menu. |
| `name`         | text              | The name of the product.                                            |
| `price`        | number            | The price of the product.                                           |
| `Slug`         | text              | (Optional) SEO-friendly unique identifier.                          |

***

### Room

This data type defines the private rooms or spaces available for booking in your establishment. Each room can have its own pricing, visual media, and description to help customers choose the best fit for their event or reservation. It's especially useful for managing privatization requests.

| **Field Name**     | **Type**      | **Description**                                                      |
| ------------------ | ------------- | -------------------------------------------------------------------- |
| `capacity`         | numeric range | Indicates the min and max number of guests the room can host.        |
| `coverImage`       | file          | Main image displayed for the room in previews and listings.          |
| `description`      | text          | Full description of the room, used for detailed views.               |
| `features`         | List of texts | List of amenities or features (e.g., sound system, projector, etc.). |
| `galleryImages`    | List of files | Additional photos for a complete visual presentation of the space.   |
| `hourlyRate`       | number        | The room’s hourly price.                                             |
| `isPublished`      | yes / no      | Whether the room is visible in the public booking interface.         |
| `name`             | text          | The name of the room (e.g., “VIP Lounge”, “The Garden Room”).        |
| `shortDescription` | text          | Brief summary shown in previews or cards.                            |
| `videoFile`        | file          | Optional video file to showcase the room in motion.                  |
| `Slug`             | text          | (Optional) SEO-friendly unique identifier.                           |

***

### User

This data type is used to manage staff accounts within the application. It contains basic identity and access information, allowing role-based control over which parts of the system each user can access. Users can have different statuses (admin, staff, demo), and their credentials are linked to their email.

| **Field Name** | **Type**   | **Description**                                                                        |
| -------------- | ---------- | -------------------------------------------------------------------------------------- |
| `firstName`    | text       | Staff member's first name.                                                             |
| `lastName`     | text       | Staff member's last name.                                                              |
| `status`       | UserStatus | Defines the role of the user (admin, staff, demo). Affects visibility and permissions. |
| `email`        | text       | Used for login and identity. Automatically linked by Bubble.                           |
| `Slug`         | text       | Optional SEO-friendly unique identifier.                                               |

***

## Option sets

Option sets are used in the template to define fixed lists of values that drive consistent behavior and logic throughout the app. Unlike regular data types, option sets are static and do not change during runtime, making them ideal for things like statuses, categories, or types.

They are especially useful for:

* Ensuring uniformity across workflows and interfaces
* Improving performance (option sets are faster to load than database entries)
* Simplifying conditional logic and display rules

In the following section, each option set used in the template is explained with its possible values and its purpose within the application.



### BookingStatus

The `BookingStatus` option set defines the lifecycle of a booking request. It is used to determine and display the current state of a reservation throughout the platform. It allows for easy filtering, conditional formatting, and workflow triggers based on status.

| Option      | Description                                                                |
| ----------- | -------------------------------------------------------------------------- |
| `Draft`     | The booking request has been created but not yet submitted or finalized.   |
| `Pending`   | The booking has been submitted and is awaiting validation or confirmation. |
| `Confirmed` | The booking has been approved and is officially scheduled.                 |
| `Archived`  | The booking is no longer active but is kept for historical reference.      |
| `Declined`  | The booking request was refused and is no longer in progress.              |

**Used in:**

* BookingRequest data type
* Filtering and displaying reservation statuses
* Triggering email notifications and logic in workflows

***

### BookingType

The `BookingType` option set is used to classify the nature of a booking request. This helps separate standard reservations from full-space privatizations, making it easier to adjust logic, pricing, and display across the application.

| Option          | Description                                                           |
| --------------- | --------------------------------------------------------------------- |
| `Reservation`   | A standard booking for one or more people in the establishment.       |
| `Privatization` | A booking that involves reserving the entire venue or a private room. |

**Used in :**

* BookingRequest data type
* Filtering and calculating pricing logic
* Adjusting availability and capacity logic in workflows

***

### LogEventType

The `LogEventType` option set is used to track user behavior and analyze conversion steps within the booking module. It’s primarily leveraged by the **Log** data type to measure which stages users are reaching and where they drop off, supporting data-driven UX improvements.

| Option             | Description                                            |
| ------------------ | ------------------------------------------------------ |
| `Traffic`          | User has opened the booking module.                    |
| `ArrivedOnDate`    | User selected a date.                                  |
| `ArrivedOnRoom`    | User selected a room.                                  |
| `ArrivedOnInfo`    | User filled out the information form.                  |
| `ArrivedOnPayment` | User reached the payment step (regardless of success). |

**Used in :**

* Log data type
* Analytics dashboard inside the back-office ("Data" tab)

***

### ProductMainCategory

The `ProductMainCategory` option set defines the top-level structure of the online menu. These main categories group together related subcategories from the `ProductCategory` option set. This hierarchy is used to organize and display the product offering in a clear and user-friendly way on the public-facing menu.

| Option      | Description                                                                      |
| ----------- | -------------------------------------------------------------------------------- |
| `Beverages` | Contains all drink-related items (softs, wine, cocktails, etc.).                 |
| `Food`      | Groups food items like starters, mains, desserts, and platters.                  |
| `Tapas`     | Dedicated to sharing dishes and finger foods typically served in a tapas format. |

**Used in:**

* `ProductCategory` option set (each subcategory links to one of these main categories)
* Online menu rendering logic (public website menu layout)

***

### ProductCategory

The `ProductCategory` option set defines the subcategories of products within the menu. Each entry is linked to a `ProductMainCategory` and is used to classify and display items (drinks or dishes) in a structured way. These subcategories are the ones directly associated with each `Product` in the database.

This structure is essential for organizing the online menu by grouping items into clear, user-friendly sections.

| Option     | Description                                             |
| ---------- | ------------------------------------------------------- |
| Soft       | Non-alcoholic beverages (sodas, juices).                |
| Wine       | All wine products.                                      |
| Cocktail   | Alcohol-based cocktails.                                |
| Mocktails  | Non-alcoholic cocktails.                                |
| Hot drinks | Includes tea, coffee, and other warm drinks.            |
| Starter    | Starters and appetizers.                                |
| Main       | Main courses and substantial dishes.                    |
| ...        | Other subcategories like dessert, platters, tapas, etc. |

**Used in:**

* `Product` data type (each product belongs to a `ProductCategory`)
* `ProductMainCategory` linkage for menu display logic
* Online public menu layout (grouping and filtering)

***

### UserStatus

The `UserStatus` option set defines access levels for users of the back-office. It helps determine permissions, visibility, and available actions for each type of user (especially staff members). This status is referenced in both logic workflows and privacy rules.

You can expand this option set based on your needs by adding new roles (e.g. “Manager”, “Intern”) and updating logic/privacy rules accordingly.

| Option | Description                                                    |
| ------ | -------------------------------------------------------------- |
| Admin  | Full access to all features, settings, and sensitive data.     |
| Staff  | Limited access to core operational features only.              |
| Demo   | Used for demonstration purposes with restricted interactivity. |

**Used in:**

* `User` data type
* Privacy rules configuration
* Conditional logic for dynamic interface control (front & back-office)
