Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Mastering DynamoDB
Mastering DynamoDB

Mastering DynamoDB: Master the intricacies of the NoSQL database DynamoDB to take advantage of its fast performance and seamless scalability

eBook
$19.99 $28.99
Paperback
$47.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Mastering DynamoDB

Chapter 2. Data Models

The flexibility of any database depends on the architecture and design of its data models. A data model fundamentally decides how data is stored, organized, and can be manipulated. When it comes to typical a RDBMS, we tend to provide the information in terms of hierarchical, relational, and network data models. SQL was designed to interact with an end user assuming he/she will use SQL to run queries that would aggregate data at one place, giving all information together. But it takes a lot of effort to maintain this user-oriented approach. Later, people realized that most of the time is being spent on creating database schemas, maintaining referential integrity, and providing transactional guarantees even though they are not using these things much. This thought ultimately resulted in the implementation of schema-less, relation-free databases, that is, NoSQL databases.

Relational data modeling starts with all the data that you have and the answers you can...

Primary key

DynamoDB, being a key-value pair database, does not index on all given attributes for a given item; it only indexes on the primary key, which is a mandatory attribute for each item of the table.

DynamoDB supports two types of primary keys:

  • Hash primary key
  • Hash and range primary key

Hash primary key

Each DynamoDB table must have a hash primary key that is unique for each item. DynamoDB builds an unordered hash index on this key that allows us to uniquely identify any given item for a given table. So, while designing your table, you must choose an attribute that would have a unique value for each attribute. For example, while creating Person table, choosing Social Security Number (SSN) as a hash key would be a better option as compared to selecting a person's name as hash key, as there might be more than one person having the same name.

Hash and range primary key

Along with the hash key, DynamoDB also supports another primary key called range key, which can be used in combination...

Secondary indexes

A primary key attribute allows us to create, maintain, and access data efficiently. To do so, DynamoDB creates indexes on those primary attributes as we have seen in the previous section. However, sometimes there might be a need to search and access items from attributes that are not part of the primary key. For all such needs, DynamoDB supports secondary indexes that can be created on attributes other than the primary key and can be accessed and searched in a manner similar to the primary key.

A secondary index contains a subset of attributes from the given table having an alternative key to support query operations. Secondary index allows users to search attributes other than the primary key, which makes DynamoDB useful for a varied set of applications. We can create multiple secondary indexes for a given table. If we don't create secondary indexes, the only option to get the item for a certain non-primary key attribute is to scan the complete table, which is a very...

Data types

DynamoDB supports various data types, broadly classified into the following two types:

  • Scalar data types (string, number, and binary)
  • Multivalued data types (string set, number set, and binary set)

Scalar data types

Scalar data types are simply single-value, simple data types. DynamoDB supports the following three scalar data types:

  • String
  • Number
  • Binary

String

The string is a multipurpose, useful data type that is similar to what we use in various programming languages. DynamoDB strings support UTF-8 binary encoding. DynamoDB does not put restrictions on the string size limit, but it specifies that the total attribute size should not be greater than 64 KB and we already know that attribute value is calculated considering the attribute name (key) plus attribute value together. When it comes to ordered query results, DynamoDB does the comparison using ASCII character code value, which means smaller letters (a,b,c,...) are greater than capital letters (A,B,C,…). One thing to note...

Operations on tables

A table in DynamoDB is quite easy to create and operate. With a few clicks on the DynamoDB management console, you can have your table created in a couple of minutes. To do so, you just need a suitable table name, primary key attributes, their data types, and read and write throughput provisioning units, and you are done. DynamoDB allows us to use the characters a-z, A-Z, 0-9, - (dash), .(dot), and _(underscore) in table names.

We have already seen how to create a table using the AWS management console in the previous chapter. Now, let's try to do table operations using the AWS SDK.

Using the AWS SDK for Java

In this section, we are going to see how to use the AWS SDK for Java to perform operations.

Create table

Before creating a table, you should have thought about how the user is going to use that table in his/her application. Data modeling in DynamoDB should be application oriented in order to get the maximum benefit of the NoSQL features. You should also have a...

Operations on items

Items in DynamoDB are simply collections of attributes. Attributes can be in the form of strings, numbers, binaries, or a set of scalar attributes. Each attribute consists of a name and a value. An item must have a primary key. As we have already seen, a primary key can have a hash key or a combination of hash and range keys. In addition to the primary key, items can have any number of attributes except for the fact that item size cannot exceed 64 KB.

While doing various item operations, you should have be aware of following DynamoDB features.

