| « PreviousNext » | |
![]() ![]() ![]() | Did this page help you? Yes | No | Tell us about it... |
The Amazon DynamoDB Developer Guide uses the following sample tables to illustrate working with tables, items and the query operations. The following table lists tables, their primary key attributes and their types.
| Table Name | Primary Key Type | Hash Attribute Name and Type | Range Attribute Name and Type |
|---|---|---|---|
| ProductCatalog (Id, ... ) | Hash |
Attribute Name: Id Type: Number | - |
| Forum ( Name, ... ) | Hash |
Attribute Name: Name Type: String | - |
| Thread (ForumName, Subject, ... ) | Hash and Range |
Attribute Name: ForumName Type: String |
Attribute Name: Subject Type: String |
| Reply ( Id, ReplyDateTime, ... ) | Hash and Range |
Attribute Name: Id Type: String |
Attribute Name: ReplyDateTime Type: String |
The Reply table has the following local secondary index:
| Index Name | Attribute to Index | Projected Attributes |
|---|---|---|
| PostedByIndex | PostedBy | Table and Index Keys |
The ProductCatalog table represents a table in which each product item is uniquely identified by an Id. Because each table is like a property bag, you can store all kinds of products in this table. For illustration, we store book and bicycle items. In an Amazon DynamoDB table, an attribute can be multivalued. For example, a book can have multiple authors. All the book items stored have an Authors attribute that stores one or more author names and the bicycle items have a Color multivalued attribute for the available colors.
The Forum, Thread, and Reply tables are modeled after the AWS forums. Each AWS service maintains one or more forums. Customers start a thread by posting a message that has a unique subject. Each thread might receive one or more replies at different times. These replies are stored in the Reply table. For more information, see AWS Forums.
Amazon DynamoDB does not support table joins. Additionally, when accessing data, queries are the most efficient and table scans should be avoided because of performance issues. These should be taken into consideration when you design your table schemas. For example, you might want to join the Reply and Thread tables. The Reply table Id attribute is set up as a concatenation of the forum name and subject values with a "#" in between to enable efficient queries. If you have a reply item, you can parse the Id to find forum name and thread subject. You can then use these values to query the Forum or the Thread table as you need.
For more information about the Amazon DynamoDB data model, see Amazon DynamoDB Data Model .
The following table shows the sample data that the code example in the getting started section uploads to the ProductCatalog table. For more information, see Step 3: Load Data into Tables.
| Id (Primary Key) | Other Attributes | |
|---|---|---|
| 101 |
{
Title = "Book 101 Title"
ISBN = "111-1111111111"
Authors = "Author 1"
Price = -2
Dimensions = "8.5 x 11.0 x 0.5"
PageCount = 500
InPublication = 1
ProductCategory = "Book"
}
| |
| 102 |
{
Title = "Book 102 Title"
ISBN = "222-2222222222"
Authors = [ "Author 1", "Author 2" ]
Price = 20
Dimensions = "8.5 x 11.0 x 0.8"
PageCount = 600
InPublication = 1
ProductCategory = "Book"
}
| |
| 103 |
{
Title = "Book 103 Title"
ISBN = "333-3333333333"
Authors = [ "Author 1", "Author2", "Author 3" ]
Price = 200
Dimensions = "8.5 x 11.0 x 1.5"
PageCount = 700 InPublication = 0
ProductCategory = "Book"
}
| |
| 201 |
{
Title = "18-Bicycle 201"
Description = "201 description"
BicycleType = "Road"
Brand = "Brand-Company A"
Price = 100
Gender = "M"
Color = [ "Red", "Black" ]
ProductCategory = "Bike"
}
| |
| 202 |
{
Title = "21-Bicycle 202"
Description = "202 description"
BicycleType = "Road"
Brand = "Brand-Company A"
Price = 200
Gender = "M"
Color = [ "Green", "Black" ]
ProductCategory = "Bike"
}
| |
| 203 |
{
Title = "19-Bicycle 203"
Description = "203 description"
BicycleType = "Road"
Brand = "Brand-Company B"
Price = 300
Gender = "W"
Color = [ "Red", "Green", "Black" ]
ProductCategory = "Bike"
}
| |
| 204 |
{
Title = "18-Bicycle 204"
Description = "204 description"
BicycleType = "Mountain"
Brand = "Brand-Company B"
Price = 400
Gender = "W"
Color = [ "Red" ]
ProductCategory = "Bike"
}
| |
| 205 |
{
Title = "20-Bicycle 205"
Description = "205 description"
BicycleType = "Hybrid"
Brand = "Brand-Company C"
Price = 500
Gender = "B"
Color = [ "Red", "Black" ]
ProductCategory = "Bike"
}
| |
The following table shows the sample data that the code example in the getting started section uploads to the Forum table. For more information, see Step 3: Load Data into Tables.
| Name (Primary Key) | Other Attributes |
|---|---|
| "Amazon DynamoDB" |
{
Category="Amazon Web Services"
Threads=3
Messages=4
Views=1000
LastPostBy="User A"
LastPostDateTime= "2012-01-03T00:40:57.165Z"
}
|
| "Amazon S3" |
{
Category="Amazon Web Services"
Threads=1
}
|
The following table shows the sample data that the code example in the getting started section uploads to the Thread table. For more information, see Step 3: Load Data into Tables.
Note that, the LastPostDateTime values are shown in the sample data are for illustration only. The code example generates the date and time values so that your table has relatively current dates in your table.
| Primary Key | Other Attributes |
|---|---|
|
ForumName = "Amazon DynamoDB" Subject = "DynamoDB Thread 1" |
{
Message = "DynamoDB thread 1 message text"
LastPostedBy = "User A"
Views = 0
Replies = 0
Answered = 0
Tags = [ "index", "primarykey", "table" ]
LastPostDateTime = "2012-01-03T00:40:57.165Z"
}
|
|
ForumName = "Amazon DynamoDB" Subject = "DynamoDB Thread 2" |
{
Message = "DynamoDB thread 2 message text"
LastPostedBy = "User A"
Views = 0
Replies = 0
Answered = 0
Tags = [ "index", "primarykey", "rangekey" ]
LastPostDateTime = "2012-01-03T00:40:57.165Z"
}
|
|
ForumName = "Amazon S3" Subject = "S3 Thread 1" |
{
Message = "S3 Thread 1 message text"
LastPostedBy = "User A"
Views = 0
Replies = 0
Answered = 0
Tags = [ "largeobject", "multipart upload" ]
LastPostDateTime = "2012-01-03T00:40:57.165Z"
}
|
The following table shows the sample data that the code example in the getting started section uploads to the Reply table. For more information, see Step 3: Load Data into Tables.
Note that, the LastPostDateTime values shown in the sample data are for illustration only. The code example generates the date and time values so that your table has relatively current dates in your table.
| Primary Key | Other Attributes |
|---|---|
|
Id = "Amazon DynamoDB#DynamoDB Thread 1" ReplyDateTime = "2011-12-11T00:40:57.165Z" |
{
Message = "DynamoDB Thread 1 Reply 1 text"
PostedBy = "User A"
}
|
|
Id = "Amazon DynamoDB#DynamoDB Thread 1" ReplyDateTime = "2011-12-18T00:40:57.165Z" |
{
Message = "DynamoDB Thread 1 Reply 1 text"
PostedBy = "User A"
}
|
|
Id = "Amazon DynamoDB#DynamoDB Thread 1" ReplyDateTime = "2011-12-25T00:40:57.165Z" |
{
Message = "DynamoDB Thread 1 Reply 3 text"
PostedBy = "User B"
}
|
|
Id = "Amazon DynamoDB#DynamoDB Thread 2" ReplyDateTime = "2011-12-25T00:40:57.165Z" |
{
Message = "DynamoDB Thread 2 Reply 1 text"
PostedBy = "User A"
}
|
|
Id = "Amazon DynamoDB#DynamoDB Thread 2" ReplyDateTime = "2012-01-03T00:40:57.165Z" |
{
Message = "DynamoDB Thread 2 Reply 2"
PostedBy = "User A"
}
|