Amazon DynamoDB | Data models and APIs Flashcards

1
Q

Can DynamoDB be used by applications running on any operating system?

Data models and APIs

Amazon DynamoDB | Database

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the Data Model?

Data models and APIs

Amazon DynamoDB | Database

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Is there a limit on the size of an item?

Data models and APIs

Amazon DynamoDB | Database

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Is there a limit on the number of attributes an item can have?

Data models and APIs

Amazon DynamoDB | Database

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the APIs?

Data models and APIs

Amazon DynamoDB | Database

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the consistency model of the Scan operation?

Data models and APIs

Amazon DynamoDB | Database

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How does the Scan operation work?

Data models and APIs

Amazon DynamoDB | Database

A

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).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Are there any limitations for a Scan operation?

Data models and APIs

Amazon DynamoDB | Database

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How many read capacity units does a Scan operation consume?

Data models and APIs

Amazon DynamoDB | Database

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What data types does DynamoDB support?

Data models and APIs

Amazon DynamoDB | Database

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What types of data structures does DynamoDB support?

Data models and APIs

Amazon DynamoDB | Database

A

DynamoDB supports key-value and document data structures.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a key-value store?

Data models and APIs

Amazon DynamoDB | Database

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a document store?

Data models and APIs

Amazon DynamoDB | Database

A

A document store provides support for storing, querying and updating items in a document format such as JSON, XML, and HTML.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Does DynamoDB have a JSON data type?

Data models and APIs

Amazon DynamoDB | Database

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Can I use the AWS Management Console to view and edit JSON documents?

Data models and APIs

Amazon DynamoDB | Database

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Is querying JSON data in DynamoDB any different?

Data models and APIs

Amazon DynamoDB | Database

A

No. You can create a Global Secondary Index or Local Secondary Index on any top-level JSON element. For example, suppose you stored a JSON document that contained the following information about a person: First Name, Last Name, Zip Code, and a list of all of their friends. First Name, Last Name and Zip code would be top-level JSON elements. You could create an index to let you query based on First Name, Last Name, or Zip Code. The list of friends is not a top-level element, therefore you cannot index the list of friends. For more information on Global Secondary Indexing and its query capabilities, see the Secondary Indexes section in this FAQ.

17
Q

If I have nested JSON data in DynamoDB, can I retrieve only a specific element of that data?

Data models and APIs

Amazon DynamoDB | Database

A

Yes. When using the GetItem, BatchGetItem, Query, or Scan APIs, you can define a ProjectionExpression to determine which attributes should be retrieved from the table. Those attributes can include scalars, sets, or elements of a JSON document.