Amazon DynamoDB | Data models and APIs Flashcards
Can DynamoDB be used by applications running on any operating system?
Data models and APIs
Amazon DynamoDB | Database
Yes. DynamoDB is a fully managed cloud service that you access via API. DynamoDB can be used by applications running on any operating system (e.g. Linux, Windows, iOS, Android, Solaris, AIX, HP-UX, etc.). We recommend using the AWS SDKs to get started with DynamoDB. You can find a list of the AWS SDKs on our Developer Resources page. If you have trouble installing or using one of our SDKs, please let us know by posting to the relevant AWS Forum.
What is the Data Model?
Data models and APIs
Amazon DynamoDB | Database
The data model for Amazon DynamoDB is as follows:
Table: A table is a collection of data items – just like a table in a relational database is a collection of rows. Each table can have an infinite number of data items. Amazon DynamoDB is schema-less, in that the data items in a table need not have the same attributes or even the same number of attributes. Each table must have a primary key. The primary key can be a single attribute key or a “composite” attribute key that combines two attributes. The attribute(s) you designate as a primary key must exist for every item as primary keys uniquely identify each item within the table.
Item: An Item is composed of a primary or composite key and a flexible number of attributes. There is no explicit limitation on the number of attributes associated with an individual item, but the aggregate size of an item, including all the attribute names and attribute values, cannot exceed 400KB.
Attribute: Each attribute associated with a data item is composed of an attribute name (e.g. “Color”) and a value or set of values (e.g. “Red” or “Red, Yellow, Green”). Individual attributes have no explicit size limit, but the total value of an item (including all attribute names and values) cannot exceed 400KB.
Is there a limit on the size of an item?
Data models and APIs
Amazon DynamoDB | Database
The total size of an item, including attribute names and attribute values, cannot exceed 400KB. Refer to the design guidance for using ‘Composite Sort Keys’ to design for items that exceed the 400K limit.
Is there a limit on the number of attributes an item can have?
Data models and APIs
Amazon DynamoDB | Database
There is no limit to the number of attributes that an item can have. However, the total size of an item, including attribute names and attribute values, cannot exceed 400KB.
What are the APIs?
Data models and APIs
Amazon DynamoDB | Database
CreateTable – Creates a table and specifies the primary index used for data access.
UpdateTable – Updates the provisioned throughput values for the given table.
DeleteTable – Deletes a table.
DescribeTable – Returns table size, status, and index information.
ListTables – Returns a list of all tables associated with the current account and endpoint.
PutItem – Creates a new item, or replaces an old item with a new item (including all the attributes). If an item already exists in the specified table with the same primary key, the new item completely replaces the existing item. You can also use conditional operators to replace an item only if its attribute values match certain conditions, or to insert a new item only if that item doesn’t already exist.
BatchWriteItem – Inserts, replaces, and deletes multiple items across multiple tables in a single request, but not as a single transaction. Supports batches of up to 25 items to Put or Delete, with a maximum total request size of 16 MB.
UpdateItem – Edits an existing item’s attributes. You can also use conditional operators to perform an update only if the item’s attribute values match certain conditions.
DeleteItem – Deletes a single item in a table by primary key. You can also use conditional operators to perform a delete an item only if the item’s attribute values match certain conditions.
GetItem – The GetItem operation returns a set of Attributes for an item that matches the primary key. The GetItem operation provides an eventually consistent read by default. If eventually consistent reads are not acceptable for your application, use ConsistentRead.
BatchGetItem – The BatchGetItem operation returns the attributes for multiple items from multiple tables using their primary keys. A single response has a size limit of 16 MB and returns a maximum of 100 items. Supports both strong and eventual consistency.
Query – Gets one or more items using the table primary key, or from a secondary index using the index key. You can narrow the scope of the query on a table by using comparison operators or expressions. You can also filter the query results using filters on non-key attributes. Supports both strong and eventual consistency. A single response has a size limit of 1 MB.
Scan – Gets all items and attributes by performing a full scan across the table or a secondary index. You can limit the return set by specifying filters against one or more attributes.
What is the consistency model of the Scan operation?
Data models and APIs
Amazon DynamoDB | Database
The Scan operation supports eventually consistent and consistent reads. By default, the Scan operation is eventually consistent. However, you can modify the consistency model using the optional ConsistentRead parameter in the Scan API call. Setting the ConsistentRead parameter to true will enable you make consistent reads from the Scan operation. For more information, read the documentation for the Scan operation.
How does the Scan operation work?
Data models and APIs
Amazon DynamoDB | Database
You can think of the Scan operation as an iterator. Once the aggregate size of items scanned for a given Scan API request exceeds a 1 MB limit, the given request will terminate and fetched results will be returned along with a LastEvaluatedKey (to continue the scan in a subsequent operation).
Are there any limitations for a Scan operation?
Data models and APIs
Amazon DynamoDB | Database
A Scan operation on a table or secondary index has a limit of 1MB of data per operation. After the 1MB limit, it stops the operation and returns the matching values up to that point, and a LastEvaluatedKey to apply in a subsequent operation, so that you can pick up where you left off.
How many read capacity units does a Scan operation consume?
Data models and APIs
Amazon DynamoDB | Database
The read units required is the number of bytes fetched by the scan operation, rounded to the nearest 4KB, divided by 4KB. Scanning a table with consistent reads consumes twice the read capacity as a scan with eventually consistent reads.
What data types does DynamoDB support?
Data models and APIs
Amazon DynamoDB | Database
DynamoDB supports four scalar data types: Number, String, Binary, and Boolean. Additionally, DynamoDB supports collection data types: Number Set, String Set, Binary Set, heterogeneous List and heterogeneous Map. DynamoDB also supports NULL values.
What types of data structures does DynamoDB support?
Data models and APIs
Amazon DynamoDB | Database
DynamoDB supports key-value and document data structures.
What is a key-value store?
Data models and APIs
Amazon DynamoDB | Database
A key-value store is a database service that provides support for storing, querying and updating collections of objects that are identified using a key and values that contain the actual content being stored.
What is a document store?
Data models and APIs
Amazon DynamoDB | Database
A document store provides support for storing, querying and updating items in a document format such as JSON, XML, and HTML.
Does DynamoDB have a JSON data type?
Data models and APIs
Amazon DynamoDB | Database
No, but you can use the document SDK to pass JSON data directly to DynamoDB. DynamoDB’s data types are a superset of the data types supported by JSON. The document SDK will automatically map JSON documents onto native DynamoDB data types.
Can I use the AWS Management Console to view and edit JSON documents?
Data models and APIs
Amazon DynamoDB | Database
Yes. The AWS Management Console provides a simple UI for exploring and editing the data stored in your DynamoDB tables, including JSON documents. To view or edit data in your table, please log in to the AWS Management Console, choose DynamoDB, select the table you want to view, then click on the “Explore Table” button.