{"id":22691507,"url":"https://github.com/noahingh/dynamodb-tutorial","last_synced_at":"2025-03-29T16:42:06.065Z","repository":{"id":187795026,"uuid":"242492952","full_name":"noahingh/dynamodb-tutorial","owner":"noahingh","description":"Dynamo DB tutorial to cover \"from SQL to NoSQL\".","archived":false,"fork":false,"pushed_at":"2020-02-23T09:56:12.000Z","size":2,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-04T17:50:58.651Z","etag":null,"topics":["aws","buzzvil","dynamodb","scalability-edge","tutorial"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/noahingh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-02-23T09:55:37.000Z","updated_at":"2020-02-23T09:57:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"724453ff-9667-4548-9e0c-ec990bbad7b8","html_url":"https://github.com/noahingh/dynamodb-tutorial","commit_stats":null,"previous_names":["noahingh/dynamodb-tutorial"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noahingh%2Fdynamodb-tutorial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noahingh%2Fdynamodb-tutorial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noahingh%2Fdynamodb-tutorial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noahingh%2Fdynamodb-tutorial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/noahingh","download_url":"https://codeload.github.com/noahingh/dynamodb-tutorial/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246215820,"owners_count":20741894,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","buzzvil","dynamodb","scalability-edge","tutorial"],"created_at":"2024-12-10T01:11:25.636Z","updated_at":"2025-03-29T16:42:06.045Z","avatar_url":"https://github.com/noahingh.png","language":"Shell","readme":"# Dynamodb tutorial\n\n## What is covered?\n\n- [From SQL to NoSQL](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/SQLtoNoSQL.html)\n\n## Index\n\n1. [Set up](#set-up)\n2. [Create a Table](#create-a-table)\n3. [Writing Data a Table](#writing-data)\n4. [Reading Data from a Table](#reading-data)\n    - [GetItem](#getitem)\n    - [Querying](#querying)\n    - [Scaning](#scaning)\n5. [Managing Indexes](#managing-indexes)\n\n## Set up\n\nSet up with [Dynamodb docker image](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.UsageNotes.html#DynamoDBLocal.Endpoint).\n\n```shell\n# run dynamodb service.\n$ docker run -p 8000:8000 amazon/dynamodb-local:1.12.0 \\\n    -jar DynamoDBLocal.jar -inMemory  -sharedDb\n```\n\n```shell\n# set up for the client and test the connection with the Docker container.\n$ export AWS_ACCESS_KEY_ID=key; export AWS_SECRET_ACCESS_KEY=secret; export AWS_DEFAULT_REGION=ap-northeast-1;\n$ export ENDPOINT=http://localhost:8000/\n\n$ aws dynamodb list-tables --endpoint-url $ENDPOINT\n{\n    \"TableNames\": []\n}\n```\n\n## Create a Table\n\n```shell\n# create the Music table.\n$ aws dynamodb create-table \\\n    --endpoint $ENDPOINT \\\n    --table-name Music \\\n    --attribute-definitions \\\n        AttributeName=Artist,AttributeType=S \\\n        AttributeName=SongTitle,AttributeType=S \\\n    --key-schema \\\n        AttributeName=Artist,KeyType=HASH \\\n        AttributeName=SongTitle,KeyType=RANGE \\\n    --provisioned-throughput \\\n        ReadCapacityUnits=1,WriteCapacityUnits=1 \\\n\n$ aws dynamodb list-tables --endpoint-url $ENDPOINT\n{\n    \"TableNames\": [\n        \"Music\"\n    ]\n}\n```\n\n## Getting information\n\n```shell\n$ aws dynamodb describe-table --table-name Music --endpoint $ENDPOINT\n\n{\n    \"Table\": {\n        \"AttributeDefinitions\": [\n            {\n                \"AttributeName\": \"Artist\",\n                \"AttributeType\": \"S\"\n            },\n            {\n                \"AttributeName\": \"SongTitle\",\n                \"AttributeType\": \"S\"\n            }\n        ],\n        \"TableName\": \"Music\",\n        \"KeySchema\": [\n            {\n                \"AttributeName\": \"Artist\",\n                \"KeyType\": \"HASH\"\n            },\n            {\n                \"AttributeName\": \"SongTitle\",\n                \"KeyType\": \"RANGE\"\n            }\n        ],\n        ...\n    }\n}\n```\n\n## Writing data\n\nSeed datas same as [doc](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/SQLtoNoSQL.WriteData.html).\n\n```shell\n$ sh scripts/seed.sh\n```\n\n## Reading data\n\nThere are three options to read data in DynamoDB([doc](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/SQLtoNoSQL.ReadData.html)).\n\n### GetItem\n\nRetrieves a single item from a table. \n\n```shell\n# the entire item with all of its attributes.\n$ aws dynamodb get-item --endpoint $ENDPOINT \\\n    --consistent-read \\\n    --table-name Music \\\n    --key \\\n        '{ \n            \"Artist\": {\"S\": \"No One You Know\"}, \n            \"SongTitle\": {\"S\": \"Call Me Today\"}\n        }'\n\n# add a ProjectionExpression parameter to return only some of the attributes.\n$ aws dynamodb get-item --endpoint $ENDPOINT \\\n    --consistent-read \\\n    --table-name Music \\\n    --projection-expression \"AlbumTitle,Price\" \\\n    --key \\\n        '{ \n            \"Artist\": {\"S\": \"No One You Know\"}, \n            \"SongTitle\": {\"S\": \"Call Me Today\"}\n        }'\n    \n```\n\n### Querying\n\nYou can use Query with **any table that has a composite primary key (partition key and sort key).** You must specify an equality condition for the partition key, and you can optionally provide another condition for the sort key.\n\n`KeyConditionExpression` parameter specifies the key values that you want to query.\n\n```shell\n$ aws dynamodb query \\\n    --endpoint $ENDPOINT \\\n    --table-name Music \\\n    --key-condition-expression \"Artist = :a and SongTitle = :t\" \\\n    --expression-attribute-values \\\n        '{\n            \":a\": {\"S\":\"No One You Know\"},\n            \":t\": {\"S\":\"Call Me Today\"}\n        }'\n\n# return all of the songs by an artist\n$ aws dynamodb query \\\n    --endpoint $ENDPOINT \\\n    --table-name Music \\\n    --key-condition-expression \"Artist = :a\" \\\n    --expression-attribute-values \\\n        '{\n            \":a\": {\"S\":\"No One You Know\"}\n        }'\n```\n\n### Scaning\n\nRetrieves all of the items, but it support `FilterExpression` parameter, which you can use to discard items.\n\n## Managing indexes\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoahingh%2Fdynamodb-tutorial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnoahingh%2Fdynamodb-tutorial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoahingh%2Fdynamodb-tutorial/lists"}