3

I am considering choosing between DynamoDB and AWS Keyspaces.

My main issue is still with many-to-many relationship in Dynamo. You don't really have too nice options. Either you do adjecency list for immutable data...but in most scenarios data is gonna change. Other way is making 2 db calls which is really not that great. Third option would be to update data all the time which seems also like a big pain in the a**. Also for batch writes it's up to 25 rows I think.

However Cassandra provides materialized views where at least I don't have to manage replication on my own. Also I can do 1 DB call to get all I need.

I am still relatively new to NoSQL databases so I might be missing a lot of stuff.

Are there plans for Dynamo to add Materialized Views or is there better way to do it?

In my eyes it seems like a really good feature. It doesn't even have to create new tables, rather references between columns of items to make it autoupdate.

Djordje Nikolic
  • 343
  • 6
  • 12
  • I’m voting to close this question because it is not about programming. – Aaron Oct 13 '20 at 12:49
  • 2
    It's about amazon-dynamodb, which is one of the recognized tags in stackoverflow. It's about the features of a database, which you use through code. So I don't see why it's "not about programming" any more than most of the database-related questions. – Nadav Har'El Oct 13 '20 at 13:26
  • @NadavHar'El fair point. The main reason I voted this way, was that I don't know if this is really the most appropriate place to be speculating on the future roadmap of data store products. Doesn't really fit what SO is about. – Aaron Oct 13 '20 at 17:58

1 Answers1

4

DynamoDB has a feature called Global Secondary Index which is very close to the materialized view feature of Cassandra. Despite its confusing name, DynamoDB's GSI is not just an index like what Cassandra calls a "secondary index"! It doesn't just like the keys matching a particular column value: Beyond the keys it can also keep any other items attributes which you choose to project. Exactly like a materialized view.

DynamoDB also has a more efficient Local Secondary Index which you can consider if the view's partition key is the same as the base table's - and you just want to sort items differently or project only part of the attributes.

Nadav Har'El
  • 11,785
  • 1
  • 24
  • 45
  • In many-to-many it can be used in adjecency list for immutable data. Many customers visit restaurants and you want to check all customers that visited certain restaurant as well as all customers of the restaurant ever. For that you can use inverted index of PK and SK and get the data. Data has to be duplicated for each relationship. If restaurant updates its name for example or adds a new address you have to update millions of rows. Materialized view keeps duplicated data updated all the time. – Djordje Nikolic Oct 13 '20 at 13:58
  • 1
    Yes, I know what Materialized Views are in Cassandra, but I'm trying to say that GSI in DynamoDB are exactly the same! They also keep duplicated data, not just a index. What Cassandra MV feature do you believe is missing in DynamoDB GSI? – Nadav Har'El Oct 13 '20 at 14:03
  • Got it. I thought Materialized View can be done across multiple tables to keep data in sync and achieve many-to-many. Such as referencing. My current issue is safe data duplication in dynamo. Any tips for the example I gave above except making 2 database calls? – Djordje Nikolic Oct 13 '20 at 14:10
  • I still don't understand your question. In DynamoDB if you have a table with a GSI, every update to the base table will also automatically go to the GSI - it's the same as in a materialized view. You'll pay for these two writes, but you only need to do one write to the base table, and the write to the GSI table happens automatically and safely (as much as possible - "consistent read" from a GSI is not supported, so you only get eventual consistency). – Nadav Har'El Oct 13 '20 at 14:16
  • I'll close this issue since I am asking different question. Thank you for clearing up what materialized views are. – Djordje Nikolic Oct 13 '20 at 14:26