Circuit design for cassandra

I am working on a forum project that allows the user to ask questions on specific topics from his network.

A custom news feed contains only those questions that were posted by its connections and tagged on the following topics. I am confused about which datamodel database would be most suitable for such an application. At the moment I am looking at Cassandra and MySQL solutions.

After my study of Cassandra, I realized that a simple news design that shows all the messages from the network would be easy to design using Cassandra, making a quick record to all subscribers of the user about the recording from the user. But for my application, where there is an additional filter for “follow-up topics,” I could not convince myself of the good design of the circuit in Kassandra. I hope if I miss something because of my brief understanding of cassandra, maybe you can help me with your suggestions on how this news feed can be implemented in Kassandra?

+4
source share
1 answer

I assume that you have already studied the Twissandra sample application. This is very close to what you are describing. Here are some useful links:

The main difference between your application is the introduction of themes. How you store the data depends on how exactly you want to request it. For example, you may be aware of all the topics presented on the same timeline, or you may want to see the timeline only for a specific topic (for example, SO tags).

If you do not need a separate time frame, I recommend the following, using the Twissandra database as a base:

Instead of the usual FOLLOWERS column family, maintain one row of followers for each user for each topic. Obviously, this creates a little extra work when creating / modifying / deleting users, but it saves your work when creating new messages, which is the main part of the operations you need to handle.

When a message is created by user Joe on topics A, B and C, you can get all interested users with a request of the type:

multiget(FOLLOWERS, ['Joe::A', 'Joe::B', 'Joe::C']) 

where "Joe :: A", "Joe :: B" and "Joe :: C" are strings. For each of the followers you return, you can simply add a UUID message as a column name to each follower timeline (and you won’t have to worry about duplicates in the timeline, since you are using the same UUID for the column name).

If you want to maintain a chronology for each topic for each user, I suggest you use one line for each topic that interests the user, and one line for the timeline of all topics. Since you already receive subscribers by topic, it is easy to find out what topic (s) this publication has, what interested participants are interested in, to add a message to the correct time frame for the topics.

+4
source

Source: https://habr.com/ru/post/1334827/


All Articles