AWS DynamoDB基本用法

 

本文来源:

https://amazon.qwiklabs.com/focuses/10407?catalog_rank=%7B%22rank%22%3A1%2C%22num_filters%22%3A1%2C%22has_search%22%3Atrue%7D&parent=catalog&search_id=6896631

 

 

 

Task1:创建新表

创建新表,命名为Music;主键 Artist,String;选择 Add sort key,在新字段中填写Song(String)

 

Task2:添加数据

一个表是多个特殊topic的集合。

每个表包含多个items。一个item是属性集合,它在其它item中唯一。

每个item由一个或多个attributes组成。一个attribute是一个基础数据element。

举例:Music表中的一个item,包含了Song和Artist等attributes。

当你向DynamoDB表中写一个item时,只需要Primary Key和Sort Key。

 

在Item Tab点击Create item。

Artist String:Pink Floyd

Song String:Money

要创建额外的attribute,点击Song前的加号,点Append。

选String,新增一个attribute,FIELD中输入Album,VALUE中输入The Dark Side of the Moon。

Album前新增attribute,选Number,FIELD中输入Year,VALUE中输入1973。

 

另外创建一个Item,

Attribute NameAttribute TypeAttribute Value
ArtistStringJohn Lennon
SongStringImagine
AlbumStringImagine
YearNumber1971
GenreStringSoft rock

该表新增了一个attribute,Genre。

 

再创建一个Item。

Attribute NameAttribute TypeAttribute Value
ArtistStringPsy
SongStringGangnam Style
AlbumStringPsy 6 (Six Rules), Part 1
YearNumber2011
LengthSecondsNumber219

 

LengthSeconds用于标记song的长度。

 

也可以使用AWS Data Pipeline来为DynamoDB导入数据。

 

Task3:修改现有的Item

点击Psy,改变日期从2011到2012,保存。

 

Task4:查询表

两种方法:Query和Scan。

query操作给予Primary Key和可选的Sort Key查找Items,它是fully indexed,因此非常快。

 

点击下拉列表Scan(再Create item按钮下面)更改其为Query。

输入Partition key:Psy;Sort key:Gangnam Style。点击开始查询

 

在下拉列表中更改为Scan,添加加号,输入Enter atribute:Year

String改为Number,Enter value:1971,点击start search。

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值