CassandraAbout the TutorialCassandra is a distributed database from Apache that is highly scalable and designed tomanage very large amounts of structured data. It provides high availability with no singlepoint of failure.The tutorial starts off with a basic introduction of Cassandra followed by its architecture,installation, and important classes and interfaces. Thereafter, it proceeds to cover how toperform operations such as create, alter, update, and delete on keyspaces, tables, andindexes using CQLSH as well as Java API. The tutorial also has dedicated chapters toexplain the data types and collections available in CQL and how to make use of userdefined data types.AudienceThis tutorial will be extremely useful for software professionals in particular who aspire tolearn the ropes of Cassandra and implement it in practice.PrerequisitesIt is an elementary tutorial and you can easily understand the concepts explained herewith a basic knowledge of Java programming. However, it will help if you have some priorexposure to database concepts and any of the Linux flavors.Copyright & Disclaimer Copyright 2015 by Tutorials Point (I) Pvt. Ltd.All the content and graphics published in this e-book are the property of Tutorials Point (I)Pvt. Ltd. The user of this e-book is prohibited to reuse, retain, copy, distribute or republishany contents or a part of contents of this e-book in any manner without written consentof the publisher.We strive to update the contents of our website and tutorials as timely and as precisely aspossible, however, the contents may contain inaccuracies or errors. Tutorials Point (I) Pvt.Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of ourwebsite or its contents including this tutorial. If you discover any errors on our website orin this tutorial, please notify us at [email protected]
CassandraTable of ContentsAbout the Tutorial . iAudience . iPrerequisites . iCopyright & Disclaimer . iTable of Contents . iiPART 1: CASSANDRA BASICS . 11.Introduction . 2NoSQL Database . 2NoSQL vs. Relational Database . 2What is Apache Cassandra? . 3Features of Cassandra . 3History of Cassandra . 42.Architecture . 5Data Replication in Cassandra . 5Components of Cassandra . 6Cassandra Query Language . 73.Data Model . 8Cluster . 8Data Models of Cassandra and RDBMS . 114.Installation . 12Pre-Installation Setup . 12Download Cassandra . 15Configure Cassandra . 15Start Cassandra . 16Programming Environment . 16Eclipse Environment . 17Maven Dependencies . 185.Referenced API . 21Cluster . 21Cluster.Builder . 21Session . 216.Cassandra cqlsh . 23Starting cqlsh . 23Cqlsh Commands . 247.Shell Commands . 26HELP . 26CAPTURE . 26CONSISTENCY . 27COPY . 27DESCRIBE . 28DESCRIBE TYPE . 29DESCRIBE TYPES . 30ii
CassandraExpand . 30EXIT . 31SHOW . 32SOURCE. 32PART 2: KEYSPACE OPERATIONS . 338.Create KeySpace . 34Creating a Keyspace. 34Replication . 34Durable writes . 35Using a Keyspace . 36Creating a Keyspace using Java API . 369.Alter KeySpace . 40Altering a KeySpace . 40Replication . 40Durable writes . 40Altering a KeySpace using Java API . 4210. Drop KeySpace . 45Dropping a KeySpace . 45Dropping a KeySpace using Java API . 45PART 3: TABLE OPERATIONS . 4811. Create Table . 49Create a Table . 49Creating a Table using Java API . 5112. Alter Table . 54Altering a Table. 54Adding a Column . 54Dropping a Column . 55Altering a Table using Java API . 55Deleting a Column . 5813. Drop Table . 59Dropping a Table . 59Deleting a Table using Java API . 5914. Truncate Table . 62Truncating a Table . 62Truncating a Table using Java API .