Learning Apache Cassandra - Second Edition by Sandeep Yarabarla
Author:Sandeep Yarabarla [Yarabarla, Sandeep]
Language: eng
Format: azw3
Tags: COM021000 - COMPUTERS / Databases / General, COM018000 - COMPUTERS / Data Processing, COM021030 - COMPUTERS / Databases / Data Mining
Publisher: Packt Publishing
Published: 2017-04-25T04:00:00+00:00
The problem with concurrent updates
Let's add a new feature to our MyStatus application: the user's ability to star their friend's status updates to indicate their approval. For each status update, we'll store a list of the users who have starred that status update so that we can display the usernames to the author of the update.
Serializing the collection
One approach is to simply store the list of users in a text column in some serialized form. JSON is a versatile serialization format for such scenarios, so we'll use that. First, we'll add the column to the user_status_updates table, recalling the technique from the Adding columns to tables section in Chapter 7, Expanding Your Data Model:
ALTER TABLE "user_status_updates"
ADD "starred_by_users" text;
Simple enough. Now let's suppose that bob wants to star one of the status updates of alice. From the application's standpoint, this means appending bob to the list of users who have starred alice's update. First, we'll read the existing list:
SELECT "starred_by_users"
FROM "user_status_updates"
WHERE "username" = 'alice'
AND "id" = 76e7a4d0-e796-11e3-90ce-5f98e903bf02;
We see that there's currently no value in the starred_by_users column, which we can just interpret as an empty list:
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8308)
Azure Data and AI Architect Handbook by Olivier Mertens & Breght Van Baelen(6784)
Building Statistical Models in Python by Huy Hoang Nguyen & Paul N Adams & Stuart J Miller(6758)
Serverless Machine Learning with Amazon Redshift ML by Debu Panda & Phil Bates & Bhanu Pittampally & Sumeet Joshi(6644)
Data Wrangling on AWS by Navnit Shukla | Sankar M | Sam Palani(6431)
Driving Data Quality with Data Contracts by Andrew Jones(6371)
Machine Learning Model Serving Patterns and Best Practices by Md Johirul Islam(6132)
Learning SQL by Alan Beaulieu(6003)
Weapons of Math Destruction by Cathy O'Neil(5794)
Big Data Analysis with Python by Ivan Marin(5385)
Data Engineering with dbt by Roberto Zagni(4389)
Solidity Programming Essentials by Ritesh Modi(4038)
Time Series Analysis with Python Cookbook by Tarek A. Atwan(3897)
Pandas Cookbook by Theodore Petrou(3598)
Blockchain Basics by Daniel Drescher(3304)
Hands-On Machine Learning for Algorithmic Trading by Stefan Jansen(2914)
Feature Store for Machine Learning by Jayanth Kumar M J(2819)
Learn T-SQL Querying by Pam Lahoud & Pedro Lopes(2801)
Mastering Python for Finance by Unknown(2748)
