Data Model & Database Structure
Based on our platform selection of Bubble.io, we've defined the database structure for the CoachPortal application. The structure includes User and Appointment models with all required fields and relationships to support the coach appointment management functionality.
Data Model
User
- name: text
- email: email
- role: text ("coach", "admin")
Appointment
- coach: User (reference)
- client_name: text
- date: date
- time: time
- duration: number (minutes)
- notes: text
Relationship:
One-to-Many: One User (Coach) can have multiple Appointments
Database Implementation
In Bubble.io, we'll implement the data model using the platform's built-in database system. Below is the configuration for each data type in the Bubble.io database:
User Data Type
| Field Name | Type | Description |
|---|---|---|
| name | Text | Full name of the user |
| Email address (used for login) | ||
| role | Text | Either "coach" or "admin" |
| password | Password | Automatically handled by Bubble's authentication |
Note: The User data type will be configured to use Bubble.io's built-in authentication system.
Appointment Data Type
| Field Name | Type | Description |
|---|---|---|
| coach | User (reference) | Reference to the coach user |
| client_name | Text | Name of the client |
| date | Date | Date of the appointment |
| time | Time | Start time of the appointment |
| duration | Number | Duration in minutes |
| notes | Text | Additional notes about the appointment |
| created_date | Date/Time | Automatically set when record is created |
Implementation Notes
- In Bubble.io, references between data types are automatically managed.
- We'll utilize Bubble's built-in privacy rules to ensure coaches only see their own appointments.
- Date and time fields can be combined in the UI while maintaining separate database fields for flexibility.
- Additional helper fields (like calendar_datetime) may be added for easier calendar integration.
Security & Privacy Rules
Proper security rules are essential to ensure data privacy and access control within the CoachPortal application. Below are the security rules we'll implement in Bubble.io to protect user data and enforce the requirement that coaches can only see their own appointments.
User Data Privacy Rules
| Action | Admin | Coach | Not Logged In |
|---|---|---|---|
| Create | Yes | No | No (except for signup) |
| Read | All users | Only self | No |
| Update | All users | Only self (limited fields) | No |
| Delete | All users | No | No |
Appointment Data Privacy Rules
| Action | Admin | Coach | Not Logged In |
|---|---|---|---|
| Create | Yes (for any coach) | Yes (only with self as coach) | No |
| Read | All appointments | Only when coach = current user | No |
| Update | All appointments | Only when coach = current user | No |
| Delete | All appointments | Only when coach = current user | No |
Implementation in Bubble.io
In Bubble.io, these privacy rules will be implemented using the platform's built-in privacy rules editor:
- For the User data type, we'll set up rules to restrict visibility and modification.
- For the Appointment data type, we'll create a "only when coach = current user" condition for coach access.
- Admin users will have unrestricted access configured through role-based permissions.
- We'll implement additional validation in workflows to ensure coaches can only create appointments for themselves.