Search code examples
database-designamazon-dynamodbamazon-rdsamazon-auroradynamodb-queries

Query against collection attribute using a managed database option on Amazon


I would like to query for some objects in O(log N) time by a field that is a set of string values.

Example object being indexed:

Restaurant: {
     name: 'Bobs Burgers'
     menu: ['hamburger', 'hotdog', 'lasagna']
}

Example pseudo-query:

SELECT * FROM restaurants WHERE menu='hamburger'
( or perhaps: 'hamburger' in menu )

Long ago I used Google App Engine and they allowed me to do this on their NoSql database, Big Table.

However I understand that Amazon's DynamoDB does not allow me to this. I understand that if I were to use DynamoDB for this type of query, I would need to use code to maintain a secondary look-up table myself (which obviously I don't want to do). Am I correct in this assumption? Or is there a clean technique that is used to query against this kind of data in O(log N) time using a database with the limitations of DynamoDB (which is that sets/collections cannot be used in an index)

Or should I be using a different technology for this type of use case? For example Amazon RDS - which offers the following types of Databases:

  • Amazon Aurora
  • PostgreSQL
  • MySQL
  • MariaDB

Solution

  • AWS DocumentDB does this. It is MongoDB compatible.

    The type of index that you are referring to is called "Multikey" in MongoDB:

    "https://docs.mongodb.com/manual/core/index-multikey/"