Database Schema Documentation

Comprehensive documentation of our Pokemon API database schema, data structures, field types, and relationships. Understand how data is organized for effective Pokemon card API integration.

Database Schema Overview

Core Entities

Cards, Sets, Prices, and Grading data with normalized relationships

Unique Identifiers

Consistent ID format across all entities for easy referencing

Indexed Fields

Optimized for fast queries on names, sets, prices, and dates

Entity Relationships

Sets

  • • id (Primary Key)
  • • name
  • • releaseDate
  • • total
←→

Cards

  • • id (Primary Key)
  • • setId (Foreign Key)
  • • name
  • • number

Price Data

  • • cardId (Foreign Key)
  • • market, low, high
  • • lastUpdated
  • • source

Graded Prices

  • • cardId (Foreign Key)
  • • grade, condition
  • • price
  • • population

Detailed Data Structures

Cards Collection Schema

{
  "id": "base1-4",                    // Unique identifier (setId-number)
  "name": "Charizard",               // Card name
  "supertype": "Pokémon",            // Card supertype
  "subtypes": ["Stage 2"],           // Array of subtypes
  "hp": "120",                       // Hit points (string or null)
  "types": ["Fire"],                 // Array of Pokemon types
  "rarity": "Rare Holo",             // Card rarity
  "artist": "Mitsuhiro Arita",       // Card artist
  "flavorText": "...",               // Flavor text (optional)
  "nationalPokedexNumbers": [6],     // Array of Pokedex numbers
  "number": "4",                     // Card number in set
  "set": {
    "id": "base1",                   // Set identifier
    "name": "Base Set",              // Set name
    "series": "Base",                // Series name
    "printedTotal": 102,             // Printed card count
    "total": 102,                    // Total cards including secrets
    "releaseDate": "1999/01/09",     // Release date (YYYY/MM/DD)
    "updatedAt": "2025/01/10",       // Last data update
    "images": {
      "symbol": "https://...",       // Set symbol URL
      "logo": "https://..."          // Set logo URL
    }
  },
  "images": {
    "small": "https://...",          // Small image URL (245x342)
    "large": "https://..."           // Large image URL (734x1024)
  },
  "tcgplayer": {
    "url": "https://...",            // TCGPlayer product URL
    "updatedAt": "2025-01-10",       // Last price update
    "prices": {
      "holofoil": {
        "low": 275.00,               // Lowest price
        "mid": 375.00,               // Mid price
        "high": 575.00,              // Highest price
        "market": 399.99,            // Market price
        "directLow": null            // Direct sale low price
      }
    }
  },
  "cardmarket": {
    "url": "https://...",            // Cardmarket URL
    "updatedAt": "2025-01-10",       // Last update
    "prices": {
      "averageSellPrice": 352.45,    // Average sell price
      "lowPrice": 249.50,            // Lowest price
      "trendPrice": 370.25,          // Trend price
      "germanProLow": null,          // German Pro low price
      "suggestedPrice": null,        // Suggested price
      "reverseHoloSell": null,       // Reverse holo sell price
      "reverseHoloLow": null,        // Reverse holo low price
      "reverseHoloTrend": null,      // Reverse holo trend
      "lowPriceExPlus": 275.00,      // Low price EX+ condition
      "avg1": 380.00,                // 1 day average
      "avg7": 375.50,                // 7 day average
      "avg30": 365.25                // 30 day average
    }
  },
  "ebay": {
    "updatedAt": "2025-01-10",       // Last update
    "prices": {
      "average": 405.75,             // Average sold price
      "low": 269.99,                 // Lowest sold price
      "high": 599.99                 // Highest sold price
    }
  },
  "gradedPrices": {
    "psa10": 15750.00,               // PSA 10 price
    "psa9": 1850.00,                 // PSA 9 price
    "psa8": 750.00,                  // PSA 8 price
    "psa7": 425.00,                  // PSA 7 price
    "bgs10": 12000.00,               // BGS 10 price
    "bgs9.5": 3200.00,               // BGS 9.5 price
    "bgs9": 1200.00,                 // BGS 9 price
    "cgc10": 8500.00                 // CGC 10 price
  },
  "lastUpdated": "2025-01-10T12:00:00Z", // Last data update
  "createdAt": "2024-01-01T00:00:00Z",   // Record creation date
  "priceHistory": [                  // Historical price data
    {
      "date": "2025-01-09",
      "market": 389.99,
      "low": 270.00,
      "high": 565.00
    }
  ]
}

