Логотип Db Schema

Db Schema

Спільнота
kazdenc
db-schema

Design a database schema from product requirements. Postgres-first with Supabase awareness. Use when user says "design the database", "create schema", "data model", "database structure", "what tables do I need", "schema design", or needs to translate requirements into a relational schema.

Огляд

Видавецьkazdenc
Репозиторійbuilder-skills
Назва навичкиdb-schema
Зірки
46
Форки
5
Файли в пакеті
Лише інструкції
ЛіцензіяMIT
Посилання
  • Інструкції у форматі Markdown

    Файл SKILL.md, який модель завантажує за потреби, тож токени витрачаються лише тоді, коли запит справді відповідає навичці.

  • Працює з будь-якою LLM

    Навички ШІ — це звичайний Markdown, а не код для певного постачальника, тому вони працюють із GPT, Claude, Gemini, Grok або локальною моделлю.

  • Усе необхідне — в інструкціях

    Усе потрібне моделі міститься в інструкціях — жодних додаткових файлів для синхронізації.

  • Відкритий вихідний код

    Опубліковано на GitHub користувачем kazdenc. Перегляньте вихідний вміст перед установленням.

Встановлення

Установіть навичку ШІ Db Schema у TypingMind, щоб використовувати її з будь-якою LLM, або додайте її до іншого агента, що читає SKILL.md.

1

Встановити в TypingMind

TypingMind встановлює навичку безпосередньо з її папки GitHub — читає SKILL.md, збирає файли ресурсів у пакет і зберігає результат локально.

  1. Відкрийте застосунок і перейдіть до Плагіни → Навички.
  2. Виберіть «Встановити з GitHub».
  3. Вставте наведений нижче URL папки навички та підтвердьте встановлення.
    https://github.com/kazdenc/builder-skills/tree/main/.claude/skills/dev/setup/db-schema
  4. Увімкніть навичку в кожному чаті, де хочете її використовувати.
Плагіни → Навички → Нова навичка → За URL GitHub, потім вставте URL папки й натисніть «Продовжити».
2

Встановити в іншому агенті

Будь-який агент, що підтримує формат Agent Skills, може використовувати цю навичку — скопіюйте папку до каталогу навичок цього агента.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/kazdenc/builder-skills.git /tmp/builder-skills
mkdir -p .claude/skills
cp -r /tmp/builder-skills/.claude/skills/dev/setup/db-schema .claude/skills/db-schema
Після копіювання перезапустіть Claude Code, щоб завантажити нову навичку.

Використовуйте навичку в TypingMind

Увімкніть навичку Db Schema в будь-якому чаті TypingMind, і далі модель усе зробить сама. Назва й опис навички містяться в системному промпті, а щойно надходить відповідний запит, модель самостійно завантажує повні інструкції — вам не потрібно викликати навичку вручну, і до фактичного використання вона не витрачає токенів.

Модель самостійно завантажує навичку Db Schema, щойно надходить відповідний запит.

Працює з будь-якою моделлю ШІ

Навички ШІ — це звичайні інструкції Markdown, а не код для певного постачальника, тому навичка Db Schema не прив’язана до моделі, для якої її створено. Установіть її один раз у TypingMind і використовуйте з GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama або локальною моделлю, яку ви запускаєте самостійно, — усе з вашими власними ключами API.

  • Завантажується лише за потреби

    Системний промпт містить лише назву й опис. Інструкції завантажуються за першого відповідного запиту, тож невикористана навичка нічого не коштує.

  • Змінюйте моделі під час чату

    Оскільки навичка — це інструкції, а не код, зміна моделі не порушує її роботу: наступна модель читає той самий файл SKILL.md.

Інструкції навички

Це вміст файлу SKILL.md, який завантажує модель. Прочитайте його перед установленням — навичка містить інструкції, яких дотримуватиметься ваша модель.

Database Schema Design

Design a Postgres database schema from product requirements. If target is provided, scope to that feature. Otherwise, ask the user what they're building.

Step 1: Identify Entities and Relationships

Read the requirements (PRD, user stories, or conversation). Extract:

  • Nouns = candidate tables (users, projects, comments, invoices)
  • Verbs = candidate relationships (creates, belongs to, has many)
  • Adjectives/states = candidate columns or enums (active, draft, published)

Ask clarifying questions if the requirements are ambiguous. Don't guess at business logic.

