Relationships
Entity relationships in the Fangate database schema.
User → Products
users (1) ----< (*) products- One user (creator) has many products
products.user_id→users.id
User → Wallet
users (1) ---- (1) wallets- One user has one wallet
wallets.user_id→users.id
User → Currency
users (*) ---- (1) currencies- Many users can share a currency
users.currency_id→currencies.id
Product ↔ Media (n:m)
products (*) ----< product_media >---- (*) media- Products and media are linked through the
product_mediapivot (product_id,media_id,sort_order) - The same media row can appear in multiple products (e.g. price links, bundles)
media.product_idis deprecated and kept for backward compatibility during migration- Media also belongs to a creator via
media.user_id→users.id
Product → Currency
products (*) ---- (1) currenciesproducts.currency_id→currencies.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_productor similar
Affiliate / Referral
users (master) ----< (*) users (invited)usersmay havemaster_idor 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
Consent
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 retainproduct_idfor seller APIs - Product
is_should_consentis 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)