Skip to content

Latest commit

 

History

History
68 lines (53 loc) · 2.32 KB

db.md

File metadata and controls

68 lines (53 loc) · 2.32 KB

DB Design

Access Pattern

  1. fetchActiveLessonRoomByUid
    1. LINE ユーザーからのリクエストに含まれる UID から、進行中のレッスンルーム ID を 1 件取得する
  2. putLessonRoom
    1. 新しいレッスンルームを 1 件作成する
  3. fetchConversationsByLessonRoomId
    1. レッスンルーム ID をもとに会話履歴を全件取得する
    2. ソート順は、送信日の降順 1 . putLessonRoom
    3. レッスンルーム ID をもとにレッスンルームを「終了」に変更する

ER Diagrams

erDiagram
  user {
    string uid PK
  }

  lesson_room {
    uuid room_id PK "検索条件"
    string uid FK "検索条件"
    string status
    timestamp created_at
  }
  conversation {
    uuid room_id "検索条件"
    timestamp sent_at "ソート条件"
    string speaker "検索条件"
    string message
  }

  user ||--}o lesson_room: "attend multiple lessons"

  lesson_room ||--o{ conversation: "have conversations"
Loading

DynamoDB Schema

SmallGPTalk Table

PrimaryKey Attributes
Record Type PK SK
lesson_room
(type)
room_id
[LESSON#uuid]
uid
[USER#string]
status
[string]
created_at
[number]
lesson_room
(example)
LESSON#fdba3e0a-9a... USER#4fab7256-ac.. IN_PROGGRESS 1677885697470
conversation
(type)
room_id
[LESSON#uuid]
sent_at
[SENT_AT#number]
sender
[string]
message
[string]
conversation
(example)
LESSON#fdba3e0a-9a... SENT_AT#1677885697470
user Hello!!!

Indecies

Primary Key

Keys Attribute Name
Partition Key PK
Sort Key SK

GSI1

For the fetchLessonRoomByUid usecase.

Keys Attribute Name
Partition Key SK
(USERS#{string})
Sort Key created_at