Giriş
Bir NoSQL veri tabanıdır, ancak multi-model'i destekler yani key-value system ve document store olarak kullanılabilir.
1. Key-value store olarak Cassandra, HBase, Redis ile rakip
2. Document DB olarak MongoDB ile rakip.
Burada bir tane yazı var. Sorry, Amazon DynamoDB is not column-based, and it is not OLAP
DynamoDB ilk olarak 2012 yılında piyasaya çıktı
Özellikleri şöyle
Açıklaması şöyle
DynamoDB is Amazon's answer to MongoDB, a NoSQL database that works on JSON documents. These databases rely heavily on nested data and do not enforce any strict schema unless the developer turns that option on. That means that DynamoDB is great for high-volume sites like a CMS or mobile apps with a lot of traffic. For example, both Major League Baseball and Duolingo make use of DynamoDB.
Pricing Model
1. throughput model : Kullanım miktarı tahmin edilir ve bu aşılamaz.
2. on-demand pricing model : Kullanım miktarına göre fiyatlandırılır
Yanlış Kullanım
1. Normalizing Data
DynamoDB bir SQL veri tabanı değildir. Bu yüzden denormalized şekilde kullanılmalıdır
2. Single Table Design
Single Table Design (STD) için açıklaması şöyle
In DynamoDB, you are charged for the capacity throughput and indexes of each table.The more tables you have the more you will end up paying (especially if each table has several secondary indexes).The STD instead encourages grouping all of your (related) data entities in one table.
Replication
Açıklaması şöyle
Departing from the traditional SQL-based offerings, DynamoDB offers a persistence model where the information is spread into partitions with a dual consistency approach.A write operation first saves the updated data to a persistence node. It is then synchronously copied to another persistence node. Only at this point, the operation is confirmed to the caller.There is an asynchronous process that copies it from the second persistence node to a third one.This means you have the redundancy of the data being persisted into 3 nodes, each located in a separate AZ. At the same time, you do not need to wait for all 3 nodes to save before returning the operation, which helps to maintain the latency at a lower level.When retrieving data you have two choices: eventually consistent and strongly consistent.If you opt for eventually consistent, your operation will be directed to any of the 3 nodes. If it happens to be the asynchronously copied one, there is a chance the information you will retrieve will be outdated when compared to the main node.In contrast, the strongly consistent mode will only be directed to the main node.
MongoDB vs DynamoDB
- MongoDB en büyük belge büyüklüğü olarak 16 MB'yi destekler. Bu DynamoDB'de 400 KB
- MongoDB C++ ile geliştirilmiştir. DynamoDB Java ile geliştirilmiştir
Primary Key
Açıklaması şöyle
... it only allows three data types for primary keys: string, number, and binary. (It does support many different data types for other attributes within a table.)
Açıklaması şöyle
DynamoDB has a weird take on the concept of a primary key. You will have two keys to identify specific data:Primary Key = Partition Key + Sort Key
Şeklen şöyle
Örnek
Tablo şöyle olabilir
PRIMARY_KEY SORT_KEY OTHER_INFO1. ORDER#1234 PRODUCT#1 ProductName,Price etc2. ORDER#1234 INVOICE#1 InvoiceDate, PaymentInfo3. ORDER#1234 CUSTOMER#1 CustomerName, ShippingAddress
Value Type
Açıklaması şöyle
Dynamo DB stores the value in a JSON serialized format
Sütun Tipleri
Açıklaması şöyle
DynamoDB supports many different data types for attributes within a table. They can be categorized as follows:1. Scalar Types – A scalar type can represent exactly one value. The scalar types are number, string, binary, Boolean, and null.2. Document Types – A document type can represent a complex structure with nested attributes, such as you would find in a JSON document. The document types are list and map.3. Set Types – A set type can represent multiple scalar values. The set types are string set, number set, and binary set.
Global Secondary Index
Eğer istediğimiz veri Primary Key dışındaysa bu index kullanılır. Tek problem her indeksin tek başına bir tablo olması
DynamoDB Disadvantages
Açıklaması şöyle
Size limit — item can only reach 400KB in sizeLimited querying options (limited number of indices)Throttling on burst throughput (and hot keys in certain situations)
create-table
Örnek
Şöyle yaparız
aws dynamodb --endpoint-url=http://localhost:4566 create-table \--table-name Music \--attribute-definitions \AttributeName=Artist,AttributeType=S \AttributeName=SongTitle,AttributeType=S \--key-schema \AttributeName=Artist,KeyType=HASH \AttributeName=SongTitle,KeyType=RANGE \--provisioned-throughput \ReadCapacityUnits=10,WriteCapacityUnits=5
describe-table
Şöyle yaparız
aws --endpoint-url=http://localhost:4566 dynamodb describe-table
--table-name Music | grep TableStatus
put-item
Şöyle yaparız
aws --endpoint-url=http://localhost:4566 dynamodb put-item \ --table-name Music \ --item \ '{"Artist": {"S": "No One You Know"}, "SongTitle": {"S": "Call Me Today"},
"AlbumTitle": {"S": "Somewhat Famous"}, "Awards": {"N": "1"}}'
scan
Şöyle yaparız
aws dynamodb scan --endpoint-url=http://localhost:4566 --table-name Music
Açıklaması şöyle
Because DynamoDB is not relational and does not enforce ACID by default, it must use a modified version of standard SQL. Amazon has developed a query language called PartiQL which uses many SQL concepts but is built for highly nested data. The query below takes advantage of the key-value underpinnings of DynamoDB in a relatively SQL standard way.
Şöyle yaparız
UPDATE Music SET AwardsWon = 1 SET AwardDetail = { 'Grammys': [ 2020, 2018 ] } WHERE Artist = 'Acme Band' AND SongTitle = 'PartiQL Rocks'
Hiç yorum yok:
Yorum Gönder