B
2019.05.09
Amazon Web Services Japan K.K.
Akihiro Tsukada, Startup Solutions Architect, Manager
• # # #
• #
• #
# #
2
• D A
R
• A D
• B
3
9 B A 9 t D S p z O
• 9 B A 9 oml a
•
• 9 B A 9 e dg W O
k s n 9 B 0 1 ci[
• - 1 9 .
9 B A 9 2 1 2 p y
• A 9 ] h [| 9 1 1
• A 1 v PL A 9 rsb] 4
S LP D A B [ OL
W
]
5
AWS Lambda
7
AWS Lambda
Amazon RDSAmazon Aurora
Amazon DynamoDB
Amazon ElastiCache Amazon Neptune
...etc
8
., 9 b
AWS Lambda
., @ a D B R
L ., 5
01 2
Amazon
RDS
Amazon
Aurora
9
a S
AWS Lambda
Amazon
RDS
Amazon
Aurora
D L
b L M 1
1 B 1 d
B R B . .
…
!
10
Private subnet
. B a IbD i
L P DN V R S
E D 2 C I
. L P ICE . C
e Id I
AWS Lambda Amazon
Aurora
Amazon
RDS
VPC
✕
Any Subnet
Elastic network interface
11
Private subnet
.1 0. aBb
RN LI L B L P
L PV 2 B C
.1 0. D d
E
AWS Lambda Amazon
Aurora
Amazon
RDS
VPC
Any Subnet
Elastic network interface
12
DuoB
• n D V S m pt uy
• D ACPS
m g m Oz B D
• elc am -
e U id
Amazon
DynamoDBAWS Lambda
…
!
14
B u eK 1 t m a
• r P
• r
a a B K
S D
• o m
• r A Q P
• 1 P ) (
) 1 ( )( IP
)( + ( +( :
K D a
• + 1 IP )
• i a P
r c
r
• r a
I D
https://docs.aws.amazon.com/ja_jp/amazondynamodb/latest/developerguide/best-practices.html
ao aP
n y m B
16
B o R O
Q • S M O B
tf R Q R
• l e
• tfR Q R B i
n a
• pf o R Q a
L
• L D c
O
E
• R 17
B c
IET • B Ic
• o E t
B t
R
• Re
I t
• m I
• I ED
B aI
• B I
• y
I
• n I
• B
18
D B
19
B c
IET • B Ic
• o E t
B t
R
• Re
I t
• m I
• I ED
B aI
• B I
• y
I
• n I
• B
20
k E
(from re:Invent 2018 session)
•
c
• . 1
i E
• B e d
b R A a
• b d
21
B c
IET • B Ic
• o E t
B t
R
• Re
I t
• m I
• I ED
B aI
• B I
• y
I
• n I
• B
22
F IMKDP R E DI DI I
Use Case
C
C 2 A2 2
#
B
C
A2 2A A2 2A
A2 2A A2 2A
A2 2A 2 A2 2A A.
A2 2A 2 A2 2A
# 2A 2A C
2A 2 C
A2 A2
23
B c
IET • B Ic
• o E t
B t
R
• Re
I t
• m I
• I ED
B aI
• B I
• y
I
• n I
• B
24
.TABLE
Primary Key Attributes
PK SK, GSI-3-PK GSI-1-PK GSI-2-PK
Acr TargetACR AcrInfo1 AcrInfo2 EbookAsin
ABOOKACR1
ABOOKACR1-v0 ABOOK-ASIN1 ABOOK-SKU1
MAP-EBOOKACR1 SyncFileAcr ABOOK-ASIN1
ABOOKACR1#TRACK#1 ABOOK-ASIN1 ABOOK-SKU1
ABOOKACR1#TRACK#2 ABOOK-ASIN1 ABOOK-SKU1
EBOOKACR1 EBOOKACR1 EBOOK-SKU1 ASIN
25
.GSI1
GSI Partition Key Projected Attributes
GSI-1-PK Acr (Primary Table PK) TargetACR (Primary Table SK)
ABOOK-ASIN1 ABOOKACR1
ABOOKACR1-v1
ABOOKACR1#TRACK#1
ABOOKACR1#TRACK#2
SyncFileAcr ABOOKACR1 MAP-EBOOKACR1
EBOOK-SKU1 ABOOKACR1 EBOOKACR1
GSI2
GSI Partition Key Projected Attributes
GSI-2-PK Acr (Primary Table PK) TargetACR (Primary Table SK)
ABOOK-ASIN1 ABOOKACR1 MAP-EBOOKACR1
ABOOK-SKU1 ABOOKACR1
ABOOKACR1-v0
ABOOKACR1#TRACK#1
ABOOKACR1#TRACK#2
GSI3
GSI Partition Key Projected Attributes
TargetACR (Primary Table SK) Acr (Primary Table PK) TargetACR (Primary Table SK)
ABOOKACR1-v0 ABOOKACR1 ABOOKACR1-v0
MAP-EBOOKACR1 ABOOKACR1 MAP-EBOOKACR1
ABOOKACR1#TRACK#1 ABOOKACR1 ABOOKACR1#TRACK#1
ABOOKACR1#TRACK#2 ABOOKACR1 ABOOKACR1#TRACK#2
EBOOKACR1 EBOOKACR1 EBOOKACR1
26
B c
IET • B Ic
• o E t
B t
R
• Re
I t
• m I
• I ED
B aI
• B I
• y
I
• n I
• B
27
# Entity Use Case Lookup parameters Table / INDEX Key Conditions Filter Conditions
1 CompanionMapping getCompanionMappingsByAsin audiobookAsin/ebookSku GSI2 GSI-2=ABOOK-ASIN1 None
2 CompanionMapping
getCompanionMappingsByEbookAn
dAudiobookContentId
ebookAcr/sku,version,format or
audiobookAcr/asin,version,format
GSI-3 on TargetACR attribute OR
PrimaryKey on Table
GSI-3=MAP-EBOOKACR1 version=v and format=f
3 CompanionMapping getCompanionMappingsFromCache
ebookAcr/sku,version,format or
audiobookAcr/asin,version,format
GSI-3 on TargetACR attribute OR
PrimaryKey on Table
GSI-3=MAP-EBOOKACR1 version=v and format=f
4 CompanionMapping getCompanionMappings
syncfileAcr, ebookAcr?,
audiobookAcr?
GSI1 GSI-1=SyncFileAcr None
5 CompanionMapping getCompanionMappingsAvailable ebookAcr, audiobookAcr Primary Key on Table
Acr=ABOOKACR1 and
TargetACR beginswith "MAP-"
6 AcrInfo getACRInfo acr Primary Key on Table
Acr=ABOOKACR1 and
TargetACR beginswith
"ABOOKACR1-v"
7 AcrInfo getACRs acr / asin,version,format Primary Key on Table Acr=ABOOKACR1 version=v and format=f
8 AcrInfo getACRInfos acr Primary Key on table
Acr=ABOOKACR1 and
TargetACR beginswith "ABOOKACR1"
9 AcrInfo getACRInfosBySKU sku GSI2 GSI-2=ABOOK-SKU1
10 AudioProduct getAudioProductsForACRs acr Primary Key on table
Acr=ABOOKACR1 and TargetACR
beginswith "ABOOKACR1"
11 AudioProduct getAudioProducts sku, version, format GSI2 GSI-2=ABOOK-SKU1 version=v and format=f
12 AudioProduct
deleteAudioProductsMatchingSkuV
ersions
sku, version GSI2 GSI-2=ABOOK-SKU1 version=v
13 AudioProduct getChildAudioProductsForSKU sku GSI2 GSI-2=ABOOK-SKU1
14 Product getProductInfoByAsins asin GSI1 GSI-1=ABOOK-ASIN1
15 Product getParentChildDataByParentAsins asin GSI1 GSI-1=ABOOK-ASIN1
16 AudioFile getAudioFilesForACR acr Primary Key on table
Acr=ABOOKACR1 and
TargetACR beginswith
"ABOOKACR1#"
28
D e m a
IET • mD e m
• I
D E
R
• y a R m yB
m I
• ot I B
• R I
m D c I
• D I
• R I
m B n
• m I
• D I
29
B
D
30
B
B D
31
E
ID:
:
AWS Loft Tokyo:
:
:
ID
2 DynamoDB
AWS Loft
Tokyo
yy/3/4
#DynamoDB
#Serverless
14
AWS Loft
Tokyo
yy/5/9
#Serverless
#Lambda
#Design
33 API Night
AWS Loft
Tokyo
yy/6/23
#WebAPI #JWT
#APIGateway
#Auth #OAuth
#OIDC #Cognito
> >><< <
33
D e m a
IET • mD e m
• I
D E
R
• y a R m yB
m I
• ot I B
• R I
m D c I
• D I
• R I
m B n
• m I
• D I
34
id (PK)
name
venue_id (FK)
date
Events
id (PK)
name
Tags
event_id (PK, FK)
tag_id (PK, FK)
EventTags
id (PK)
name
address
Venues
-- SQL
-- :
SELECT e.id, v.name... FROM Events e
JOIN Venues v ON v.id = e.venue_id
JOIN EventTags et ON et.event_id = e.id
JOIN Tags t ON t.id = et.tag_id
WHERE v.name = :vname AND t.name = :tname
35
2 2 2
Use Case
. . . .
. . . .
. . .
. . . .
# . . .
. .
. .
36
i n t hc et Ql tTABLE
Partition Key Attributes
{EventID} {EventName} {VenueName} {TagName1, ...} {yyyy-mm-dd}
... ... ... ... ...
• . . . .3 GB I S
G D +- 3 . Q G
• +- 3 i n t hc m t
lma t Sr c
• QE +- 3 Q F D vQ D
u +- 3 QE . . . -/ . . S
D
BS y F
38
e b l cTABLE
Primary Key Attributes
Partition Key GSI-1-PK GSI-2-PK GSI-3-PK GSI-4-PK
{EventID} {EventName} {VenueName} {TagName1, ...} {yyyy-mm-dd}
... ... ... ... ...
• / + / . 0- 2 0-. 3.2
G
• S u b le b r a b b
• l o y x
b dn c Q I
39
-
GTABLE
Primary Key Attributes
PK, GSI-1-SK SK GSI-1-PK GSI-2-PK
ID DataType DataValue VenueName VenueAddress
{EventID} EventName {EventName}
{EventID} VenueID {VenueID}
{EventID} Date {yyyy-mm-dd}
{EventID} Tag_{TagName} Tag_{TagName}
{VenueID} VenueInfo {VenueName} {Address}
• S 3
• . I G
• 3 1
41
3 3GSI1
GSI Partition Key Projected Attributes
GSI-1-PK GSI-1-SK (Primary Table SK)
DataValue ID DataType VenueAddress
{EventName} {EventID} EventName
{VenueID} {EventID} Venue
{yyyy-mm-dd} {EventID} Date
Tag_{TagName} {EventID} Tag_{TagName}
GSI2
GSI Partition Key Projected Attributes
GSI-2-PK (Primary Table PK)
VenueName ID VenueAddress
{VenueName} {VenueID} {Address}
• . . 42
TABLE
Primary Key Attributes
PK, GSI-1-SK SK GSI-1-PK GSI-2-PK
ID DataType DataValue VenueName VenueAddress
E123 EventName DynamoDB
E123 VenueID V32
E123 Date yy/3/4
E123 Tag_#DynamoDB Tag_#DynamoDB
E123 Tag_#Serverless Tag_#Serverless
E145 EventName
E145 VenueID V32
E145 Date yy/5/9
E145 Tag_#Serverless Tag_#Serverless
E145 Tag_#Lambda Tag_#Lambda
E145 Tag_#Design Tag_#Design
V32 VenueInfo AWS Loft Tokyo
• . .4
• . 4 2 E
51 4 3
43
TABLE
Primary Key Attributes
PK, GSI-1-SK SK GSI-1-PK GSI-2-PK
ID DataType DataValue VenueName VenueAddress
E123 EventName DynamoDB
E123 VenueID V32
E123 Date yy/3/4
E123 Tag_#DynamoDB Tag_#DynamoDB
E123 Tag_#Serverless Tag_#Serverless
E145 EventName
E145 VenueID V32
E145 Date yy/5/9
E145 Tag_#Serverless Tag_#Serverless
E145 Tag_#Lambda Tag_#Lambda
E145 Tag_#Design Tag_#Design
V32 VenueInfo AWS Loft Tokyo
1 3
Query(ID = :eventId) . 3 : .
Table Query(ID = "E123") 44
TABLE
Primary Key Attributes
PK, GSI-1-SK SK GSI-1-PK GSI-2-PK
ID DataType DataValue VenueName VenueAddress
E123 EventName DynamoDB
E123 VenueID V32
E123 Date yy/3/4
E123 Tag_#DynamoDB Tag_#DynamoDB
E123 Tag_#Serverless Tag_#Serverless
E145 EventName
E145 VenueID V32
E145 Date yy/5/9
E145 Tag_#Serverless Tag_#Serverless
E145 Tag_#Lambda Tag_#Lambda
E145 Tag_#Design Tag_#Design
V32 VenueInfo AWS Loft Tokyo
1 3
Query(DataValue = :tagName) . : .
GSI1.Query(DataValue = "Tag_#Serverless") 45
dcj nlr
Use Case Parameters Table/Index API & Key Conditions
. DI I. DI . DI1- G C G B 4 G 1- ) ( DI1
. DI I. DI . DI2 C 1 4 G - I B ) ( DI2 C
. DI I. DI D 2 C
1
1
4 G D 2 C ) ( D 2 C
4 G - I B ) ( D 1
. DI I. DI - I 1 4 G - I B ) ( I
# . DI I. DI 1 4 G - I B ) (I 2 C
I . DI1- G C G B 4 G 1- ) ( DI1
D I D . DI1-
G C G B
G C G B
I1I C 1- ) ( DI1 D - I F ) D 1-
I1I C 1- ) ( D 1 D - I F ) D 1D=E
• i fe f B 1D bp N Sh gb
m aV TP I1I C I I:?1I C 4 G : D Qbus
• / BI G ,ED I ED GE :I ED . FG ED bot
46
A
• . . . a
. 1 B4
• y 2 D
•
n 3 .
. .
. o
o
• m z
o 3 48
s ztL P
• 9 B A 9 rpo [d
• A 9 h cg ]a
• 9 B A 9 h cg ]a
n 9 B 0 1 l
• - 1 9 .
9 B A 9 2 1 2 s
• A 9 bD ibkm 9 1 1
• A 1 y S OW A 9 v e Dm 49
D GI1 E A S D GI
TABLE
Primary Key Attributes
PK, GSI-1-SK SK GSI-1-PK
ID DataType DataValue1 DataValue2
{EventID} EventName {EventName}
{EventID} VenueInfo {VenueName} {Address}
{EventID} Date {yyyy-mm-dd}
{EventID} Tag_{TagName} Tag_{TagName}
•
. - D
52
-1 .TABLE
Primary Key Attributes
PK, GSI-1-SK SK GSI-1-PK
ID DataType DataValue1 DataValue2
E123 EventName DynamoDB
E123 VenueInfo AWS Loft Tokyo
E123 Date yy/3/4
E123 Tag_#DynamoDB Tag_#DynamoDB
E123 Tag_#Serverless Tag_#Serverless
E145 EventName
E145 VenueID AWS Loft Tokyo
E145 Date yy/5/9
E145 Tag_#Serverless Tag_#Serverless
E145 Tag_#Lambda Tag_#Lambda
E145 Tag_#Design Tag_#Design
53
1 -. 1 -.GSI1
GSI Partition Key Projected Attributes
GSI-1-PK GSI-1-SK (Primary Table SK)
DataValue ID DataValue1 DataValue2
{EventName} {EventID} EventName
{VenueID} {EventID} Venue
{yyyy-mm-dd} {EventID} Date
Tag_{TagName} {EventID} Tag_{TagName}
{VenueName} {EventID} {VenueName} {Address}
54
(BB =I _iurmv
Use Case Parameters Table/Index API & Key Conditions
G ED E G E) G E. C= C 1 C . G E.
G ED E G ED) G E/ - . 1 C E G E/
G ED E G ED) / - . 1 C E G /
G ED E G ED) E - . 1 C E E
# G ED E G ED) - . 1 C E E /
D E D) G E. C= C
1 C
. G E. E B = D =E
E ) G E. C= C
- E.E
. G E E B . :A
• T o w h a i e nr V
• tl fd y xP CAD A D y Q NpS sg b 55
2 U m E SVg I d
1 -
1 - .
d nm
A- . B
d , .
e
x um
• V I E EU G E U
• G 2 d I
a S a m d
• i s
• A my t e VB
• ir v p NS S G E
56
- 2.
TABLE
Primary Key Attributes
PK SK, GSI-1-PK GSI-1-SK
EventID DataType DataValue
{EventID} EventName {EventName}
{EventID} VenueName {VenueName}
{EventID} VenueAddress {VenueAddress}
{EventID} Date {yyyy-mm-dd}
{EventID} Tag_{n} {TagName}
58
2 - .
TABLE
Primary Key Attributes
PK SK, GSI-1-PK GSI-1-SK
EventID DataType DataValue
E123 EventName DynamoDB
E123 VenueName AWS Loft Tokyo
E123 VenueAddress
E123 Date yy/3/4
E123 Tag_1 #DynamoDB
E123 Tag_2 #Serverless
E145 EventName
E145 VenueName AWS Loft Tokyo
E145 VenueAddress
E145 Date yy/5/9
E145 Tag_1 #Serverless
E145 Tag_2 #Lambda
E145 Tag_3 #Design
59
2 . -GSI1
GSI Partition Key Projected Attributes
GSI-1-PK GSI-1-SK (Primary Table SK)
DataType DataValue EventID
EventName {EventName} {EventID}
VenueName {VenueName} {EventID}
VenueAddress {VenueAddress} {EventID}
Date {yyyy-mm-dd} {EventID}
Tag_{n} {TagName} {EventID}
60
:: TS
Use Case Parameters Table/Index Key Conditions
= = = A = - 1 A 12 = =
= = = A = 1 .
1=1 A: = 1
= 1 = 1
= = = A 1 .
1=1 A: 1
1 1
# = = = A 1= .
1=1 A: 1=
1= 1=
= = = A 1
4825
6
57 3 1
1 = 1 A 1 1
1 = 1 A =
= A =
• P = = A 1 I N P BDaG V E
61
. - N . . N PB
GSI1
GSI Partition Key Projected Attributes
GSI-1-PK GSI-1-SK (Primary Table SK)
DataType DataValue EventID
EventName {EventName} {EventID}
VenueName {VenueName} {EventID}
VenueAddress {VenueAddress} {EventID}
Date {yyyy-mm-dd} {EventID}
Tag_{n} {TagName} {EventID}
• 2. BS . b KT
Query(DataType = begins_with("Tag_") and DataValue = :tagName)
. _ . B AN
• Query(DataType = Tag_{n} and DataValue = :tagName)
dBS Pe TE
. a N
62

