= Cassandra Quickstart 

== STEP 1: GET CASSANDRA USING DOCKER

You'll need to have Docker Desktop for Mac, Docker Desktop for Windows, or similar software installed on your computer.

Apache Cassandra is also available as a tarball or package xref:_/download.adoc[download].

[source, console]
----
include::cassandra:example$BASH/docker_pull.sh[]
----

== STEP 2: START CASSANDRA

A Docker network allows us to access the container's ports without exposing them on the host.

[source, console]
----
include::cassandra:example$BASH/docker-network-run.sh[]
----

== STEP 3: CREATE FILES

The Cassandra Query Language (CQL) is very similar to SQL but suited for the JOINless structure of Cassandra.

Create a file named data.cql and paste the following CQL script in it. This script will create a keyspace, the layer at which Cassandra replicates its data, a table to hold the data, and insert some data into that table:

[source, cql]
----
include::cassandra:example$CQL/create-keyspace-store.cql[]

include::cassandra:example$CQL/create-table-shopping-cart.cql[]

include::cassandra:example$CQL/insert-shopping-cart-data.cql[]
----

== STEP 4: LOAD DATA WITH CQLSH

The CQL shell, or `cqlsh`, is one tool to use in interacting with the database. 
We'll use it to load some data into the database using the script you just saved.

[source, console]
----
include::cassandra:example$BASH/docker-run-cqlsh-load-data.sh[] 
----

[NOTE]
====
The cassandra server itself (the first docker run command you ran) takes a few seconds to start up. 
The above command will throw an error if the server hasn't finished its init sequence yet, so give it a few seconds to spin up.
====

== STEP 5: INTERACTIVE CQLSH

Much like an SQL shell, you can also of course use `cqlsh` to run CQL commands interactively.

[source, console]
----
include::cassandra:example$BASH/docker-run-cqlsh-quickstart.sh[]
----

This should get you a prompt like so:

[source, console]
----
include::cassandra:example$RESULTS/docker-run-cqlsh-quickstart.result[]
----

== STEP 6: READ SOME DATA

[source, cql]
----
include::cassandra:example$CQL/select-data-from-shopping-cart.cql[]  
----

== STEP 7: WRITE SOME MORE DATA

[source, cql]
----
include::cassandra:example$CQL/insert-more-data-shopping-cart.cql[]
----

== STEP 8: CLEAN UP

[source, console]
----
include::cassandra:example$BASH/docker-kill-and-remove.sh[]
----

== CONGRATULATIONS!

Hey, that wasn't so hard, was it?

To learn more, we suggest the following next steps:

* Read through the xref:master@_:ROOT:cassandra-basics.adoc[Cassandra Basics] to learn main concepts and how Cassandra works at a high level.
* Browse through the xref:master@_:ROOT:case-studies.adoc[Case Studies] to learn how other users in our worldwide community are getting value out of Cassandra.




