Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to assign foreignkey in DynamoDB?

I'm trying to use the Dynamo DB. I am trying to test the Dynamo DB Tables But I can't Get Foreign Key in this.

like image 610
Vishal Maitry Avatar asked Feb 10 '15 12:02

Vishal Maitry


People also ask

What is PK and SK in DynamoDB?

The partition key of these entity items is the attribute that uniquely identifies the item and is referred to generically on all items as PK . The sort key attribute contains an attribute value that you can use for an inverted index or global secondary index. It is generically referred to as SK .

How do I connect two tables in DynamoDB?

In a relational database, there's essentially one way to do this—using a foreign key in one table to refer to a record in another table and using a SQL join at query time to combine the two tables. There are no joins in DynamoDB.

Can we store relational data in DynamoDB?

Traditional relational database management system (RDBMS) platforms store data in a normalized relational structure. This structure reduces hierarchical data structures to a set of common elements that are stored across multiple tables.

Can we have two sort keys in DynamoDB?

4. How many sort keys can DynamoDB have? There should only be one sort key defined per table. But, it can be composed using multiple columns.


2 Answers

DynamoDB does not have foreign keys. It is a NoSQL database that doesn't support that kind of relational data. There is no data integrity maintained between tables, so this sort of behavior is not built in. If you want to have this sort of behavior, you will have to model your data storage in DynamoDB a different way.

From the FAQ explaining that it is not a relational database:

While Amazon DynamoDB tackles the core problems of database scalability, management, performance, and reliability, it does not have all the functionality of a relational database. It does not support complex relational queries (e.g. joins) or complex transactions. If your workload requires this functionality, or you are looking for compatibility with an existing relational engine, you may wish to run a relational engine on Amazon RDS or Amazon EC2. While relational database engines provide robust features and functionality, scaling a workload beyond a single relational database instance is highly complex and requires significant time and expertise.

like image 86
mkobit Avatar answered Oct 25 '22 00:10

mkobit


Dynomodb does not have foreign keys. Dynomodb is non-relational database, but it contains tables .

like image 30
anoja madusanka Avatar answered Oct 25 '22 01:10

anoja madusanka