【旧版・説明欄参照ください】 サーバーレスアプリケーション向きの DB 設計ベストプラクティス

  • 1.
    B 2019.05.09 Amazon Web ServicesJapan K.K. Akihiro Tsukada, Startup Solutions Architect, Manager
  • 2.
    • # ## • # • # # # 2
  • 3.
    • D A R •A D • B 3
  • 4.
    9 B A9 t D S p z O • 9 B A 9 oml a • • 9 B A 9 e dg W O k s n 9 B 0 1 ci[ • - 1 9 . 9 B A 9 2 1 2 p y • A 9 ] h [| 9 1 1 • A 1 v PL A 9 rsb] 4
  • 5.
    S LP DA B [ OL W ] 5
  • 7.
  • 8.
    AWS Lambda Amazon RDSAmazonAurora Amazon DynamoDB Amazon ElastiCache Amazon Neptune ...etc 8
  • 9.
    ., 9 b AWSLambda ., @ a D B R L ., 5 01 2 Amazon RDS Amazon Aurora 9
  • 10.
    a S AWS Lambda Amazon RDS Amazon Aurora DL b L M 1 1 B 1 d B R B . . … ! 10
  • 11.
    Private subnet . Ba IbD i L P DN V R S E D 2 C I . L P ICE . C e Id I AWS Lambda Amazon Aurora Amazon RDS VPC ✕ Any Subnet Elastic network interface 11
  • 12.
    Private subnet .1 0.aBb RN LI L B L P L PV 2 B C .1 0. D d E AWS Lambda Amazon Aurora Amazon RDS VPC Any Subnet Elastic network interface 12
  • 14.
    DuoB • n DV S m pt uy • D ACPS m g m Oz B D • elc am - e U id Amazon DynamoDBAWS Lambda … ! 14
  • 16.
    B u eK1 t m a • r P • r a a B K S D • o m • r A Q P • 1 P ) ( ) 1 ( )( IP )( + ( +( : K D a • + 1 IP ) • i a P r c r • r a I D https://docs.aws.amazon.com/ja_jp/amazondynamodb/latest/developerguide/best-practices.html ao aP n y m B 16
  • 17.
    B o RO Q • S M O B tf R Q R • l e • tfR Q R B i n a • pf o R Q a L • L D c O E • R 17
  • 18.
    B c IET •B Ic • o E t B t R • Re I t • m I • I ED B aI • B I • y I • n I • B 18
  • 19.
  • 20.
    B c IET •B Ic • o E t B t R • Re I t • m I • I ED B aI • B I • y I • n I • B 20
  • 21.
    k E (from re:Invent2018 session) • c • . 1 i E • B e d b R A a • b d 21
  • 22.
    B c IET •B Ic • o E t B t R • Re I t • m I • I ED B aI • B I • y I • n I • B 22
  • 23.
    F IMKDP RE DI DI I Use Case C C 2 A2 2 # B C A2 2A A2 2A A2 2A A2 2A A2 2A 2 A2 2A A. A2 2A 2 A2 2A # 2A 2A C 2A 2 C A2 A2 23
  • 24.
    B c IET •B Ic • o E t B t R • Re I t • m I • I ED B aI • B I • y I • n I • B 24
  • 25.
    .TABLE Primary Key Attributes PKSK, GSI-3-PK GSI-1-PK GSI-2-PK Acr TargetACR AcrInfo1 AcrInfo2 EbookAsin ABOOKACR1 ABOOKACR1-v0 ABOOK-ASIN1 ABOOK-SKU1 MAP-EBOOKACR1 SyncFileAcr ABOOK-ASIN1 ABOOKACR1#TRACK#1 ABOOK-ASIN1 ABOOK-SKU1 ABOOKACR1#TRACK#2 ABOOK-ASIN1 ABOOK-SKU1 EBOOKACR1 EBOOKACR1 EBOOK-SKU1 ASIN 25
  • 26.
    .GSI1 GSI Partition KeyProjected Attributes GSI-1-PK Acr (Primary Table PK) TargetACR (Primary Table SK) ABOOK-ASIN1 ABOOKACR1 ABOOKACR1-v1 ABOOKACR1#TRACK#1 ABOOKACR1#TRACK#2 SyncFileAcr ABOOKACR1 MAP-EBOOKACR1 EBOOK-SKU1 ABOOKACR1 EBOOKACR1 GSI2 GSI Partition Key Projected Attributes GSI-2-PK Acr (Primary Table PK) TargetACR (Primary Table SK) ABOOK-ASIN1 ABOOKACR1 MAP-EBOOKACR1 ABOOK-SKU1 ABOOKACR1 ABOOKACR1-v0 ABOOKACR1#TRACK#1 ABOOKACR1#TRACK#2 GSI3 GSI Partition Key Projected Attributes TargetACR (Primary Table SK) Acr (Primary Table PK) TargetACR (Primary Table SK) ABOOKACR1-v0 ABOOKACR1 ABOOKACR1-v0 MAP-EBOOKACR1 ABOOKACR1 MAP-EBOOKACR1 ABOOKACR1#TRACK#1 ABOOKACR1 ABOOKACR1#TRACK#1 ABOOKACR1#TRACK#2 ABOOKACR1 ABOOKACR1#TRACK#2 EBOOKACR1 EBOOKACR1 EBOOKACR1 26
  • 27.
    B c IET •B Ic • o E t B t R • Re I t • m I • I ED B aI • B I • y I • n I • B 27
  • 28.
    # Entity UseCase Lookup parameters Table / INDEX Key Conditions Filter Conditions 1 CompanionMapping getCompanionMappingsByAsin audiobookAsin/ebookSku GSI2 GSI-2=ABOOK-ASIN1 None 2 CompanionMapping getCompanionMappingsByEbookAn dAudiobookContentId ebookAcr/sku,version,format or audiobookAcr/asin,version,format GSI-3 on TargetACR attribute OR PrimaryKey on Table GSI-3=MAP-EBOOKACR1 version=v and format=f 3 CompanionMapping getCompanionMappingsFromCache ebookAcr/sku,version,format or audiobookAcr/asin,version,format GSI-3 on TargetACR attribute OR PrimaryKey on Table GSI-3=MAP-EBOOKACR1 version=v and format=f 4 CompanionMapping getCompanionMappings syncfileAcr, ebookAcr?, audiobookAcr? GSI1 GSI-1=SyncFileAcr None 5 CompanionMapping getCompanionMappingsAvailable ebookAcr, audiobookAcr Primary Key on Table Acr=ABOOKACR1 and TargetACR beginswith "MAP-" 6 AcrInfo getACRInfo acr Primary Key on Table Acr=ABOOKACR1 and TargetACR beginswith "ABOOKACR1-v" 7 AcrInfo getACRs acr / asin,version,format Primary Key on Table Acr=ABOOKACR1 version=v and format=f 8 AcrInfo getACRInfos acr Primary Key on table Acr=ABOOKACR1 and TargetACR beginswith "ABOOKACR1" 9 AcrInfo getACRInfosBySKU sku GSI2 GSI-2=ABOOK-SKU1 10 AudioProduct getAudioProductsForACRs acr Primary Key on table Acr=ABOOKACR1 and TargetACR beginswith "ABOOKACR1" 11 AudioProduct getAudioProducts sku, version, format GSI2 GSI-2=ABOOK-SKU1 version=v and format=f 12 AudioProduct deleteAudioProductsMatchingSkuV ersions sku, version GSI2 GSI-2=ABOOK-SKU1 version=v 13 AudioProduct getChildAudioProductsForSKU sku GSI2 GSI-2=ABOOK-SKU1 14 Product getProductInfoByAsins asin GSI1 GSI-1=ABOOK-ASIN1 15 Product getParentChildDataByParentAsins asin GSI1 GSI-1=ABOOK-ASIN1 16 AudioFile getAudioFilesForACR acr Primary Key on table Acr=ABOOKACR1 and TargetACR beginswith "ABOOKACR1#" 28
  • 29.
    D e ma IET • mD e m • I D E R • y a R m yB m I • ot I B • R I m D c I • D I • R I m B n • m I • D I 29
  • 30.
  • 31.
  • 33.
    E ID: : AWS Loft Tokyo: : : ID 2DynamoDB AWS Loft Tokyo yy/3/4 #DynamoDB #Serverless 14 AWS Loft Tokyo yy/5/9 #Serverless #Lambda #Design 33 API Night AWS Loft Tokyo yy/6/23 #WebAPI #JWT #APIGateway #Auth #OAuth #OIDC #Cognito > >><< < 33
  • 34.
    D e ma IET • mD e m • I D E R • y a R m yB m I • ot I B • R I m D c I • D I • R I m B n • m I • D I 34
  • 35.
    id (PK) name venue_id (FK) date Events id(PK) name Tags event_id (PK, FK) tag_id (PK, FK) EventTags id (PK) name address Venues -- SQL -- : SELECT e.id, v.name... FROM Events e JOIN Venues v ON v.id = e.venue_id JOIN EventTags et ON et.event_id = e.id JOIN Tags t ON t.id = et.tag_id WHERE v.name = :vname AND t.name = :tname 35
  • 36.
    2 2 2 UseCase . . . . . . . . . . . . . . . # . . . . . . . 36
  • 38.
    i n thc et Ql tTABLE Partition Key Attributes {EventID} {EventName} {VenueName} {TagName1, ...} {yyyy-mm-dd} ... ... ... ... ... • . . . .3 GB I S G D +- 3 . Q G • +- 3 i n t hc m t lma t Sr c • QE +- 3 Q F D vQ D u +- 3 QE . . . -/ . . S D BS y F 38
  • 39.
    e b lcTABLE Primary Key Attributes Partition Key GSI-1-PK GSI-2-PK GSI-3-PK GSI-4-PK {EventID} {EventName} {VenueName} {TagName1, ...} {yyyy-mm-dd} ... ... ... ... ... • / + / . 0- 2 0-. 3.2 G • S u b le b r a b b • l o y x b dn c Q I 39
  • 40.
  • 41.
    GTABLE Primary Key Attributes PK,GSI-1-SK SK GSI-1-PK GSI-2-PK ID DataType DataValue VenueName VenueAddress {EventID} EventName {EventName} {EventID} VenueID {VenueID} {EventID} Date {yyyy-mm-dd} {EventID} Tag_{TagName} Tag_{TagName} {VenueID} VenueInfo {VenueName} {Address} • S 3 • . I G • 3 1 41
  • 42.
    3 3GSI1 GSI PartitionKey Projected Attributes GSI-1-PK GSI-1-SK (Primary Table SK) DataValue ID DataType VenueAddress {EventName} {EventID} EventName {VenueID} {EventID} Venue {yyyy-mm-dd} {EventID} Date Tag_{TagName} {EventID} Tag_{TagName} GSI2 GSI Partition Key Projected Attributes GSI-2-PK (Primary Table PK) VenueName ID VenueAddress {VenueName} {VenueID} {Address} • . . 42
  • 43.
    TABLE Primary Key Attributes PK,GSI-1-SK SK GSI-1-PK GSI-2-PK ID DataType DataValue VenueName VenueAddress E123 EventName DynamoDB E123 VenueID V32 E123 Date yy/3/4 E123 Tag_#DynamoDB Tag_#DynamoDB E123 Tag_#Serverless Tag_#Serverless E145 EventName E145 VenueID V32 E145 Date yy/5/9 E145 Tag_#Serverless Tag_#Serverless E145 Tag_#Lambda Tag_#Lambda E145 Tag_#Design Tag_#Design V32 VenueInfo AWS Loft Tokyo • . .4 • . 4 2 E 51 4 3 43
  • 44.
    TABLE Primary Key Attributes PK,GSI-1-SK SK GSI-1-PK GSI-2-PK ID DataType DataValue VenueName VenueAddress E123 EventName DynamoDB E123 VenueID V32 E123 Date yy/3/4 E123 Tag_#DynamoDB Tag_#DynamoDB E123 Tag_#Serverless Tag_#Serverless E145 EventName E145 VenueID V32 E145 Date yy/5/9 E145 Tag_#Serverless Tag_#Serverless E145 Tag_#Lambda Tag_#Lambda E145 Tag_#Design Tag_#Design V32 VenueInfo AWS Loft Tokyo 1 3 Query(ID = :eventId) . 3 : . Table Query(ID = "E123") 44
  • 45.
    TABLE Primary Key Attributes PK,GSI-1-SK SK GSI-1-PK GSI-2-PK ID DataType DataValue VenueName VenueAddress E123 EventName DynamoDB E123 VenueID V32 E123 Date yy/3/4 E123 Tag_#DynamoDB Tag_#DynamoDB E123 Tag_#Serverless Tag_#Serverless E145 EventName E145 VenueID V32 E145 Date yy/5/9 E145 Tag_#Serverless Tag_#Serverless E145 Tag_#Lambda Tag_#Lambda E145 Tag_#Design Tag_#Design V32 VenueInfo AWS Loft Tokyo 1 3 Query(DataValue = :tagName) . : . GSI1.Query(DataValue = "Tag_#Serverless") 45
  • 46.
    dcj nlr Use CaseParameters Table/Index API & Key Conditions . DI I. DI . DI1- G C G B 4 G 1- ) ( DI1 . DI I. DI . DI2 C 1 4 G - I B ) ( DI2 C . DI I. DI D 2 C 1 1 4 G D 2 C ) ( D 2 C 4 G - I B ) ( D 1 . DI I. DI - I 1 4 G - I B ) ( I # . DI I. DI 1 4 G - I B ) (I 2 C I . DI1- G C G B 4 G 1- ) ( DI1 D I D . DI1- G C G B G C G B I1I C 1- ) ( DI1 D - I F ) D 1- I1I C 1- ) ( D 1 D - I F ) D 1D=E • i fe f B 1D bp N Sh gb m aV TP I1I C I I:?1I C 4 G : D Qbus • / BI G ,ED I ED GE :I ED . FG ED bot 46
  • 48.
    A • . .. a . 1 B4 • y 2 D • n 3 . . . . o o • m z o 3 48
  • 49.
    s ztL P •9 B A 9 rpo [d • A 9 h cg ]a • 9 B A 9 h cg ]a n 9 B 0 1 l • - 1 9 . 9 B A 9 2 1 2 s • A 9 bD ibkm 9 1 1 • A 1 y S OW A 9 v e Dm 49
  • 52.
    D GI1 EA S D GI TABLE Primary Key Attributes PK, GSI-1-SK SK GSI-1-PK ID DataType DataValue1 DataValue2 {EventID} EventName {EventName} {EventID} VenueInfo {VenueName} {Address} {EventID} Date {yyyy-mm-dd} {EventID} Tag_{TagName} Tag_{TagName} • . - D 52
  • 53.
    -1 .TABLE Primary KeyAttributes PK, GSI-1-SK SK GSI-1-PK ID DataType DataValue1 DataValue2 E123 EventName DynamoDB E123 VenueInfo AWS Loft Tokyo E123 Date yy/3/4 E123 Tag_#DynamoDB Tag_#DynamoDB E123 Tag_#Serverless Tag_#Serverless E145 EventName E145 VenueID AWS Loft Tokyo E145 Date yy/5/9 E145 Tag_#Serverless Tag_#Serverless E145 Tag_#Lambda Tag_#Lambda E145 Tag_#Design Tag_#Design 53
  • 54.
    1 -. 1-.GSI1 GSI Partition Key Projected Attributes GSI-1-PK GSI-1-SK (Primary Table SK) DataValue ID DataValue1 DataValue2 {EventName} {EventID} EventName {VenueID} {EventID} Venue {yyyy-mm-dd} {EventID} Date Tag_{TagName} {EventID} Tag_{TagName} {VenueName} {EventID} {VenueName} {Address} 54
  • 55.
    (BB =I _iurmv UseCase Parameters Table/Index API & Key Conditions G ED E G E) G E. C= C 1 C . G E. G ED E G ED) G E/ - . 1 C E G E/ G ED E G ED) / - . 1 C E G / G ED E G ED) E - . 1 C E E # G ED E G ED) - . 1 C E E / D E D) G E. C= C 1 C . G E. E B = D =E E ) G E. C= C - E.E . G E E B . :A • T o w h a i e nr V • tl fd y xP CAD A D y Q NpS sg b 55
  • 56.
    2 U mE SVg I d 1 - 1 - . d nm A- . B d , . e x um • V I E EU G E U • G 2 d I a S a m d • i s • A my t e VB • ir v p NS S G E 56
  • 58.
    - 2. TABLE Primary KeyAttributes PK SK, GSI-1-PK GSI-1-SK EventID DataType DataValue {EventID} EventName {EventName} {EventID} VenueName {VenueName} {EventID} VenueAddress {VenueAddress} {EventID} Date {yyyy-mm-dd} {EventID} Tag_{n} {TagName} 58
  • 59.
    2 - . TABLE PrimaryKey Attributes PK SK, GSI-1-PK GSI-1-SK EventID DataType DataValue E123 EventName DynamoDB E123 VenueName AWS Loft Tokyo E123 VenueAddress E123 Date yy/3/4 E123 Tag_1 #DynamoDB E123 Tag_2 #Serverless E145 EventName E145 VenueName AWS Loft Tokyo E145 VenueAddress E145 Date yy/5/9 E145 Tag_1 #Serverless E145 Tag_2 #Lambda E145 Tag_3 #Design 59
  • 60.
    2 . -GSI1 GSIPartition Key Projected Attributes GSI-1-PK GSI-1-SK (Primary Table SK) DataType DataValue EventID EventName {EventName} {EventID} VenueName {VenueName} {EventID} VenueAddress {VenueAddress} {EventID} Date {yyyy-mm-dd} {EventID} Tag_{n} {TagName} {EventID} 60
  • 61.
    :: TS Use CaseParameters Table/Index Key Conditions = = = A = - 1 A 12 = = = = = A = 1 . 1=1 A: = 1 = 1 = 1 = = = A 1 . 1=1 A: 1 1 1 # = = = A 1= . 1=1 A: 1= 1= 1= = = = A 1 4825 6 57 3 1 1 = 1 A 1 1 1 = 1 A = = A = • P = = A 1 I N P BDaG V E 61
  • 62.
    . - N. . N PB GSI1 GSI Partition Key Projected Attributes GSI-1-PK GSI-1-SK (Primary Table SK) DataType DataValue EventID EventName {EventName} {EventID} VenueName {VenueName} {EventID} VenueAddress {VenueAddress} {EventID} Date {yyyy-mm-dd} {EventID} Tag_{n} {TagName} {EventID} • 2. BS . b KT Query(DataType = begins_with("Tag_") and DataValue = :tagName) . _ . B AN • Query(DataType = Tag_{n} and DataValue = :tagName) dBS Pe TE . a N 62