Strong versus eventual consistency

In Chapter 1, Getting Started, we had talked about the durability feature of DynamoDB. To provide this durability, DynamoDB keep copies of items in various availability zones. When a certain item gets updated, DynamoDB needs to make sure that it updates all other copies as well. However, it takes time to make any write consistent on all servers; that's why the operation is called eventually...

Primary key


DynamoDB, being a key-value pair database, does not index on all given attributes for a given item; it only indexes on the primary key, which is a mandatory attribute for each item of the table.

DynamoDB supports two types of primary keys:

  • Hash primary key

  • Hash and range primary key

Hash primary key

Each DynamoDB table must have a hash primary key that is unique for each item. DynamoDB builds an unordered hash index on this key that allows us to uniquely identify any given item for a given table. So, while designing your table, you must choose an attribute that would have a unique value for each attribute. For example, while creating Person table, choosing Social Security Number (SSN) as a hash key would be a better option as compared to selecting a person's name as hash key, as there might be more than one person having the same name.

Hash and range primary key

Along with the hash key, DynamoDB also supports another primary key called range key, which can be used in combination with...

Secondary indexes


A primary key attribute allows us to create, maintain, and access data efficiently. To do so, DynamoDB creates indexes on those primary attributes as we have seen in the previous section. However, sometimes there might be a need to search and access items from attributes that are not part of the primary key. For all such needs, DynamoDB supports secondary indexes that can be created on attributes other than the primary key and can be accessed and searched in a manner similar to the primary key.

A secondary index contains a subset of attributes from the given table having an alternative key to support query operations. Secondary index allows users to search attributes other than the primary key, which makes DynamoDB useful for a varied set of applications. We can create multiple secondary indexes for a given table. If we don't create secondary indexes, the only option to get the item for a certain non-primary key attribute is to scan the complete table, which is a very expensive...

Data types


DynamoDB supports various data types, broadly classified into the following two types:

  • Scalar data types (string, number, and binary)

  • Multivalued data types (string set, number set, and binary set)

Scalar data types

Scalar data types are simply single-value, simple data types. DynamoDB supports the following three scalar data types:

  • String

  • Number

  • Binary

String

The string is a multipurpose, useful data type that is similar to what we use in various programming languages. DynamoDB strings support UTF-8 binary encoding. DynamoDB does not put restrictions on the string size limit, but it specifies that the total attribute size should not be greater than 64 KB and we already know that attribute value is calculated considering the attribute name (key) plus attribute value together. When it comes to ordered query results, DynamoDB does the comparison using ASCII character code value, which means smaller letters (a,b,c,...) are greater than capital letters (A,B,C,…). One thing to note here is...

Left arrow icon Right arrow icon
Download code icon Download Code

Description

If you have interest in DynamoDB and want to know what DynamoDB is all about and become proficient in using it, this is the book for you. If you are an intermediate user who wishes to enhance your knowledge of DynamoDB, this book is aimed at you. Basic familiarity with programming, NoSQL, and cloud computing concepts would be helpful.

What you will learn

  • Comprehend the DynamoDB data model and how to build the efficient schema of DynamoDB tables
  • Decipher the architecture of DynamoDB and its core features
  • Understand how DynamoDB manages ring membership and handles partial failures
  • Get acquainted with the AWS security token service and learn how DynamoDB deals with authentication and authorization
  • Integrate DynamoDB with other AWS services in order to form a complete application ecosystem on AWS Cloud
  • Explore thirdparty tools and libraries to efficiently use DynamoDB to help to autoscale, test, and back up/archive
  • Familiarize yourself with mobile application development using DynamoDB at the backend

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Aug 25, 2014
Length: 236 pages
Edition : 1st
Language : English
ISBN-13 : 9781783551965
Category :
Concepts :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Aug 25, 2014
Length: 236 pages
Edition : 1st
Language : English
ISBN-13 : 9781783551965
Category :
Concepts :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 145.97
DynamoDB Cookbook
$48.99
DynamoDB Applied Design Patterns
$48.99
Mastering DynamoDB
$47.99
Total $ 145.97 Stars icon

Table of Contents

