Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples of how to Implement counter columns? #7

Closed
dan-mi-sun opened this issue May 16, 2016 · 2 comments
Closed

Examples of how to Implement counter columns? #7

dan-mi-sun opened this issue May 16, 2016 · 2 comments

Comments

@dan-mi-sun
Copy link

dan-mi-sun commented May 16, 2016

This is an extension to this question:

http://stackoverflow.com/questions/37236128/how-to-increment-cassandra-counter-column-with-phantom-dsl

This question has also been asked here.

In Thiagos example the two tables; 'songs' & 'songs_by_artist' both have the same rows but with different partitions (primary keys / clustering columns)

CREATE TABLE test.songs (
    song_id timeuuid PRIMARY KEY,
    album text,
    artist text,
    title text
);

CREATE TABLE test.songs_by_artist (
    artist text,
    song_id timeuuid,
    album text,
    title text,
    PRIMARY KEY (artist, song_id)
) WITH CLUSTERING ORDER BY (song_id ASC);

This means inserting, updating and deleting across both tables within the SongsService works with the same base data / rows.

How would you for example have a table such as 'artist_songs_counts', with columns 'song_id' (K) and 'num_songs' (++) and ensure that 'SongsService' adds corresponding row to each table; 'songs' & 'songs_by_artist' & 'artist_songs_counts' (where there are different numbers of row but information should be linked, such as the artist info).

CREATE TABLE test.artist_songs_counts (
    artist text PRIMARY KEY,
    num_songs counter);
@iamthiago
Copy link
Owner

I have answered your question on SO http://stackoverflow.com/questions/37245031/how-to-implement-cassandra-counter-columns-with-phantom-dsl/37256783#37256783 take a look and if that fits what you need, please close this issue.

@dan-mi-sun
Copy link
Author

thanks @thiagoandrade6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants