How is it possible that DynamoDB can create a global secondary index comprising of a partition key (and sort key) that not all items in the table share? I'm not able to put an item into a table that doesn't have the proper primary key structure, so it doesn't make sense to me that I can create a GSI using an attribute as the partition key that not all items in the table have.
Let's say I have a table with 10 items. 5 items are users. 2 items are the products I sell. The 3 remaining items are orders that have been created.
Let's also say the attempt at approaching this NoSQL style was whole-hearted and half-understood, leaving us with these items and their corresponding attributes -
user items: id, email, phone, address, first_name, last_name
product items: id, description, title, price
order items: id, user_id, product_id, quantity, creation_date
The partition key of this table is id
.
Then, when I try to create a GSI using creation_date
as the partition key, it lets me... can someone explain why this works to me?