Global Secondary Index
Understand GSI with an example.
We'll cover the following
Example scenario
Imagine that we are creating a database for songs. We choose “Artist” as the partition key and “Song_title” as the sort key. The other attributes in the table are “Album”, “Genre”, and “Year”.
The envisioned database will look like this:
Artist | Song | Album | Genre | Year |
---|---|---|---|---|
Pink Floyd | Comfortably Numb | The Wall | Progressive rock | 1979 |
Pink Floyd | Mother | The Wall | Progressive rock | 1979 |
The Beatles | Glass Onion | The Beatles | Psychedelic rock | 1968 |
The Beatles | Hey Jude | 1 | Pop rock | 2000 |
Metallica | Atlas, Rise! | Hardwired… to self-destruct | Metal | 2016 |
From this database, we can easily get all the songs by a given “Artist”. For example, we can get a playlist of all the songs by “Pink Floyd”, with the use of the following command:
Get hands-on with 1400+ tech skills courses.