Amazon DynamoDB Basic Apis

Amazon DynamoDB Basic Apis Writing Data

  1. put item
    • create a new item or fully replace an old item
    • consumes WCUs
  2. update item
    • edits and existing items attributes or adds a new item if it doesn’t exist
    • can be used to implement Atomic counters – a numeric attribute that’s unconditionally incremented
  3. conditional writes
    • accept a write/update/delete only if conditions are met, otherwise returns an error
    • helps with concurrent access to items
    • no performance impact

Amazon DynamoDB Basic Apis Reading Data

1 GetItem

  • read based on primary key
  • primary key can be hash hash+range
  • eventually consistent Read (default)
  • Option to use Strongly Consistent Read (more RCU – might take longer)
  • ProjectionExpresion can be specified to retrieve only certain attributes

Reading Data (Query)


  1. query return items base on:
  • keyconditionalexpression
  • partition key value (must be = operator)-requierd
  • sort value(=,<,<=,>,>=, between, begins with) – optional]
  • FilterEcpresion:
  • adiotnal filtering after the query operation(before data returned to you)
  • Use only with non-key attributes (does not allow HASH or RANGE attributes)

2. Returns:

    • number of items specified in limit
    • or up to 1 MB of data

    3. Abaility to do pagination on the results

    4. can query table a local secondary index or a Global Secondary index

      Reading Data (Scan)

      1. Scan the entire table and then filter out data(inefficient)
      2. Returns up to 1 MB of data - use pagination to keep on reading
      3. Consumes a lot of RCU
      4. Limit impact using Limit or reduce the size of the result and pause
      5. For fater performace use Parallel Scan
         - Multioke workers scan multiple data segments at the same time
         - increacses the Throughput and RCU consumed
         - Limit the impact af parallel scans just like you would for Scans
      6. Can use ProjectionExpresion & FilterExpresion(no Changes to RCU)
      

      Deleting Data

      1. DeleteItem
         - delete and individual item
         - ability to perform a conditional delete
      2. DeleteTable
         - Delete a Whole table and all its items
         - much quicker deletion then calling DeleteItem on all items
      

      Batch operations

      1. allows to save in latency by reducing the number of API calls
      2. Operations are done in parallel for better efficiency
      3. Part of bath can fail; in which case we need to try again for the failed items
      4. BatchWritenItem
         - up to 25 PutItem and/ot DeleteItem in one call
         - this up to 16 MB of data written, up to 400 KB of data per item
         - can't update items(use UpdateItem)
         - UnProcessedItems for failed write operations (exponential backoff or add WCU)
      5. Batch Get Item
         - Return item from one or more tables
         - up to 100 item up to 16 MB of Data
         - Items are retrieved in Parallel to minimize latency
         - UnprocessedKeys for Failed read operations(exponential backoff or add RCU)
      

      PartiQL

      1. Sql-compatible query language for DynamoDB
      2. allows you to select, insert, updaqte and delete data in DynamoDB using Sql
      3. run queries across multiple DynamoDB tables
      4. Run partiQL queries from:
         - Aws Management Console
         - NoSQL Workbench for DynamoDB
         - DynamoDB APIs
         - AWS CLI
         - AWS SDK
      

      Example of update and delete , query data on DynamoDB

      Here we have the table futbolTeam that have 3 items

      We can update the name of one team for example the id team 2 we change the name to Alianza Lima

      we can create a item just to click on create item and fill the fields

      we can query by id

      we can query on PartiQL

      Links

      https://console.aws.amazon.com/console/home?nc2=h_ct&src=header-signin

      https://juliovaldiviamarin.com/amazon-dynamo-db/


      Posted

      in

      by

      Tags:

      Comments

      Leave a Reply