Step 2: Design Tables

Follow these conventions on every table:

ConventionRuleExample
Table namessnake_case, pluraluser_profiles, org_members
Column namessnake_casefirst_name, created_at
Primary keysuuid, auto-generatedid uuid default gen_random_uuid() primary key
TimestampsOn every table, non-nullablecreated_at timestamptz default now() not null
Updated timestampOn every tableupdated_at timestamptz default now() not null
Foreign keysNamed explicitly, with on deleteuser_id uuid references users(id) on delete cascade
Soft deletesUse deleted_at timestamptz when neededOnly when business requires undo/recovery
BooleansPrefix with is_ or has_is_active, has_verified_email

Postgres Type Recommendations

DataUseDon't useWhy
Identifiersuuidserial, integerNon-sequential, safe to expose, no collision across tables
TimestampstimestamptztimestampAlways store timezone-aware. Convert on display.
Moneynumeric(12,2) or bigint (cents)float, realFloating point causes rounding errors
Emailtext with check constraintvarchar(255)text is faster in Postgres. Constrain with check.
Short stringstextvarchar(n)Postgres text has no performance penalty. Use check(length(col) <= n) if needed.
Status/enumtext with check, or Postgres enumMagic integerscheck (status in ('draft','published','archived'))
JSON datajsonbjsonjsonb is indexable and more efficient
IP addressesinettextNative type supports operations
Tags/arraystext[] or junction tableCSV in text columnArrays for simple cases, junction table for queryable tags

Step 3: Define Relationships

One-to-Many

Put the foreign key on the "many" side:

sql
create table posts (
  id uuid default gen_random_uuid() primary key,
  user_id uuid references users(id) on delete cascade not null,
  title text not null,
  created_at timestamptz default now() not null,
  updated_at timestamptz default now() not null
);

One-to-One

Same as one-to-many but add a unique constraint:

sql
create table user_profiles (
  id uuid default gen_random_uuid() primary key,
  user_id uuid references users(id) on delete cascade not null unique,
  bio text,
  avatar_url text,
  created_at timestamptz default now() not null,
  updated_at timestamptz default now() not null
);

Many-to-Many

Use a junction table. Name it <table_a>_<table_b> in alphabetical order, or use a domain name if clearer:

sql
create table project_members (
  project_id uuid references projects(id) on delete cascade not null,
  user_id uuid references users(id) on delete cascade not null,
  role text not null default 'member' check (role in ('owner','admin','member','viewer')),
  joined_at timestamptz default now() not null,
  primary key (project_id, user_id)
);

Step 4: Add Indexes

Create indexes for:

Index whenExample
Foreign keys (always)create index idx_posts_user_id on posts(user_id);
Columns in WHERE clausescreate index idx_posts_status on posts(status);
Columns in ORDER BYcreate index idx_posts_created_at on posts(created_at desc);
Unique lookupscreate unique index idx_users_email on users(email);
Composite queriescreate index idx_posts_user_status on posts(user_id, status);
Full-text searchcreate index idx_posts_title_search on posts using gin(to_tsvector('english', title));

Don't over-index. Each index costs write performance. Start with foreign keys and obvious query patterns. Add more based on actual query plans.

Step 5: Write the Migration

Put everything in a Supabase migration:

bash
npx supabase migration new create_initial_schema

Structure the migration file:

sql
-- 1. Create enums (if using Postgres enums)
-- 2. Create tables (parent tables first, then children)
-- 3. Create indexes
-- 4. Enable RLS on all tables
-- 5. Create RLS policies
-- 6. Create functions and triggers (e.g., updated_at trigger)

-- Updated_at trigger function (create once, reuse)
create or replace function update_updated_at()
returns trigger as $$
begin
  new.updated_at = now();
  return new;
end;
$$ language plpgsql;

-- Example table
create table users (
  id uuid default gen_random_uuid() primary key,
  email text not null unique,
  full_name text,
  avatar_url text,
  created_at timestamptz default now() not null,
  updated_at timestamptz default now() not null
);

-- Apply updated_at trigger
create trigger set_updated_at
  before update on users
  for each row execute function update_updated_at();

-- Enable RLS
alter table users enable row level security;

-- Indexes
create index idx_users_email on users(email);

Step 6: Supabase-Specific Guidance

