Prompt Details
Model
(gemini-3.1-pro)
Token size
407
Example input
[PROJECT_DESCRIPTION]: A platform connecting freelance musicians with event organizers.
[DATABASE_TECHNOLOGY]: PostgreSQL
[EXPECTED_TRAFFIC]: Medium
Example output
1. Structural Analysis and Assumptions
Assumptions: The platform requires user authentication (musicians and organizers), profiles, event listings, and a booking/application system. Given the "Medium" traffic expectation, a normalized relational structure will ensure data integrity while maintaining excellent read/write performance.
Main Entities:
User: Handles authentication for both roles (Musician, Organizer).
MusicianProfile: Extended details for musicians (portfolio, genre).
Event: Created by organizers, contains gig details.
Application: The junction/transaction table linking a Musician to an Event.
2. Entity-Relationship Diagram (Mermaid.js)
erDiagram
USER ||--o| MUSICIAN_PROFILE : has
USER ||--o{ EVENT : creates
MUSICIAN_PROFILE ||--o{ APPLICATION : submits
EVENT ||--o{ APPLICATION : receives
USER {
uuid id PK
string email
string password_hash
string role
timestamp created_at
}
MUSICIAN_PROFILE {
uuid id PK
uuid user_id FK
string genre
float hourly_rate
}
EVENT {
uuid id PK
uuid organizer_id FK
string title
date event_date
string location
}
APPLICATION {
uuid id PK
uuid event_id FK
uuid musician_id FK
string status
}
## 3\. Database Generation Code
CREATE TYPE user_role AS ENUM ('musician', 'organizer');
CREATE TYPE application_status AS ENUM ('pending', 'accepted', 'rejected');
CREATE TABLE users (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
email VARCHAR(255) UNIQUE NOT NULL,
password_hash VARCHAR(255) NOT NULL,
role user_role NOT NULL,
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE musician_profiles (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id UUID UNIQUE NOT NULL REFERENCES users(id) ON DELETE CASCADE,
genre VARCHAR(100) NOT NULL,
hourly_rate DECIMAL(10, 2),
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE events (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
organizer_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
title VARCHAR(255) NOT NULL,
event_date DATE NOT NULL,
location VARCHAR(255) NOT NULL,
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE applications (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
event_id UUID NOT NULL REFERENCES events(id) ON DELETE CASCADE,
musician_id UUID NOT NULL REFERENCES musician_profiles(id) ON DELETE CASCADE,
status application_status DEFAULT 'pending',
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
UNIQUE(event_id, musician_id) -- Prevents double applying
);
-- Performance Indexes
CREATE INDEX idx_users_email ON users(email);
CREATE INDEX idx_events_organizer ON events(organizer_id);
CREATE INDEX idx_applications_event_musician ON applications(event_id, musician_id);
## 4\. Security and Scalability Recommendations
Row-Level Security (RLS): Implement PostgreSQL RLS so organizers can only query and modify events/applications they own, preventing horizontal privilege escalation.
Data Minimization & Encryption: Ensure password_hash uses strong algorithms (like Argon2 or bcrypt). If physical addresses or payment details are added later, implement column-level encryption (pgcrypto) to comply with GDPR.
Connection Pooling: Since traffic is "Medium", set up PgBouncer to manage database connections efficiently and prevent the database from being overwhelmed during traffic spikes (e.g., weekend evenings when gigs are happening).
By purchasing this prompt, you agree to our terms of service
GEMINI-3.1-PRO
A professional-grade prompt that turns a simple app description into a complete database architecture. It generates structural analysis, a visual Mermaid.js Entity-Relationship diagram, production-ready creation code, and security recommendations scaled to your traffic.
...more
Added over 1 month ago
