Database Schema
Database Schema
Section titled “Database Schema”This reference reflects workers/bookmarks-api-worker/migrations.
Tables and keys
Section titled “Tables and keys”| Table | Primary Key | Foreign Keys |
|---|---|---|
users | id | None |
clubs | id | created_by -> users.id |
memberships | (club_id, user_id) | club_id -> clubs.id, user_id -> users.id |
club_books | id | club_id -> clubs.id, created_by -> users.id |
club_book_categories | id | book_id -> club_books.id |
note_sections | id | club_id -> clubs.id, book_id -> club_books.id, created_by -> users.id |
notes | id | club_id -> clubs.id, author_id -> users.id, book_id -> club_books.id, category_id -> club_book_categories.id, section_id -> note_sections.id |
comments | id | note_id -> notes.id, author_id -> users.id |
reactions | (note_id, user_id, emoji) | note_id -> notes.id, user_id -> users.id |
note_assets | id | note_id -> notes.id, created_by -> users.id |
club_meetings | id | club_id -> clubs.id, book_id -> club_books.id, created_by -> users.id, canceled_by -> users.id |
meeting_rsvps | (meeting_id, user_id) | meeting_id -> club_meetings.id, user_id -> users.id |
meeting_comments | id | meeting_id -> club_meetings.id, author_id -> users.id |
book_ratings | (book_id, user_id) | book_id -> club_books.id, user_id -> users.id |
Important constraints
Section titled “Important constraints”memberships.rolein (admin,member)meeting_rsvps.statusin (yes,maybe,no)notes.categoryin (chapter,character,event)notes.spoiler_levelandcomments.spoiler_levelin (none,mild,major)book_ratings.ratingbetween1and5club_books.bookmark_ratingbetween0and5club_books.chapter_countbetween1and500note_sectionsenforces chapter-number presence for chapter sections only
Important indexes
Section titled “Important indexes”idx_memberships_user_ididx_club_books_club_ididx_club_book_categories_book_ididx_note_sections_club_bookidx_notes_club_created,idx_notes_book_id,idx_notes_section_ididx_comments_note_id,idx_comments_parent_comment_ididx_reactions_note_ididx_club_meetings_club_scheduled,idx_club_meetings_club_book_scheduledidx_meeting_rsvps_meeting_ididx_meeting_comments_meeting_ididx_book_ratings_book_id,idx_book_ratings_user_id
comments.parent_comment_idexists but is not currently declared as an FK.- Legacy
clubs.book_titleis retained for compatibility whileclub_booksis the active model.