ConcernApproach
Auth usersSupabase manages auth.users. Reference with auth.uid(). Create a public.users or public.profiles table that mirrors/extends it.
Auto-create profileUse a trigger on auth.users insert to create a row in public.profiles
RLSEnable on every table. Write policies immediately. See supabase-setup skill for patterns.
RealtimeAdd tables to Supabase Realtime publication if live updates are needed: alter publication supabase_realtime add table <table>;
Type generationRun npx supabase gen types typescript --local after every migration

Auto-create profile trigger

sql
create or replace function public.handle_new_user()
returns trigger as $$
begin
  insert into public.profiles (user_id, email, full_name, avatar_url)
  values (
    new.id,
    new.email,
    new.raw_user_meta_data->>'full_name',
    new.raw_user_meta_data->>'avatar_url'
  );
  return new;
end;
$$ language plpgsql security definer;

create trigger on_auth_user_created
  after insert on auth.users
  for each row execute function public.handle_new_user();

Schema Review Checklist

CheckPass?
Every table has id uuid primary key
Every table has created_at and updated_at
All foreign keys have on delete behavior defined
All foreign keys have indexes
RLS is enabled on every table
No varchar without justification (use text)
No timestamp without tz (use timestamptz)
No floating point for money
Junction tables have composite primary keys
updated_at trigger is applied to all tables
Migration runs cleanly on supabase db reset
Types regenerated after migration

Поширені запитання

Що робить навичка ШІ Db Schema?

Design a database schema from product requirements. Postgres-first with Supabase awareness. Use when user says "design the database", "create schema", "data model", "database structure", "what tables do I need", "schema design", or needs to translate requirements into a relational schema.

Навіщо використовувати Db Schema у TypingMind?

Тому що ви встановлюєте її один раз і використовуєте з будь-якою моделлю. Db Schema — це звичайний Markdown, а не код для конкретного постачальника, тому та сама навичка працює з GPT-5, Claude, Gemini, Grok або локальною моделлю. Ви можете змінити модель навіть посеред чату, і навичка продовжить працювати. TypingMind використовує ваші власні ключі API, тож ви платите безпосередньо постачальникам замість передплати за кожне місце користувача, а ваші навички й чати залишаються у вашому сховищі.

Як встановити Db Schema у TypingMind?

Відкрийте в TypingMind Плагіни → Навички → Встановити з GitHub і вставте https://github.com/kazdenc/builder-skills/tree/main/.claude/skills/dev/setup/db-schema. TypingMind прочитає файл SKILL.md і встановить навичку, яку можна вмикати окремо для кожного чату.

Які моделі ШІ можуть використовувати Db Schema?

Будь-яка модель, яку ви підключите в TypingMind. Навички ШІ — це звичайні інструкції у форматі Markdown, а не код для конкретного постачальника, тому GPT, Claude, Gemini, Grok і локальні моделі можуть завантажувати цю навичку, коли запит їй відповідає.

Зі скількома моделями ШІ можна використовувати Db Schema?

Зі скількома забажаєте. Якщо модель підтримує навички, ви можете використовувати з нею Db Schema — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama та інші — усе в TypingMind із власними ключами API.

Чи безкоштовна навичка ШІ Db Schema?

Так. Навичку опубліковано на GitHub: kazdenc, за ліцензією MIT. Ви платите лише своєму постачальнику ШІ за використані токени.

Що таке навички ШІ?

Навичка ШІ — це багаторазовий набір інструкцій, який навчає модель ШІ виконувати одне конкретне завдання. Він відповідає відкритому формату Agent Skills: файл SKILL.md із назвою та описом, а також скрипти, шаблони чи довідкові файли, які можуть знадобитися моделі. Модель читає інструкції лише тоді, коли ваш запит відповідає навичці, тому встановлена навичка нічого не коштує, доки її не використано.

Чим навички ШІ відрізняються від плагінів або серверів MCP?

Плагін або сервер MCP надає моделі нові інструменти для виклику — код, який десь виконується й повертає результат. Натомість навичка ШІ надає моделі знання та порядок дій: як підійти до завдання, яких кроків дотримуватися та яким має бути якісний результат. Навички — це звичайний Markdown, тож їм не потрібні ні сервер, ні ключ API, ні середовище виконання, і вони працюють із будь-якою моделлю.

Усі

Створіть власний ШІ-простір уже зараз

Підпишіться на нашу розсилку, щоб дізнаватися про нові функції та майбутні розіграші 👇