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

products (1) ----< (*) media
  • One product has many media files (e.g. multiple photos, video)
  • media.product_idproducts.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)
  • Product may have associated consent documents
  • Consent linked to product and/or media

Diagram (Simplified)

users
  ├── products (1:N)
  │     ├── media (1:N)
  │     ├── consents
  │     └── currency
  ├── wallet (1:1)
  │     └── transactions
  ├── collection (1:1)
  │     └── products (N:M)
  └── currency

Fangate API Documentation