Illustration Image

How to properly create a table for user messages?

I have a table with user channels in the Apache Cassandra database. And queries responsible for getting the list of channels and getting data about the channel. One of the queries requires ALLOW FILTERING, we think that the best option is to make a duplicate of the table, only it will have a primary key ((channel_id, bucket), user_id), and then the question arose, is there something like links in Apache Cassandra, so that the database does not have to constantly write and update data in both tables. If you know a solution where this does not need to be done, then I will be very grateful for the solution

create table channels
(
    user_id     bigint,
    bucket      int,
    channel_id  bigint,
    flags       int,
    permissions bigint,
    type        int,
    primary key ((user_id, bucket), channel_id)
)
SELECT * FROM channels WHERE user_id = :user_id AND bucket = :bucket
SELECT * FROM channels WHERE channel_id = :channel_id ALLOW FILTERING
Become part of our
growing community!
Welcome to Planet Cassandra, a community for Apache Cassandra®! We're a passionate and dedicated group of users, developers, and enthusiasts who are working together to make Cassandra the best it can be. Whether you're just getting started with Cassandra or you're an experienced user, there's a place for you in our community.
A dinosaur
Planet Cassandra is a service for the Apache Cassandra® user community to share with each other. From tutorials and guides, to discussions and updates, we're here to help you get the most out of Cassandra. Connect with us and become part of our growing community today.
© 2009-2023 The Apache Software Foundation under the terms of the Apache License 2.0. Apache, the Apache feather logo, Apache Cassandra, Cassandra, and the Cassandra logo, are either registered trademarks or trademarks of The Apache Software Foundation. Sponsored by Anant Corporation and Datastax, and Developed by Anant Corporation.

Get Involved with Planet Cassandra!

We believe that the power of the Planet Cassandra community lies in the contributions of its members. Do you have content, articles, videos, or use cases you want to share with the world?