3-Databases Flashcards
How is data on DynamoDB stored?
On SSDs that are replicated in 3 geographically distinct data centres
What are the conceptual elements of DynamoDB?
Tables are broad collections of data, they consist of items which each have attributes
It supports both the key-value and document data models
How can access to DynamoDB be restricted?
IAM provides very fine-grained control.
The dynamodb:LeadingKeys and dynamodb:attributes conditions restrict access to items and attributes respectively
How are items in DynamoDB reference?
With a primary key
How do primary keys work in DyanmoDB?
There are two kinds: a partition key is based on a unique attribute i.e. user ID
If the partition key is not unique, a composite key is used instead. It consists of a partition key and a sort key
What is the purpose of database indexes?
They allow fast queries to be performed on specific columns/attributes
What indexes does DynamoDb support?
Local Secondary Index - same partition key as the original table but different sort key, Can only be created when the table is created
Global Secondary Index - can be added later. Hase a differetn partition key and a different sort key as the original table
What API calls are used to get data out of DynamoDB?
Query, Scan, Get and BatchGetItem
How does Query work in DynamoDB?
It finds items based on the primary key of a table or index.
It is eventually consistent by default but can be set to strongly consistent
How can Query be refined?
It usually returns all attributes but the ProjectionExpression parameter can control this
Usually results are ascending by sort key but setting ScanIndexForward to false reverses this
How does Scan work in DynamoDB?
It dumps all items in a table and filters those of interest
The attributes it returns can be controlled with the ProjectionExpression parameter
How can the performance impact of scans be minimised?
Performing parallel scans - by default data is processed sequentially in 1 MB blocks
Set a lower-page size as this means fewer items are returned per API call
What are the consistency models of Scan and Query?
Scan is eventually consistent
Query is eventually consistent by default but can be made strongly consistent
How is DyanmoDB capacity managed?
Manually with capacity units, or automatically with the On-Demand Capacity option
How is DynamoDB throughput calculated?
Each write capacity unit allows for 1 x 1 KB write per second
Each read capacity unit allows for either 1 x 4 KB strong consistent read per second or 2 x 4 KB eventually consistent reads per second