ডকুমেন্টেশনডেটাবেস স্পেসিফিকেশন
মনচিত্র প্রজেক্ট গাইড

ডেটাবেস স্পেসিফিকেশন

প্রস্তাবিত relational entity, প্রধান field, সম্পর্ক, index ও row-level access rule।

Schema অবস্থা ও নিয়ম

পরিদর্শনের সময় সংযুক্ত Supabase database-এ public table ছিল না। এই নথি target model নির্ধারণ করে; migration প্রয়োগ ও পুনরায় যাচাই না হওয়া পর্যন্ত table বা capability deployed বলে ধরা যাবে না।

  • UUID primary key, timestamptz audit field, explicit foreign key ও check constraint ব্যবহার করুন।
  • foreign key এবং সাধারণ owner/status/date query path index করুন।
  • user, child, annotation, progress ও payment-সম্পর্কিত সব table-এ RLS চালু করুন।

মূল entity ও সম্পর্ক

Tableগুরুত্বপূর্ণ fieldসম্পর্ক / index
profilesid (auth user FK), display_name, locale, created_atপ্রতি auth user-এ একটি profile
student_profilesuser_id, class_level, curriculum, medium, board, consent_stateprofile FK; class/medium index
guardian_linksguardian_id, student_id, status, approved_atguardian/student pair unique; status index
teachers / class_membersteacher_id, class_id, student_id, rolemembership FK; class/user index
curriculums / bookscode, class_level, medium, subject, title, statusপ্রকাশিত content index
book_versions / chapters / pagesversion, chapter_order, page_number, localized bodybook/version ও chapter/page order unique
text_nodes / audio_assetspage_id, node_key, text, locale, asset_key, rightsPage FK; locale ও order index
annotations / bookmarksuser_id, page_id, kind, selected_text, note, colorOwner/page index; owner-only RLS
questions / quiz_attemptschapter_id, version, prompt, options, key, explanation, answers, scoreশিক্ষার্থী তালিকায় answer key প্রকাশ নয়
study_rooms / room_members / commentsroom_id, member_id, status, body, moderation_stateপ্রতিটি room write-এ membership যাচাই
learning_progressuser_id, book_version_id, page_index, completed_atuser/book-version unique; user scope
subscriptions / paymentsuser_id, provider, status, amount_bdt, idempotency_keyserver-only mutation; unique idempotency key

RLS policy matrix

ডেটা শ্রেণিReadWrite
প্রকাশিত শিক্ষামূলক contentপ্রকাশিত row-এ anonymous/authenticated readশুধু editor/admin server path
Profile ও student recordমালিক; অনুমোদিত linked guardian summaryমালিক-সীমিত field; role field server-only
Private note ও bookmarkশুধু মালিকমালিক ও বৈধ page relationship
Quiz attempt ও progressশিক্ষার্থী মালিক; স্পষ্ট scope-এ guardian
Room contentঅনুমোদিত room member ও moderatorবিদ্যমান membership + moderation rule
Subscription/paymentমালিক-নিরাপদ receipt summaryশুধু trusted server/provider webhook

Index ও data integrity

  • Unique: guardian_links(guardian_id, student_id); bookmarks(user_id, page_id); learning_progress(user_id, book_version_id)।
  • Composite: pages(chapter_id, page_number); chapters(book_version_id, position); questions(chapter_id, status, position)।
  • নির্ভরশীল learning content-এ ON DELETE CASCADE ব্যবহার করুন; অনুমোদিত retention policy অনুযায়ী financial audit record রাখুন।
  • medium, status, annotation kind, BDT amount ও consent state constraint দিয়ে যাচাই করুন।

উদাহরণ record ও migration

উদাহরণ table contract sql
create table public.bookmarks (
  id uuid primary key default gen_random_uuid(),
  user_id uuid not null references auth.users(id) on delete cascade,
  page_id uuid not null references public.pages(id) on delete cascade,
  created_at timestamptz not null default now(),
  unique (user_id, page_id)
);

alter table public.bookmarks enable row level security;
create policy bookmarks_owner_all
on public.bookmarks for all
using (auth.uid() = user_id)
with check (auth.uid() = user_id);