AI Relationship Discovery

Powered by OpenAI

Discover hidden connections between your Firestore collections and get AI-powered schema optimization suggestions to fix vibe coding anti-patterns using advanced analysis of field patterns, naming conventions, and data samples.

How AI Relationship Discovery Works

Our AI system analyzes your Firestore collections using GPT-4 to identify potential relationships based on field names, data types, and actual content patterns. It also detects common vibe coding anti-patterns where AI tools incorrectly apply relational database thinking to NoSQL, providing confidence scores and detailed explanations for each discovered relationship and optimization.

Pattern Recognition
Identifies ID fields, foreign keys, and reference patterns across collections
Smart Analysis
Analyzes field names, types, and sample data to find hidden connections
Confidence Scoring
Provides reliability scores from 0-100% with detailed explanations
Vibe Coding Schema Optimization

Our AI specifically detects and fixes common anti-patterns created by AI coding tools like Cursor, Claude, and Replit when they incorrectly apply relational database patterns to NoSQL Firestore databases.

Common Vibe Coding Issues Fixed:

  • Separate Collections: AI creates `users` and `userProfiles` when data should be embedded
  • Excessive Reads: Requiring 2+ reads per query instead of 1 optimized read
  • Higher Costs: Unnecessary Firestore billing from inefficient queries
  • Our Solution: Suggests embedded document structures with cost analysis
AI Tool Detection
Identifies patterns specific to Cursor, Claude, Replit, and other vibe coding tools
Cost Analysis
Shows before/after performance with percentage savings (e.g., '2 reads → 1 read = 50% savings')

Getting Started

1

Navigate to AI Relationships

From the Database Explorer, switch to the "AI Relationships" tab. You'll see all available collections in your Firebase project ready for analysis.

2

Select Collections for Analysis

Choose 2-10 collections that you suspect might be related. The AI will analyze relationships between all selected collections:

  • Start small - Begin with 2-3 collections for faster results
  • Related data - Select collections that logically might connect
  • Limit selection - Maximum 10 collections to avoid timeouts
3

Configure Analysis Settings

Adjust the analysis depth and sample size based on your needs:

Analysis Depth Options

  • Shallow: Quick analysis focusing on obvious patterns (fastest)
  • Medium: Balanced analysis with good accuracy (recommended)
  • Deep: Comprehensive analysis including subtle patterns (slowest)
4

Review Discovered Relationships

Once analysis completes, review the discovered relationships with their confidence scores and explanations. Use this information to understand your data structure better.

5

Review Vibe Coding Optimizations

Pay special attention to any vibe coding anti-patterns detected by the AI. These optimizations can significantly reduce your Firestore costs and improve performance:

  • Priority fixes - Address vibe coding issues first (marked with AI tool badges)
  • Cost analysis - Review percentage savings from each optimization
  • Implementation guides - Follow step-by-step migration instructions
  • Schema comparison - Use before/after views to understand changes

Understanding Results

Confidence Scores
How to interpret the AI's confidence levels in discovered relationships

High Confidence (80-100%)

Strong evidence of relationship. Clear field name matches, consistent data types, and logical connection patterns. These relationships are very likely accurate.

Medium Confidence (50-79%)

Moderate evidence of relationship. Some matching patterns but may require manual verification. Good starting point for investigation.

Low Confidence (0-49%)

Weak evidence or speculative relationship. May be coincidental patterns. Use caution and verify manually before relying on these connections.

Relationship Types

Foreign Key Relationships

Fields that reference documents in other collections (e.g., userId, productId, categoryId)

Hierarchical Relationships

Parent-child relationships where one collection contains subcategories of another

Many-to-Many Relationships

Junction tables or collections that link multiple entities together

Semantic Relationships

Logical connections based on field names and data patterns that suggest related business concepts

Schema Optimization Types
Understanding the different types of vibe coding optimizations suggested by the AI

Embed Collection

Combines separate collections into embedded documents. Most common vibe coding fix. Example: `users` + `userProfiles` → embedded `users` with profile data.

Denormalize Field

Duplicates frequently accessed data to reduce queries. Good for read-heavy data. Example: Adding user name to posts collection to avoid user lookup.

Merge Collections

Combines multiple related collections into a single collection with type fields. Good for similar data structures that were unnecessarily separated.

Advanced Configuration

Analysis Parameters

Sample Size

Small (1-10 docs):Fast, basic patterns
Medium (20-50 docs):Balanced accuracy
Large (100-500 docs):Comprehensive analysis

Analysis Depth

Shallow:~10-30 seconds
Medium:~30-60 seconds
Deep:~60-120 seconds

Best Practices

Optimizing Analysis
  • Use consistent naming conventions in your collections for better detection
  • Include collections with obvious relationships first to validate AI accuracy
  • Analyze related collections together (e.g., users, orders, products)
  • Re-run analysis after significant schema changes
Data Quality Tips
  • 💡Ensure collections have sufficient sample data (at least 10-20 documents)
  • 💡Use descriptive field names that indicate their purpose (userId vs uid)
  • 💡Include representative data that shows typical usage patterns
Vibe Coding Optimization Tips
  • Start with high-confidence, low-complexity optimizations first
  • Test optimizations in development before applying to production
  • Use the migration guides for step-by-step implementation instructions
  • Monitor Firestore usage after applying optimizations to verify cost savings

Troubleshooting

Common Issues

AI analysis not available

Ensure your subscription includes AI features and that OpenAI API is properly configured. Check the status indicator in the AI Relationships tab.

No relationships found

Try selecting different collections, increasing sample size, or using deeper analysis. Some datasets may genuinely have no detectable relationships.

Analysis timeout

Reduce the number of selected collections (try 3-5 instead of 10) or decrease the sample size. Large analyses may need to be split into smaller groups.

Low confidence results

Increase analysis depth, ensure collections have meaningful field names, or verify that the collections actually contain related data.

No vibe coding optimizations found

Your schema may already be well-optimized for NoSQL! This is good news. If you suspect issues, try analyzing collections created by AI tools specifically.

Optimization seems incorrect

Check the confidence score and explanation. Not all optimizations fit every use case. Consider your specific read/write patterns and data access requirements.

Example: E-commerce Analysis with Vibe Coding Optimization

Here's how AI might analyze relationships and detect vibe coding issues in a typical e-commerce database:

Relationship Discovery:

Users ↔ Orders:95% confidence

Strong relationship: orders.userId field matches users collection document IDs

Orders ↔ Products:78% confidence

Likely relationship: orders.items.productId appears to reference products collection

Products ↔ Categories:89% confidence

Clear relationship: products.categoryId field matches categories collection structure

Vibe Coding Issues Detected:

❌ Users + UserProfiles:92% confidenceClaude Pattern

Separate collections should be embedded. Cost saving: 50% (2 reads → 1 read)

❌ Orders + OrderItems:85% confidenceCursor Pattern

Order items should be embedded in orders. Cost saving: 67% (3 reads → 1 read)

Enhance Your Analysis

Combine AI relationship discovery with schema visualization and data browsing for a complete understanding of your database structure.