# dynamodb how to define none key schema in serverless.yml?

**URL:** <https://forum.serverless.com/t/dynamodb-how-to-define-none-key-schema-in-serverless-yml/5894>\
**Category:** Serverless Framework\
**Tags:** dynamodb\
**Created:** [September 20, 2018, 3:26pm UTC](https://forum.serverless.com/t/dynamodb-how-to-define-none-key-schema-in-serverless-yml/5894 "2018-09-20T15:26:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![foretribe](https://avatars.discourse-cdn.com/v4/letter/f/3da27b/32.png) [@foretribe](https://forum.serverless.com/u/foretribe)\
**Post date:** [September 20, 2018, 3:26pm UTC](https://forum.serverless.com/t/dynamodb-how-to-define-none-key-schema-in-serverless-yml/5894/1 "2018-09-20T15:26:12Z")

</div>

I try to apply a dynamodb in my serverless aws lambda. My file is like:

```auto
resources:
  Resources:
    StoreDynamoDbTable:
      Type: 'AWS::DynamoDB::Table'
      DeletionPolicy: Retain
      Properties:
        AttributeDefinitions:
          - AttributeName: id
            AttributeType: S
          - AttributeName: lat
            AttributeType: N 
          - AttributeName: lng
            AttributeType: N
        KeySchema:
          - AttributeName: id
            KeyType: HASH
        ProvisionedThroughput:
          ReadCapacityUnits: 1
          WriteCapacityUnits: 1
        TableName: ${self:provider.environment.TableStore}

```

I try to apply lat and lng as attributes of storeTable, just the attribute not key Schema, but every store element should have these attributes.

But there is error:

> An error occurred: StoreDynamoDbTable - Property AttributeDefinitions is inconsistent with the KeySchema of the table and the secondary indexes.

How to make lat and lng just mast attribute,not key element for index?

---

<div class="post-metadata">

**Author:** ![rupakg](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/rupakg/32/900_2.png) [@rupakg](https://forum.serverless.com/u/rupakg)\
**Post date:** [September 20, 2018, 3:35pm UTC](https://forum.serverless.com/t/dynamodb-how-to-define-none-key-schema-in-serverless-yml/5894/2 "2018-09-20T15:35:48Z")

</div>

@foretribe In DynamoDB you don’t create a schema of the attributes other than the keys. It is a schema-less NoSQL database. So remove the `lat` and `lng` attributes from the definition.  
Here is the confusing part if you are coming from a RDBMS or SQL databae background:

Every table is a collection of items, and every item is a collection of key/value pairs called _attributes_. In contrast to relational databases, DynamoDB does not enforce a strict schema. **It means that different items can have different numbers of attributes and attributes with the same name can have different types**.

Hope that helps.
