Database Schema

Database

Database Schema

Complete schema for Tonal — a gated indie-artist incubator and data-analytics marketplace. All tables use UUID primary keys, timestamps, and proper foreign key relationships.

users

Subscriber accounts — authentication and subscription state

FieldTypeConstraints
id
UUID
PK
email
VARCHAR(255)
UNIQUE
NOT NULL
display_name
VARCHAR(100)
NOT NULL
auth_provider
ENUM
NOT NULL
auth_provider_id
VARCHAR(255)
stripe_customer_id
VARCHAR(255)
UNIQUE
subscription_status
ENUM
NOT NULL
subscription_started_at
TIMESTAMP
created_at
TIMESTAMP
NOT NULL
updated_at
TIMESTAMP
NOT NULL

artists

Musician profiles — onboarded and verified creators

FieldTypeConstraints
id
UUID
PK
user_id
UUID
FK → users
UNIQUE
artist_name
VARCHAR(200)
NOT NULL
bio
TEXT
avatar_url
VARCHAR(500)
base44_identity_hash
CHAR(64)
UNIQUE
NOT NULL
id_verified
BOOLEAN
DEFAULT false
pro_org
ENUM
pro_member_id
VARCHAR(100)
pro_verified
BOOLEAN
DEFAULT false
ipi_cae_number
VARCHAR(20)
stripe_connect_id
VARCHAR(255)
onboarding_status
ENUM
NOT NULL
created_at
TIMESTAMP
NOT NULL

tracks

Audio tracks — the core catalog with AI detection status

FieldTypeConstraints
id
UUID
PK
artist_id
UUID
FK → artists
NOT NULL
album_id
UUID
FK → albums
title
VARCHAR(300)
NOT NULL
isrc
CHAR(12)
UNIQUE
duration_ms
INTEGER
NOT NULL
genre
VARCHAR(50)
audio_fingerprint
CHAR(64)
UNIQUE
NOT NULL
base44_rights_hash
CHAR(64)
UNIQUE
NOT NULL
hls_manifest_url
VARCHAR(500)
ai_detection_status
ENUM
NOT NULL
ai_confidence_score
DECIMAL(5,4)
source_platform
ENUM
published
BOOLEAN
DEFAULT false
created_at
TIMESTAMP
NOT NULL

albums

Album groupings for track organization

FieldTypeConstraints
id
UUID
PK
artist_id
UUID
FK → artists
NOT NULL
title
VARCHAR(300)
NOT NULL
cover_art_url
VARCHAR(500)
upc
CHAR(12)
UNIQUE
release_date
DATE
track_count
INTEGER
DEFAULT 0
created_at
TIMESTAMP
NOT NULL

listen_events

Validated stream events — feeds the payout engine

FieldTypeConstraints
id
BIGINT
PK
AUTO_INCREMENT
user_id
UUID
FK → users
NOT NULL
track_id
UUID
FK → tracks
NOT NULL
artist_id
UUID
FK → artists
NOT NULL
started_at
TIMESTAMP
NOT NULL
duration_listened_ms
INTEGER
NOT NULL
qualified
BOOLEAN
NOT NULL
fraud_score
DECIMAL(3,2)
device_fingerprint
CHAR(64)
ip_hash
CHAR(64)
country_code
CHAR(2)

payout_periods

Monthly payout calculation periods

FieldTypeConstraints
id
UUID
PK
period_start
DATE
NOT NULL
period_end
DATE
NOT NULL
active_subscribers
INTEGER
NOT NULL
total_pool_usd
DECIMAL(12,2)
NOT NULL
total_qualified_listens
BIGINT
NOT NULL
status
ENUM
NOT NULL
finalized_at
TIMESTAMP

artist_payouts

Per-artist payout records for each period

FieldTypeConstraints
id
UUID
PK
payout_period_id
UUID
FK → payout_periods
NOT NULL
artist_id
UUID
FK → artists
NOT NULL
qualified_listens
BIGINT
NOT NULL
share_percentage
DECIMAL(10,8)
NOT NULL
payout_amount_usd
DECIMAL(10,2)
NOT NULL
stripe_transfer_id
VARCHAR(255)
transfer_status
ENUM
NOT NULL
smart_contract_tx
VARCHAR(66)

merch_products

Artist merchandise listings

FieldTypeConstraints
id
UUID
PK
artist_id
UUID
FK → artists
NOT NULL
name
VARCHAR(200)
NOT NULL
description
TEXT
price_usd
DECIMAL(8,2)
NOT NULL
category
ENUM
NOT NULL
image_url
VARCHAR(500)
inventory_count
INTEGER
DEFAULT 0
fulfillment_partner
ENUM
active
BOOLEAN
DEFAULT true

merch_orders

Merchandise purchase orders

FieldTypeConstraints
id
UUID
PK
user_id
UUID
FK → users
NOT NULL
artist_id
UUID
FK → artists
NOT NULL
total_usd
DECIMAL(8,2)
NOT NULL
platform_commission_usd
DECIMAL(8,2)
NOT NULL
artist_revenue_usd
DECIMAL(8,2)
NOT NULL
stripe_payment_id
VARCHAR(255)
fulfillment_status
ENUM
NOT NULL
tracking_number
VARCHAR(100)
created_at
TIMESTAMP
NOT NULL

provenance_log

Append-only Base-44 identity and rights chain ledger

FieldTypeConstraints
id
BIGINT
PK
AUTO_INCREMENT
entity_type
ENUM
NOT NULL
entity_id
UUID
NOT NULL
action
ENUM
NOT NULL
base44_hash
CHAR(64)
NOT NULL
prev_hash
CHAR(64)
metadata_json
JSONB
ipfs_cid
VARCHAR(100)
created_at
TIMESTAMP
NOT NULL
IMMUTABLE

fraud_events

Detected fraudulent or suspicious activity

FieldTypeConstraints
id
BIGINT
PK
AUTO_INCREMENT
user_id
UUID
FK → users
event_type
ENUM
NOT NULL
severity
ENUM
NOT NULL
details_json
JSONB
action_taken
ENUM
NOT NULL
reviewed_by
UUID
created_at
TIMESTAMP
NOT NULL

Key Indexes

• listen_events(user_id, started_at)
• listen_events(artist_id, qualified, started_at)
• tracks(audio_fingerprint)
• tracks(ai_detection_status, published)
• artist_payouts(payout_period_id, artist_id)
• provenance_log(entity_type, entity_id)
• fraud_events(user_id, created_at)
• merch_orders(user_id, created_at)
0:00
0:00

Welcome to Tonal

Human-made music, fair payouts, and a platform built for independent artists.

Human-made music only
Support artists directly
AI-generated music blocked
Transparent payouts
1 / 7