Composite Primary Key Flashcards
DynamoDB - Composite Primary Key
How a Primary Key with a Partition and Sort Key Chooses Which Partition
New Data Example
Alien: Romulan
Example sentence
Primary Key Structure
Partition Key: Alien
• 1 to 255 characters, case sensitive
Sort Key: Name (optional)
• 1 to 255 characters, case sensitive
Important Points
The combination of Partition Key and Sort Key must be unique.
DynamoDB’s Internal Hash Function is a secret, and we have no idea how the algorithm decides which partition to write data
Partition Distribution
Partition A:
• Alien: Cardassian, Name: Dukat
• Alien: Cardassian, Name: Dumar
Partition B:
• Alien: Klingon, Name: Worf
• Alien: Klingon, Name: Kor
Partition C:
• Alien: Romulan, Name: Tomalok
• Alien: Romulan, Name: Toreth
• Alien: Romulan, Name: Valdore
Key Concepts
When using a Sort Key, the records with the same Partition Key are kept together and sorted A-Z by the Sort Key
Key concept explanation