If you are using single table design then the GSI names being generic is very useful. If you are not using single table design it (sometimes) makes more sense to give them more specific names.
You give the indices general names, if you have a single table design. That is if you save different data models into the same table. Then you can reuse the indices for each data model differently. At which point it would make no sense in given the index a name of a concrete attribute.
Generic GSI names are good for reusability, if you can fit it within your schema (the library ElectroDB allows you to do this easily); the same way it’s sometimes/many times suggested to name your partition and sort keys, “PK” and “SK” respectively.
But there’s nothing that says you need to name GSIs and partition/sort keys as generically as possible. If it works for you to have your GSI named “users_by_email” or something to that effect, there’s nothing wrong with it.
It just means your queries might be a bit less optimal or your costs will be slightly less optimized. And if monetary difference between “very optimized” and “slightly less very optimized” isn’t significant, it probably doesn’t matter until you scale much more.
I use on demand tables. I don’t think there would be any cost difference whether I use single table or multi table. I hope I’m not missing anything here.
On demand tables don’t really have a tremendous amount to do with single-table designs. There are some cost considerations and even less performance considerations and corner cases where a single table might help.
But the big thing that you can get from a single table design is when you are able to get multiple data types or related data from executing a single QUERY operation. If your data is laid out right, like having a GSI on a `order_id` field, you might be able to get the data for the customer, the order item rows, shipping info and other data types that are all related to that order.
This is an extension of the concept of designing your DynamDB data schema to make sure that you are handling as many of the read use-cases with as get GETs and QUERYs as possible. A single table can let you read multiple data types that might be required for certain processes, from a single QUERY.
But not all applications and use-cases fit into this format, so having multiple tables isn’t a 100% fit for everything. But it is good to think about if you have do have use cases where you might want to get records for multiple data types at the same time.
Multi table design usually means you’re thinking about tables in a relational database way which is an antipattern in dynamo db.
It everything exists in one table you can get all your data in one query. Instead of multiple queries.
For instance, if you have a customer records, order records table and product records you could use a single table design in dynamo that can return data to populate an invoice with customer records product records and order records all in one query.
If you have your product records in a product table, you order records in an order table and your customers in a customer table that’s going to be 3 queries.
In dynamodb you want to model your data for your access patterns, not to fit neatly into separate entities that may exist in your code