# Designing a Notifications table

**URL:** <https://forum.scylladb.com/t/designing-a-notifications-table/3223>\
**Category:** ScyllaDB\
**Tags:** counters, data-model\
**Created:** [November 23, 2024, 7:48am UTC](https://forum.scylladb.com/t/designing-a-notifications-table/3223 "2024-11-23T07:48:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![coratype](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.scylladb.com/coratype/32/1291_2.png) [@coratype](https://forum.scylladb.com/u/coratype)\
**Post date:** [November 23, 2024, 7:48am UTC](https://forum.scylladb.com/t/designing-a-notifications-table/3223/1 "2024-11-23T07:48:47Z")

</div>

i need basically a notification table, app is similar to slack in design, create a notification when a user posts a message to a channel, whenever somebody reacts to a message, follow, etc im having trouble grouping/batching notifications. if 100 people like a message, i dont want to create 100 rows, it would be more efficient to just send a number with the context, but im not sure how to do this because you cant use a counter in a non-counter table. any pointers?

---

<div class="post-metadata">

**Author:** ![felipemendes](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.scylladb.com/felipemendes/32/11_2.png) [@felipemendes](https://forum.scylladb.com/u/felipemendes)\
**Post date:** [December 9, 2024, 7:08pm UTC](https://forum.scylladb.com/t/designing-a-notifications-table/3223/2 "2024-12-09T19:08:26Z")

</div>

> but im not sure how to do this because you cant use a counter in a non-counter table. any pointers?

The answer is to denormalize, you hold the likes for posts under a single/separate table. Although, if I am following you correctly, a “Slack” type of app would allow for multiple different types of reactions. So rather than a likes table, why not a reactions\_by\_message where you store each reaction separately and then simply count to retrieve the grand total?

This could also work with UDTs/collections considering they don’t get too big.

---

<div class="post-metadata">

**Author:** ![coratype](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.scylladb.com/coratype/32/1291_2.png) [@coratype](https://forum.scylladb.com/u/coratype)\
**Post date:** [December 9, 2024, 10:19pm UTC](https://forum.scylladb.com/t/designing-a-notifications-table/3223/3 "2024-12-09T22:19:09Z")

</div>

wouldn’t this require a batch read though? i read that those are to be avoided generally. so say i pull 8 messages via a group\_chat\_id, thats just one query, but to now get the reaction counts for each reaction on the message, i have to extract each message\_id and do a batch read request

also ive gotten conflicting advice on this, ive also been told to just increment a count with LWT’s directly on the message

---

<div class="post-metadata">

**Author:** ![felipemendes](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.scylladb.com/felipemendes/32/11_2.png) [@felipemendes](https://forum.scylladb.com/u/felipemendes)\
**Post date:** [December 9, 2024, 10:39pm UTC](https://forum.scylladb.com/t/designing-a-notifications-table/3223/4 "2024-12-09T22:39:56Z")

</div>

You will probably pull messages within a specific timestamp, as a chat app is really a sliding window of event. That allows you to concurrently and efficiently avoid large partitions when a specific `group_chat_id` becomes popular or subject to spams.

If you use UDTs or collections to store the reactions along each message, then the job is done and you should have everything you need going forward.

If you decide to store it under a different table, you would probably also read the same `group_chat_id` and time-window, which would retrieve you the reactions for each message you stored upfront.

> also ive gotten conflicting advice on this, ive also been told to just increment a count with LWT’s directly on the message

Seems like an overkill for a chatapp which can tolerate eventual consistency - though I’d pick and choose whatever approach works best for the scale you’re after.

---

<div class="post-metadata">

**Author:** ![coratype](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.scylladb.com/coratype/32/1291_2.png) [@coratype](https://forum.scylladb.com/u/coratype)\
**Post date:** [December 10, 2024, 6:33pm UTC](https://forum.scylladb.com/t/designing-a-notifications-table/3223/5 "2024-12-10T18:33:19Z")

</div>

this was very helpful thank you for replying

on a side note what are your thoughts on batch reads in general? the idea of extracting relevant ids after querying one partition, and then using those ids to batch get another set of information from another partition? the most important thing ive noted so far is that ideally you should only every query one partition at a time
