Skip to content

Commit 6cb255f

Browse files
authored
Update README.md - 2nd draft
1 parent 646e90b commit 6cb255f

File tree

1 file changed

+19
-17
lines changed
  • schema_design/SchemaExamples/ChatSystem

1 file changed

+19
-17
lines changed

schema_design/SchemaExamples/ChatSystem/README.md

+19-17
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,16 @@ We employ a single table design coupled with a global secondary index (GSI).
1616
The following key structures are used:
1717

1818
- 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"
2529

2630
- Examples:
2731

@@ -32,38 +36,36 @@ The following key structures are used:
3236

3337
- GSI
3438
- Partition key (RoomID)
35-
- c#\<customerId\> - Given customer
39+
- \<RoomID\>
3640
- Sort key (CreatedAt)
37-
- RoomID#\<session UUID\> - Given session of partition key (customer or child session)
41+
- \<timestamp\>
3842

3943
- Examples:
4044

4145
| PK | SK | Sample Attributes |
4246
| ----------- | ----------- | ----------- |
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 |
4648

4749

4850
## Access Patterns
4951

5052
The document covers 9 access patterns. For each access pattern, we provide:
5153
- Usage of Base table or GSI
52-
- Relevant DynamoDB operation (PutItem, GetItem, DeleteItem, Query)
54+
- Relevant DynamoDB operation (PutItem, DeleteItem, Query)
5355
- Partition and Sort key values
5456
- Other conditions or filters
5557

5658
| Access pattern | Base table/GSI | Operation | Partition key value | Sort key value | Other conditions/Filters |
5759
| ----------- | ----------- | ----------- | ----------- | ----------- | ----------- |
5860
| createChatRoom | Base table | PutItem | PK=\<RoomID\> | SK="Meta" | if not exists |
5961
| 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\> | |
6365
| getAllComments | GSI | Query | PK=\<RoomID\> | | Limit 1 |
6466
| 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 | |
6769

6870

6971
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

Comments
 (0)