Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Database specialist covering PostgreSQL, MongoDB, Redis, and advanced data patterns for modern applications
.claude/skills/microck-moai-domain-database/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-03 | ✗→✓ | ▲ Improved | 62% | 0% |
| case-04 | ✗→✓ | ▲ Improved | 143% | 0% |
| case-05 | ✗→✓ | ▲ Improved | -15% | 0% |
| case-06 | ✗→✓ | ▲ Improved | 29% | 0% |
| case-18 | ✗→✓ | ▲ Improved | 20% | 0% |
Enterprise Database Expertise - Comprehensive database patterns and implementations covering PostgreSQL, MongoDB, Redis, and advanced data management for scalable modern applications.
Core Capabilities:
When to Use:
Database Stack Initialization:
pythonfrom moai_domain_database import DatabaseManager # Initialize multi-database stack db_manager = DatabaseManager() # Configure PostgreSQL for relational data postgresql = db_manager.setup_postgresql( connection_string="postgresql://...", connection_pool_size=20, enable_query_logging=True ) # Configure MongoDB for document storage mongodb = db_manager.setup_mongodb( connection_string="mongodb://...", database_name="app_data", enable_sharding=True ) # Configure Redis for caching and real-time features redis = db_manager.setup_redis( connection_string="redis://...", max_connections=50, enable_clustering=True ) # Use unified database interface user_data = db_manager.get_user_with_profile(user_id) analytics = db_manager.get_user_analytics(user_id, time_range="30d")
Single Database Operations:
bash# PostgreSQL schema migration moai db:migrate --database postgresql --migration-file schema_v2.sql # MongoDB aggregation pipeline moai db:aggregate --collection users --pipeline analytics_pipeline.json # Redis cache warming moai db:cache:warm --pattern "user:*" --ttl 3600
modules/postgresql.md)modules/mongodb.md)modules/redis.md)Polyglot Persistence Pattern:
pythonclass DataRouter: def __init__(self): self.postgresql = PostgreSQLConnection() self.mongodb = MongoDBConnection() self.redis = RedisConnection() def get_user_profile(self, user_id): # Get structured user data from PostgreSQL user = self.postgresql.get_user(user_id) # Get flexible profile data from MongoDB profile = self.mongodb.get_user_profile(user_id) # Get real-time status from Redis status = self.redis.get_user_status(user_id) return self.merge_user_data(user, profile, status) def update_user_data(self, user_id, data): # Route different data types to appropriate databases if 'structured_data' in data: self.postgresql.update_user(user_id, data['structured_data']) if 'profile_data' in data: self.mongodb.update_user_profile(user_id, data['profile_data']) if 'real_time_data' in data: self.redis.set_user_status(user_id, data['real_time_data']) # Invalidate cache across databases self.invalidate_user_cache(user_id)
Data Synchronization:
pythonclass DataSyncManager: def sync_user_data(self, user_id): # Sync from PostgreSQL to MongoDB for search pg_user = self.postgresql.get_user(user_id) search_document = self.create_search_document(pg_user) self.mongodb.upsert_user_search(user_id, search_document) # Update cache in Redis cache_data = self.create_cache_document(pg_user) self.redis.set_user_cache(user_id, cache_data, ttl=3600)
Query Performance Analysis:
python# PostgreSQL query optimization def analyze_query_performance(query): explain_result = postgresql.execute(f"EXPLAIN (ANALYZE, BUFFERS) {query}") return QueryAnalyzer(explain_result).get_optimization_suggestions() # MongoDB aggregation optimization def optimize_aggregation_pipeline(pipeline): optimizer = AggregationOptimizer() return optimizer.optimize_pipeline(pipeline) # Redis performance monitoring def monitor_redis_performance(): metrics = redis.info() return PerformanceAnalyzer(metrics).get_recommendations()
Scaling Strategies:
python# Read replicas for PostgreSQL read_replicas = postgresql.setup_read_replicas([ "postgresql://replica1...", "postgresql://replica2..." ]) # Sharding for MongoDB mongodb.setup_sharding( shard_key="user_id", num_shards=4 ) # Redis clustering redis.setup_cluster([ "redis://node1:7000", "redis://node2:7000", "redis://node3:7000" ])
Complementary Skills:
moai-domain-backend - API integration and business logicmoai-foundation-core - Database migration and schema managementmoai-workflow-project - Database project setup and configurationmoai-platform-baas - BaaS database integration patternsTechnology Integration:
python# PostgreSQL advanced queries users = postgresql.query( "SELECT * FROM users WHERE created_at > %s ORDER BY activity_score DESC LIMIT 100", [datetime.now() - timedelta(days=30)] ) # MongoDB analytics analytics = mongodb.aggregate('events', [ {"$match": {"timestamp": {"$gte": start_date}}}, {"$group": {"_id": "$type", "count": {"$sum": 1}}}, {"$sort": {"count": -1}} ]) # Redis caching operations async def get_user_data(user_id): cache_key = f"user:{user_id}" data = await redis.get(cache_key) if not data: data = fetch_from_database(user_id) await redis.setex(cache_key, 3600, json.dumps(data)) return json.loads(data)
pythonasync def create_user_with_profile(user_data, profile_data): try: # Start transaction across databases async with transaction_manager(): # Create user in PostgreSQL user_id = await postgresql.insert_user(user_data) # Create profile in MongoDB await mongodb.insert_user_profile(user_id, profile_data) # Set initial cache in Redis await redis.set_user_cache(user_id, { "id": user_id, "status": "active", "created_at": datetime.now().isoformat() }) return user_id except Exception as e: # Automatic rollback across databases logger.error(f"User creation failed: {e}") raise
Relational Database:
NoSQL Database:
In-Memory Database:
Supporting Tools:
Performance Features:
For detailed implementation patterns and database-specific optimizations, see the modules/ directory.
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 18,426 | 19,356 | +5% | 1 | 1 | 0% | 3,792 | 6,110 | +61% | 0 | 0 | — |
case-02 | fail→fail | 26,090 | 21,849 | -16% | 1 | 1 | 0% | 4,834 | 6,135 | +27% | 0 | 0 | — |
case-03 | fail→pass | 8,678 | 3,116 | -64% | 1 | 1 | 0% | 1,601 | 2,599 | +62% | 0 | 0 | — |
case-04 | fail→pass | 6,905 | 4,384 | -37% | 1 | 1 | 0% | 1,170 | 2,843 | +143% | 0 | 0 | — |
case-05 | fail→pass | 16,871 | 3,218 | -81% | 1 | 1 | 0% | 3,108 | 2,632 | -15% | 0 | 0 | — |
case-06 | fail→pass | 11,886 | 4,151 | -65% | 1 | 1 | 0% | 2,152 | 2,785 | +29% | 0 | 0 | — |
case-07 | pass→pass | 17,396 | 19,235 | +11% | 1 | 1 | 0% | 3,535 | 6,127 | +73% | 0 | 0 | — |
case-08 | fail→fail | 21,029 | 16,254 | -23% | 1 | 1 | 0% | 4,430 | 5,328 | +20% | 0 | 0 | — |
case-09 | fail→fail | 13,585 | 16,105 | +19% | 1 | 1 | 0% | 2,474 | 5,514 | +123% | 0 | 0 | — |
case-10 | fail→fail | 16,632 | 15,418 | -7% | 1 | 1 | 0% | 3,117 | 5,088 | +63% | 0 | 0 | — |
case-11 | fail→fail | 18,298 | 18,588 | +2% | 1 | 1 | 0% | 3,555 | 6,101 | +72% | 0 | 0 | — |
case-12 | fail→fail | 15,723 | 16,034 | +2% | 1 | 1 | 0% | 3,074 | 5,335 | +74% | 0 | 0 | — |
case-13 | fail→fail | 14,331 | 11,909 | -17% | 1 | 1 | 0% | 2,690 | 4,367 | +62% | 0 | 0 | — |
case-14 | fail→fail | 13,153 | 17,645 | +34% | 1 | 1 | 0% | 2,541 | 5,713 | +125% | 0 | 0 | — |
case-15 | pass→pass | 11,064 | 11,443 | +3% | 1 | 1 | 0% | 2,110 | 4,354 | +106% | 0 | 0 | — |
case-16 | pass→pass | 9,645 | 10,263 | +6% | 1 | 1 | 0% | 1,997 | 4,087 | +105% | 0 | 0 | — |
case-17 | pass→pass | 8,124 | 5,468 | -33% | 1 | 1 | 0% | 1,478 | 3,170 | +114% | 0 | 0 | — |
case-18 | fail→pass | 10,971 | 2,094 | -81% | 1 | 1 | 0% | 2,014 | 2,417 | +20% | 0 | 0 | — |
case-19 | fail→pass | 8,038 | 2,834 | -65% | 1 | 1 | 0% | 1,389 | 2,535 | +83% | 0 | 0 | — |
case-20 | pass→pass | 4,528 | 4,587 | +1% | 1 | 1 | 0% | 633 | 2,997 | +373% | 0 | 0 | — |
case-21 | pass→pass | 7,573 | 11,934 | +58% | 1 | 1 | 0% | 1,646 | 4,474 | +172% | 0 | 0 | — |
case-22 | pass→pass | 6,211 | 5,131 | -17% | 1 | 1 | 0% | 1,182 | 3,024 | +156% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +27 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.