This example demonstrates how to implement a robust user management system using Cassandra's ACID transaction capabilities. The example showcases managing user data across multiple tables while maintaining consistency and preventing duplicate email registrations.
The example implements:
- Primary user storage with UUID-based lookups
- Email-based user lookups
- Location-based user lookups
- Atomic updates across all tables
- Duplicate email prevention
- Docker installed on your system
- Basic understanding of CQL (Cassandra Query Language)
- Run the setup script:
./setup.sh
This will:
- Start a Cassandra container with Accord transactions enabled
- Create the necessary schema
- Load sample data
- Verify the setup
The example uses three tables:
users.user
: Primary user storageusers.user_by_email
: Email lookup indexusers.user_by_location
: Location-based lookup index
setup.sh
: Setup script for running the exampleschemas.cql
: Table definitionssample_data.cql
: Sample user dataqueries.cql
: Example transactional queries
After running setup.sh, you can:
- Query users by ID
- Look up users by email
- Find users by location
- Add new users atomically
Example query:
SELECT * FROM users.user_by_email WHERE email='[email protected]';
Have questions or want to learn more about Cassandra transactions? Check out the Github Discussions in the repository or...
Join our Discord community: https://discord.gg/GrRCajJqmQ