0
votes

According to "CQL for Cassandra 2.x Documentation", the author for storing a playlist, creates table as follows:

CREATE TABLE songs ( id uuid PRIMARY KEY, title text, album text, artist text, data blob )

CREATE TABLE playlists ( id uuid, song_order int, song_id uuid, title text, album text, artist text, PRIMARY KEY (id, song_order ) );

But how does he get song_id? Does the app read the songs table to get the id and use that in this table when doing an insert? (I am trying to learn cassandra and all the examples on the net talks about having different tables to satisfy my query but no where they mention how should I take care of inserting the same data in all tables at a time).

Regards, Seenu.

1

1 Answers

0
votes

I'd imagine the app doing the insert would already know the song id. Think about the use case - a use is adding a song to a playlist. Think about the interface - the user searches for songs and these are displayed in some form of list view. The user selects a song to add to a play list. At that point, the app knows the id of the song. The apps puts the selected song into the appropriate slot in the playlist (I imagine that's where song_order comes in).