Creating a schema in DataStax Studio

Create a schema to give your graph a structure.

To create a schema, execute Gremlin code in a Gremlin cell in your notebook. The schema used in this example represents users and products and their relationships to one another.

  1. Add a code cell to your notebook.

  2. Write code to create a schema:

    1. Drop the schema if it exists.


      When creating a notebook, some variables are created by default (if none exist) for you to access in code cells. For example, a graph (graph), a graph traversal (g), and a schema (schema). The graph variable is set to an empty graph with the name that you previously provided in the notebook’s connection.

    2. Create the property keys for the schema.


      The id and name property keys are used by both the user and the product vertices. The role property key is only used by the user vertex.

    3. Create the vertex labels for user and product.

    4. Create the edge label for use between the user and product vertices.

  3. Execute the code by selecting Run Cell.

    You have created the schema for the example.

  4. View the resulting schema by selecting Schema in the upper-right-hand corner of the notebook.


The schema you created in this task is based on the following data model:


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,