Setting up the cycling keyspace

CQL commands to set up the cycling keyspace for examples used in this documenation.

Use the replication factor that is appropriate for your environment. The following assumes that the Astra DB Serverless deployment is a single node cluster in a development environment.

Update the following command and create a CQL file named keyspace-create-simple.cql in the same directory where you launch cqlsh.

CREATE KEYSPACE IF NOT EXISTS cycling
WITH REPLICATION = {
  'class' : 'SimpleStrategy',
  'replication_factor' : 1
};

Additional cycling keyspace examples

Create a keyspace with a network topology strategy

CREATE KEYSPACE cycling 
WITH REPLICATION = { 
  'class' : 'NetworkTopologyStrategy', 
  'datacenter1' : 1
};

Create a keyspace with multiple data centers

CREATE KEYSPACE IF NOT EXISTS cycling
WITH REPLICATION = {
  'class' : 'NetworkTopologyStrategy',
  'datacenter1': '3', 
  'datacenter2': '3'
};

Create a keyspace with multiple named data centers

-- previously tag::multi
// tag::keyspace-create-Cycling[]
CREATE KEYSPACE "Cycling"
WITH REPLICATION = {
  'class' : 'NetworkTopologyStrategy', 
  'boston'  : 3 , // Datacenter 1 
  'seattle' : 2 , // Datacenter 2
  'tokyo'   : 2   // Datacenter 3
};
// end::keyspace-create-Cycling[]

Create a keyspace with keyspace options

CREATE KEYSPACE cycling
WITH REPLICATION = { 
  'class' : 'NetworkTopologyStrategy',
  'datacenter1' : 3 
} 
AND DURABLE_WRITES = false;

User-defined types (UDTs)

User-defined type examples used in the CQL documentation.

basic_info

User-defined type that contains fields for basic information about a cyclist such as birthday, nationality, height, and weight.

basic_info_withTTL

User-defined type that contains fields for basic information about a cyclist such as birthday, nationality, height, and weight.

fullname

User-defined type that contains two fields for first name and last name.

race

User-defined type that contains three fields for a race name, date, and time.

User-defined functions (UDFs) and user-defined aggregates (UDAs)

User-defined functions and aggregates examples used in the CQL documentation.

Requires setting the https://docs.datastax.com/en/dse/6.8/dse-admin/datastax_enterprise/config/configCassandra_yaml.html#configCassandra_yamlenable_user_defined_functions[enable_user_defined_functions] and https://docs.datastax.com/en/dse/6.8/dse-admin/datastax_enterprise/config/configCassandra_yaml.html#configCassandra_yamlenable_scripted_user_defined_functions[enable_scripted_user_defined_functions] to true in the cassandra.yaml file.

flog

User-defined function.

left

Create a user-define function that trims row data from the left.

left

Create a user-define function that is an intermediate average state.

left

Create a user-define function that is a final average state.

Cycling user-defined aggregate team_average

Creates a Java user-defined aggregate function that calculates the average of a target column. Uses the average_state and average_final functions.

Tables

CQL commands that create cycling example tables and insert the corresponding data.


birthday_list

Example for maps and indexing search index map fields.

calendar

Using clustering columns to display data.

comments

Example for count, timestamps, limiting results by partition.

country_flag

Static data type examples.

cyclist_alt_stats

Removes the table and inserts data required for examples.

cyclist_base
cyclist_career_teams

Set data type example.

cyclist_category

Clustering column simple example with corresponding query.

cyclist_emails

Create and drop the cyclist emails table with its known ID.

cyclist_expenses

Empty table to demonstrate batches.

cyclist_id

Composite partition key examples.

cyclist_name

Simple single column partition key

cyclist_points

Select aggregated data using the built-in functions.

cyclist_races

Create user-defined type, insert data into UDT and time fields.

cyclist_sponsors

Races and race sponsors in collection types.

cyclist_stats

Using a UDT, inserting and updating data.

cyclist_teams

Map data type example.

events

Uses month and date of cycling races to show how to get ranges that span clustering columns. Example of copying data from a CSV into the table.

popular_count

<what is it used for?>

race_sponsors

Races and race sponsors in collection types.

race_starts

Frozen list full index example.

race_times

Field times includes duration and time, and a multicolumn primary key.

race_winners

Using a user-defined type in a table and queries.

rank_by_year_and_name

Using a composite partition key and writing conditional statements (WHERE).

team_average

Partition key with two clustering columns. Shows use of aggregate and functions.

upcoming_calendar

Find all calendar events for a particular year and month.

Cycling Materialized Views

Create materialized views from cycling tables.

Materialized views (MVs)

Create materialized views from cycling tables.


cyclist_by_age-mv

Supports queries by age without an index or allow filtering.

SASI indexes

Experimental secondary index.


Index on cyclist_name

Create an experimental secondary index.

Search indexes

Search index examples using the cycling tables.


comments search index

Modifying the configuration and schema on the comments table search index.

Search index examples

CQL description of keyspaces, tables and other database resources used in CQL search index examples.


Setting up the Cycling keyspace

CQL commands to set up the cycling keyspace and examples used in this guide.

Search index examples

Step-by-step tutorials with sample keyspaces, tables, and data that demonstrate DSE Search index functionality.

Search index examples

Use these step-by-step tutorials with sample keyspaces, tables, and data to learn how to setup and use DSE Search index functionality.

Useful external resources:

  • Tutorial how to index and query geospatial Polygons and MultiPolygons.

  • Docker container for running Silk on DSE Search.


Creating a demo keyspace for tutorials

Step-by-step instructions to create a keyspace for tutorials found in this section.

Multi-faceted search using healthcare data

Create and alter search indexes using CQL index management commands.

Quick Start for CQL index management

Example for creating and altering search indexes using CQL index management commands.

Term and phrase searches using the wikipedia demo

Set up the Wikipedia demo, keyspace, table, and data and run queries on terms in article titles and bodies.

Indexing and querying polygons

:leveloffset!:

Queries

Querying the cycling keyspace tables.


Aggregating cycling data

Using native aggregate functions.

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com