المهارات postgresql
📦

postgresql

آمن

Design PostgreSQL Database Schemas

متاح أيضًا من: 2025Emma,2025Emma

Database schema design errors cause performance issues and data integrity problems. This skill provides PostgreSQL-specific best practices for data types, indexes, constraints, and scalability patterns.

يدعم: Claude Codex Code(CC)
🥉 74 برونزي
1

تنزيل ZIP المهارة

2

رفع في Claude

اذهب إلى Settings → Capabilities → Skills → Upload skill

3

فعّل وابدأ الاستخدام

اختبرها

استخدام "postgresql". Design a users table with email, name, and timestamps

النتيجة المتوقعة:

  • CREATE TABLE users (
  • user_id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
  • email TEXT NOT NULL UNIQUE,
  • name TEXT NOT NULL,
  • created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
  • updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
  • );
  • CREATE UNIQUE INDEX ON users (LOWER(email));

استخدام "postgresql". Should I use UUID or BIGINT for primary keys?

النتيجة المتوقعة:

  • Use BIGINT GENERATED ALWAYS AS IDENTITY when:
  • - Sequential IDs are acceptable
  • - Index performance is critical
  • - Smaller index size matters
  •  
  • Use UUID when:
  • - Global uniqueness is required
  • - ID opacity is a security requirement
  • - Merging data from multiple sources

التدقيق الأمني

آمن
v1 • 2/24/2026

All 221 static analyzer findings were determined to be false positives. The skill consists entirely of markdown documentation (SKILL.md) with no executable code. Backtick characters are markdown formatting for code examples, not shell execution. References to security features like Row Level Security are PostgreSQL documentation, not Windows SAM access. The skill provides educational guidance for database schema design with no security risks.

1
الملفات التي تم فحصها
233
الأسطر التي تم تحليلها
0
النتائج
1
إجمالي عمليات التدقيق
لا توجد مشكلات أمنية
تم تدقيقه بواسطة: claude

درجة الجودة

38
الهندسة المعمارية
100
قابلية الصيانة
87
المحتوى
50
المجتمع
100
الأمان
91
الامتثال للمواصفات

ماذا يمكنك بناءه

New Application Schema Design

Design a complete database schema for a new web application with proper data types, primary keys, foreign key relationships, and indexes for common query patterns.

Schema Review and Optimization

Review existing table designs for performance issues, missing indexes, inappropriate data types, or constraint gaps that could cause data integrity problems.

Migration Planning

Plan safe schema evolution with transactional DDL, concurrent index creation, and strategies for adding columns to large tables without downtime.

جرّب هذه الموجهات

Basic Table Design
Design a PostgreSQL table for storing user profiles with fields for email, name, registration date, and optional profile settings. Use appropriate data types and constraints.
Index Strategy
I have a queries table with columns: id, user_id, status, created_at. Common queries filter by user_id and status, and sort by created_at descending. Recommend an indexing strategy.
JSONB Design Decision
Should I store product attributes in a JSONB column or create separate columns? The attributes vary by product category and users frequently search by specific attributes.
Large Table Partitioning
I have an events table growing at 10M rows per month. Queries typically filter by event_date and device_id. Recommend a partitioning strategy and explain trade-offs.

أفضل الممارسات

  • Use TIMESTAMPTZ instead of TIMESTAMP for all event timestamps to avoid timezone confusion
  • Add explicit indexes on foreign key columns since PostgreSQL does not create them automatically
  • Normalize to 3NF first, then denormalize only for proven high-ROI read performance gains

تجنب

  • Using VARCHAR with length limits instead of TEXT with CHECK constraints
  • Creating indexes on every column without analyzing actual query patterns
  • Using SERIAL instead of GENERATED ALWAYS AS IDENTITY for auto-increment columns

الأسئلة المتكررة

Should I use TEXT or VARCHAR for string columns?
Use TEXT for most cases. PostgreSQL stores TEXT and VARCHAR identically. If you need length validation, add a CHECK constraint rather than using VARCHAR(n).
Do I need to index foreign key columns?
Yes. PostgreSQL does not auto-index FK columns. Add explicit indexes on FK columns for join performance and to prevent locking issues during parent row deletions.
When should I use JSONB instead of regular columns?
Use JSONB for optional, variable, or semi-structured attributes. Keep core relational data in regular columns. Always add a GIN index on JSONB columns for containment queries.
What is the difference between TIMESTAMP and TIMESTAMPTZ?
TIMESTAMPTZ stores timestamps with timezone awareness and converts to UTC internally. TIMESTAMP stores literal values without timezone context. Always use TIMESTAMPTZ to avoid timezone bugs.
Should I partition my table?
Consider partitioning for tables exceeding 100M rows where queries consistently filter on a partition key like date. Partitioning adds complexity, so only use when clear benefits exist.
How do I safely add a NOT NULL column to a large table?
Add the column as NULL first, backfill data, then alter to NOT NULL. Adding NOT NULL with a volatile default like now() causes a full table rewrite. Use a non-volatile default or multi-step migration.

تفاصيل المطور

المؤلف

sickn33

الترخيص

MIT

مرجع

main

بنية الملفات

📄 SKILL.md