Actually, the approach depends on the Query Access Pattern (QAP).
Approach 1:-
Typical, normalized approach similar to RDBMS design. However, we need to think this on NoSQL perspective. There is no join in DynamoDB. Potentially, you may need to read two tables to get the required data. Please note that cost is calculated based on Read Capacity Units. So, the two different reads will cost you.
This approach may be acceptable if the item size exceeds the DynamoDB item size 400 KB
You can write query expression to filter the data by attributes attrX, attrY and attrZ as they are stored as normal scalar data type attributes
Approach 2:-
Preferred NoSQL approach to keep all the required data in one table. Join or additional read is not required
Need to consider whether the item size can exceed 400 KB
Whether you need to write query to filter the data by attributes attrX, attrY and attrZ. Please note that in this approach the ListC data is stored as List of Map DynamoDB data type. In most scenarios, DynamoDB doesn't have the flexibility to query the complex data structures like this (i.e. Map inside List data type)
Answer from notionquest on Stack OverflowList of Objects - means List of Map on DynamoDB database
{ X: "2.8", Y: "nop" } - is the object. This translates to MAP data type on DynamoDB database.
The outside square bracket translates to LIST data type on DynamoDB
database - DynamoDB: How to store a list of items - Stack Overflow
java - Storing and searching maps in DynamoDB? - Stack Overflow
java - DynamoDB Storing/ Mapping Complex Objects in Maps - Stack Overflow
java - Storing JSON as string in DynamoDB vs List/Map types - Stack Overflow
DynamoDB records are literally maps, so yes you can definitely store and search maps in DynamoDB. It looks like if your map isn't of <String, AttributeValue> then you need to provide a custom converter. You wouldn't convert the entire map to a string, you would convert the map to a Map<String, AttributeValue>
Another thing you could consider is
@DynamoDBDocument. Basically it means instead of using a map you are using an object (but translates to a Map with different data types in Dynamo)
Check this link for an example https://github.com/aws/aws-sdk-java/issues/331
First approach
The benefit here is that you can store arbitrary data and should not care if DynamoDB supports it. You don't even need to care if this is a valid JSON. If you are storing DynamoDB List/Maps all attributes should be of types that DynamoDB supports.
You can push this approach even further and use compression and your item will occupy less space and save you some RCUs/WCUs in the process.
The first drawback is that it is harder to work with code like this. Simply because you need to convert data back and forth and this will make your code and operations more complicated.
The second drawback, DynamoDB won't know anything about your data and won't be able to access it. For example you will not be able to use document paths feature.
Second approach
I think this is a preferred approach unless you have a good reason to stick to the first one (e.g. unusual data or size constraints).
The benefit here is that it is easier to work with, you can access all DynamoDB features and if you are using DynamoDBMapper it is really easy to implement.
DynamoDB provides more query flexibility. First of all you can specify query expressions that will use fields in you maps/lists. Second you will be able to project attributes from DynamoDB data structures