Reputation: 405
Currently, my database is having 3 collections. Basically, my data Structure is shown below.
xx: {
yy: {
zz: {
}
}
}
Where 'xx', 'yy', 'zz' are seperate collections. and i have mapped xx > yy >> zz using keys.
xx: {
KEY: "123"
}
YY: {
xx_Key : "123",
KEY : "456"
}
zz: {
yy_key: "456",
KEY: "789"
}
1, The question is how can I make these 3 tables into one table, but need to do every operation on each 'xx', 'yy', 'zz'. Since the dynamoDB only allows GSI in top-level. So how can I do CRUD ops on these?
2, Another approach is, storing datas as "one to one". So i can get XX, YY, ZZ in the top-level domain, But will it increases the data redundancy? Basically the changed data will be,
Entry1: {
XX: "123",
YY:"456",
ZZ: "789"
}
Entry2: {
XX: "123",
YY:"456",
ZZ: "790" //Change in value here. But same xx & yy repeated.
}
So basically what how should i do that?
Upvotes: 3
Views: 75
Reputation: 547
Another approach is, storing datas as "one to one". So i can get XX, YY, ZZ in the top-level domain, But will it increases the data redundancy?
Yes it will increase data redundancy which will add to storage cost but it should not be major concern unless the duplicated data is significant as compared to the size of the document.
Concept of normalization with NoSQL should be dealt with carefully as JOINs are mostly not supported thereby leading to increased query latency.
I found this blog useful when designing DynamoDB table structure. Quoting the gist(which is actually the blog's conclusion) of the blog here:
There is no one-size-fits-all guideline for deciding on a normalization strategy. This is especially true if you are migrating an application from a relational database. Many of the assumptions you make for a relational schema design do not apply in a NoSQL database like DynamoDB.
In the end, the schema you choose depends primarily on the access patterns for your applications and the size of the data items.
Upvotes: 1