@@ -16,12 +16,16 @@ We employ a single table design coupled with a global secondary index (GSI).
16
16
The following key structures are used:
17
17
18
18
- Base table
19
- - Partition key (PK)
20
- - User:\< userID\> - Given User
21
- - Room:\< roomID\> - Given Room
22
- - Sort key (SK)
23
- - <\timestamp\> -
24
- - "meta" -
19
+ - For a user item:
20
+ - Partition key (PK)
21
+ - User:\< UserID\>
22
+ - Sort key (SK)
23
+ - \< timestamp\>
24
+ - For a room item:
25
+ - Partition key (PK)
26
+ - Room:\< RoomID\>
27
+ - Sort key (SK)
28
+ - "meta"
25
29
26
30
- Examples:
27
31
@@ -32,38 +36,36 @@ The following key structures are used:
32
36
33
37
- GSI
34
38
- Partition key (RoomID)
35
- - c# \< customerId \> - Given customer
39
+ - \< RoomID \>
36
40
- Sort key (CreatedAt)
37
- - RoomID# \< session UUID \> - Given session of partition key (customer or child session)
41
+ - \< timestamp \>
38
42
39
43
- Examples:
40
44
41
45
| PK | SK | Sample Attributes |
42
46
| ----------- | ----------- | ----------- |
43
- | child#suuid#ert54fbgn | suuid#c342etj3 | access _ token, session_state |
44
- | child#suuid#kljhfyf23 | suuid#c342etj3 | access _ token, session_state |
45
- | c#ABC | suuid#c342etj3 | last_login_time, access_token, session_state |
47
+ | Music | 2023-04-01T12:00:00.001Z | PK, SK, Comment |
46
48
47
49
48
50
## Access Patterns
49
51
50
52
The document covers 9 access patterns. For each access pattern, we provide:
51
53
- Usage of Base table or GSI
52
- - Relevant DynamoDB operation (PutItem, GetItem, DeleteItem, Query)
54
+ - Relevant DynamoDB operation (PutItem, DeleteItem, Query)
53
55
- Partition and Sort key values
54
56
- Other conditions or filters
55
57
56
58
| Access pattern | Base table/GSI | Operation | Partition key value | Sort key value | Other conditions/Filters |
57
59
| ----------- | ----------- | ----------- | ----------- | ----------- | ----------- |
58
60
| createChatRoom | Base table | PutItem | PK=\< RoomID\> | SK="Meta" | if not exists |
59
61
| deleteChatRoom | Base table | DeleteItem | PK=\< RoomID\> | SK="Meta" | createdBy=UserID |
60
- | joinChatRoom | Base table | PutItem | PK=\< UserID\> | SK="Join" + RoomID | |
61
- | leaveChatRoom | Base table | DeleteItem | PK=\< UserID\> | SK="Join" + RoomID | |
62
- | addComments | Base table | PutItem | PK=\< UserID\> | SK=timestammp | |
62
+ | joinChatRoom | Base table | PutItem | PK=\< UserID\> | SK="Join"\< roomID \> | |
63
+ | leaveChatRoom | Base table | DeleteItem | PK=\< UserID\> | SK="Join"\< roomID \> | |
64
+ | addComments | Base table | PutItem | PK=\< UserID\> | SK=\< timestamp \> | |
63
65
| getAllComments | GSI | Query | PK=\< RoomID\> | | Limit 1 |
64
66
| getLatestComments | GSI | Query | PK=\< RoomID\> | | Limit 10 & ScanIndexForward = false |
65
- | getFromLatestToSpecifiedPositionComments | GSI | Query | PK=\< RoomID \> | SK > FromPosition | |
66
- | getFromPositionToPositionComments | GSI | Query | PK=\< RoomID \> | SK between FromPosition and ToPosition | |
67
+ | getFromLatestToSpecifiedPositionComments | GSI | Query | PK=\< roomID \> | SK > FromPosition | |
68
+ | getFromPositionToPositionComments | GSI | Query | PK=\< roomID \> | SK between FromPosition and ToPosition | |
67
69
68
70
69
71
Please note: We add “Limit 1” for getLastLoginTimeByCustomerId since GSIs can have duplicate values. GSIs do not enforce uniqueness on key attribute values like the base table does.
0 commit comments