10 Chapters
1. Getting Started Chevron down icon Chevron up icon
2. Data Models Chevron down icon Chevron up icon
3. How DynamoDB Works Chevron down icon Chevron up icon
4. Best Practices Chevron down icon Chevron up icon
5. Advanced Topics Chevron down icon Chevron up icon
6. Integrating DynamoDB with Other AWS Components Chevron down icon Chevron up icon
7. DynamoDB – Use Cases Chevron down icon Chevron up icon
8. Useful Libraries and Tools Chevron down icon Chevron up icon
9. Developing Mobile Apps Using DynamoDB Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.8
(5 Ratings)
5 star 20%
4 star 20%
3 star 0%
2 star 40%
1 star 20%
A. Zubarev Nov 04, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Databases are very much in the spotlight lately and especially the NoSQL breed. While there are dozens of offerings on the market only a handful tops the list, one such offspring in the key-value area is Amazon's DynamoDB. Being a close relative to such popular players on this arena as Redis or Voldemort DynamoDB I figured has many unique points, add-ons and a strong backing by the user community, not only the mighty Amazon corporation. Mastering DynamoDB as a book came out at a very strategic time.It is a great technical read, too. Tanmay (the author) walks you gently into the wonderful NoSQL database world. Then the book takes you, arm with DynamoDB, and make a fearless traveller sailing through high seas of today’s turbulent and fierce data streams and make you prowl the dark alleys of handling the data in the Cloud.The book is structured so it devotes its several first chapters to the nitty-gritties of the DynamoDB and then explains on best practices and best usage scenarios. The book has an advanced chapter for those who like the extremes. For example relational integrity is suddenly discussed in a book about NoSQL (no schema or structure supposed to be there the core, alas not so fast). The book tastefully ends with an overview of the top 10 or so of the sheer third party offerings from either Amazon itself or GitHubers.The best one I liked is the local DynamoDB and the ability to conduct transactions. The module that allows to scale the database appeared to be very much of value, but frankly I was surprised it is not written by Amazon itself. To say more, the design decision of having a developer (or perhaps an admin) being responsible for assigning and provisioning compute throughput for each table made my eyebrows raise.The author appeared very savvy in the subject of Cloud Data (perhaps I coined it), I actually learned quite a few interesting techniques and found out that Amazon has SLAs for each component, even for their internal systems and especially such a crucial piece as DynamoDB. And they are tight SLAs. Yet, make a lot of sense to me. Nobody argues Amazon does not successfully process huge volumes of data, fast.Anyway, I liked the book and the author much, heck, perhaps even more than the DynamoDB as a database itself.
Amazon Verified review Amazon
FRANC C CARTER Oct 18, 2014
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Mastering DynamoDB is a medium level introduction to most of the features, uses cases and concepts of DynamoDB. The only obvious omission is that configuration with Cloudformation is not covered, however you could argue that this is best left to a book covering Cloudformation.The section I found most valuable was the third party tools which fill useful gaps not covered by DynamoDB itself at the moment. Given the range of coverage I would expect that most people will find useful pieces of information unless they already have comprehensive experience with DynamoDB.The main weakness is the colloquial and conversational style. This along with a lack of diagrams made the indexing section hard to follow. I would have liked to see more diagrams showing the index designs along with more succinct language. I found Amazon's description of indexing to be clearer than Mastering DynamoDB.
Amazon Verified review Amazon
Steven Chu Jan 12, 2023
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
First the good things:- Limitations (e.g. 10GB table max size when using local indexes, max item size of 400KB, etc.)- A nice enumeration of interesting libraries (transaction libraries, geo libraries, etc.)Now the many, many bad things:- LOTs of wasted space showing the same query API in 4 different programming languages- Wasted space showing architecture diagrams that essentially repeat previous chapters -- and do so for essentially the same exact type of web architectures- No depth on the internals of DynamoDB; I understand that this is AWS proprietary software, but the author did not even take a practical approach to discuss things that other DBs do; for example, I come from a MySQL world where heuristics such as no DB over 1TB since performance can degrade beyond this point, not using foreign keys because they make online schema changes hard, etc. are all lessons learned from years of battle-tested DBA experience; I'd hope for the same lessons in a book dedicated to DynamoDBSave your money and try and read articles and watch YouTube or maybe wait for a better book.
Amazon Verified review Amazon
Chris Snow Aug 13, 2015
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
This book has poor editing and concepts are not clearly explained. After the confusing description of Hash and Range keys in chapter 2, I put the book away and instead followed a DynamoDB tutorial on youtube and also the hands on tutorial in the Dynamo DB Local Javascript Shell.
Amazon Verified review Amazon
Omar Nov 08, 2017
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
Either book was rushed and/or review was poor. One too many confusing statements that'll force you to go online to make sense of the topic anyway. Used the book as more of an outline rather than an in-depth analysis into Dynamodb. Most of the content seems bloated/irrelevant in order to fill up pages.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.