Skip to content

Relationships

Entity relationships in the Fangate database schema.


User → Products

users (1) ----< (*) products
  • One user (creator) has many products
  • products.user_idusers.id

User → Wallet

users (1) ---- (1) wallets
  • One user has one wallet
  • wallets.user_idusers.id

User → Currency

users (*) ---- (1) currencies
  • Many users can share a currency
  • users.currency_idcurrencies.id

Product ↔ Media (n:m)

products (*) ----< product_media >---- (*) media
  • Products and media are linked through the product_media pivot (product_id, media_id, sort_order)
  • The same media row can appear in multiple products (e.g. price links, bundles)
  • media.product_id is deprecated and kept for backward compatibility during migration
  • Media also belongs to a creator via media.user_idusers.id

Product → Currency

products (*) ---- (1) currencies
  • products.currency_idcurrencies.id

Collections

users (1) ---- (1) collections
collections (*) ----< (*) products  (via pivot)
  • One user has one collection (current design)
  • Collection has many products; product can be in one collection
  • Pivot: collection_product or similar

Affiliate / Referral

users (master) ----< (*) users (invited)
  • users may have master_id or equivalent linking to referring user
  • Referral relationships tracked for affiliate earnings

Transactions

wallets (1) ----< (*) transactions
  • Wallet has many transactions
  • Transaction types: product_earning, affiliate_earning, withdrawal, fee, refund, hold, release_hold, pending

products (1) ----< (*) consents (or consent_requests)
media (1) ----< (*) consent_creator_tags
products (1) ----< (*) consent_creator_tags
  • Product may have associated consent documents (legacy upload flow)
  • Consent creator tags belong to a media row (media_id) and retain product_id for seller APIs
  • Product is_should_consent is derived from linked media rows

Diagram (Simplified)

users
  ├── products (1:N)
  │     ├── media (N:M via product_media, legacy product_id on media)
  │     ├── consent_creator_tags (via product_id + media_id)
  │     ├── consents
  │     └── currency
  ├── wallet (1:1)
  │     └── transactions
  ├── collection (1:1)
  │     └── products (N:M)
  └── currency

media (library)
  └── consent_creator_tags (1:N)

Fangate backend developer documentation