Primary Fields:

  • String
    id: Unique identifier (setId-number)
  • String
    name: Card name (indexed)
  • String
    rarity: Card rarity level
  • Array
    types: Pokemon types
  • Object
    set: Set information

Price Fields:

  • Object
    tcgplayer: TCGPlayer pricing
  • Object
    cardmarket: European prices
  • Object
    ebay: eBay sold listings
  • Object
    gradedPrices: Graded card values
  • Array
    priceHistory: Historical data

Database Indexes & Performance

Search Indexes

Optimized Query Fields:

  • Primary
    cards.id - Unique lookups
  • Index
    cards.name - Text search
  • Index
    cards.setId - Set filtering
  • Index
    cards.rarity - Rarity queries
  • Index
    cards.types - Type filtering
  • Index
    cards.lastUpdated - Freshness
  • Compound
    setId + number - Card identification

Performance Metrics:

  • • Average query time: <50ms
  • • Complex searches: <200ms
  • • 99th percentile: <500ms

Data Integrity

Validation Rules:

  • Required
    id, name, setId - Must exist
  • Format
    id - Must match setId-number
  • Range
    prices - Must be positive numbers
  • Date
    lastUpdated - Valid timestamp
  • Enum
    rarity - Predefined values

Data Quality:

  • • Automated validation checks
  • • Price anomaly detection
  • • Missing data monitoring
  • • Regular integrity audits

API Response Mapping

Database to API Response Transformation

Understanding how database fields map to API responses helps with integration and debugging.

// Database Document (MongoDB)
{
  "_id": ObjectId("..."),
  "id": "base1-4",
  "name": "Charizard",
  "tcgplayer_prices": {
    "holofoil_market": 399.99,
    "updated_at": ISODate("2025-01-10T12:00:00Z")
  }
}

// API Response (JSON)
{
  "id": "base1-4",
  "name": "Charizard",
  "prices": {
    "tcgplayer": {
      "market": 399.99,
      "lastUpdated": "2025-01-10T12:00:00Z"
    }
  }
}

// Transformation Rules:
// 1. Remove internal MongoDB _id field
// 2. Flatten nested price structures
// 3. Convert snake_case to camelCase
// 4. Format dates to ISO 8601 strings
// 5. Add calculated fields (averages, trends)
// 6. Apply field-level permissions based on API key tier

Response Processing:

  • • Field filtering by subscription tier
  • • Price aggregation and calculations
  • • Image URL generation
  • • Pagination metadata addition

Performance Optimizations:

  • • Field projection to reduce bandwidth
  • • Conditional field inclusion
  • • Response caching at API level
  • • Compressed response encoding

Schema Evolution & Migration

Version History & Breaking Changes

v2.1 (Current) - January 2025

  • • Added CGC grading data
  • • Enhanced price history granularity
  • • Added market trend indicators
  • • Improved set expected value calculations

v2.0 - October 2024

  • Breaking
    Restructured price objects
  • • Added CardMarket European pricing
  • • Enhanced graded card population data
  • • Improved image URL structure

v1.5 - June 2024

  • • Added eBay sold listing integration
  • • Enhanced set metadata
  • • Added price trend analysis

🔄 Migration Support

We maintain backwards compatibility for at least 12 months after schema changes. Migration guides and automated tools are provided for breaking changes.

Ready to Integrate with Our Database?

Start building applications with comprehensive Pokemon card data and pricing information