Hi Team,
I am quite new to Cassandra database. I have a question related to use of cassandra.
Table structure looks like below :-
- Table Name :- Product Details.
- ProductFamily Text,
- AccessGroup Text,
- ProductDetails Map<text,text>
- ((ProductFamily), AccessGroup) PRIMARY Key
Data Relation: For 1 Product family we have multiple Access Groups and each access group has product details in Map <ProductId, Details>. It is quite possible 1 product detail is present in all the access groups or some of the access groups.
Scenario: We receive a delete event with ProductId and product family only.
Our implementation:
- Fetch all access group of the product family from the database.
- For each access group, hit database to get the map, then we are checking whether it has specific productid as map key.
- If yes, then hold that accessgroup -> productid (key,value) pair in memory.
- In the end, prepare batch statement to delete all the product ids for the access group because our partition key is same.
Note: Max. we have 15-20 items in a map and 8-10 access groups with a product family.
Questions:
- Could you please let me know whether am I following right approach for batch deletion ?
- If we receive thousands of such events in a day whether this approach is performant ?
Thanks in advance.
Update:
Our requirement is like this. For each product family and access group fetch all the product details from the system. e.g when customer selects specific product family in the web page we can check the access group of that customer and on that basis we will display the product details. (Read model)
Note : It might possible same product detail is present for different access group but for same product family.
Write Model :-
Our application is completely event based system. We are receiving following messages :-
1. When a product detail is added for a product family.
Note :- In this scenario, need to read access groups first from cassandra db to upsert the product detail for all access groups.
2. When a product detail is added to a specific access group.
3. When a product detail is removed for product family. In this case, it creates tombstones.
Can you please share some design alternatives.
Thanks in advance.