Skip to content

Latest commit

 

History

History
104 lines (86 loc) · 3.1 KB

step3-astra.md

File metadata and controls

104 lines (86 loc) · 3.1 KB
Bulk Loading Large Datasets into Apache Cassandra® ℹ️ For technical support, please contact us via email or LinkedIn.
⬅️ Back Step 3 of 7 Next ➡️
Connect to Astra DB and create a database

✅ Create an application token with the Database Administrator role to access Astra DB. Skip this step is you already have a token.

You can reuse the same token in our other labs, too.

✅ Setup Astra CLI by providing your application token:

astra setup

✅ List your existing Astra DB databases:

astra db list

✅ Create database cassandra-fundamentals and keyspace ks_bulk_loading if they do not exist:

astra db create cassandra-fundamentals -k ks_bulk_loading --if-not-exist --wait

This operation may take a bit longer when creating a new database or resuming an existing hibernated database.

✅ Verify that database cassandra-fundamentals is ACTIVE and keyspace ks_bulk_loading exists:

astra db get cassandra-fundamentals

✅ Create the tables:

astra db cqlsh cassandra-fundamentals -k ks_bulk_loading -e "

CREATE TABLE IF NOT EXISTS users (
  id TEXT,
  gender TEXT,
  age INT,
  PRIMARY KEY ((id))
);

CREATE TABLE IF NOT EXISTS movies (
  id TEXT,
  title TEXT,
  year INT,
  duration INT,
  country TEXT,
  PRIMARY KEY ((id))
);

CREATE TABLE IF NOT EXISTS ratings_by_user (
  user_id TEXT,
  movie_id TEXT,
  rating INT,
  PRIMARY KEY ((user_id), movie_id)
);

CREATE TABLE IF NOT EXISTS ratings_by_movie (
  movie_id TEXT,
  user_id TEXT,
  rating INT,
  PRIMARY KEY ((movie_id), user_id)
);"

✅ Verify that the four tables have been created:

astra db cqlsh cassandra-fundamentals -k ks_bulk_loading -e "DESCRIBE TABLES;"
⬅️ Back Next ➡️