Skip to content

Create a schema

To bulk import data into Nebula Graph, you must have a schema. You can create a schema with the Console module or the Schema module of Studio.

NOTE: You can use nebula-console to create a schema. For more information, see Deploy Nebula Graph with Docker Compose and Get started with Nebula Graph.


To create a schema on Studio, you must do a check of these:

  • Studio is connected to Nebula Graph.
  • Your account has the privileges of GOD, ADMIN, or DBA. For more information, see Nebula Graph roles.
  • The schema is designed.
  • A graph space is created.

    NOTE: If no graph space exists, and your account has GOD privileges, you can create a graph space on the Console or Schema page.

Create a schema with Schema

To create a schema on the Schema page, make sure that the version of Studio is v1.2.1-beta or later then follow these steps:

  1. Create tags. For more information, see Operate tags.
  2. Create edge types. For more information, see Operate edge types.

Create a schema with Console

To create a schema on the Console page, follow these steps:

  1. In the toolbar, click the Console tab.
  2. In the Current Graph Space field, choose a graph space name. In this example, mooc_actions is used.

    Choose a graph space name for the Current Graph Space field

  3. In the input box, enter these statements one by one and click the button Icon of Run.

-- To create a tag named "user", with one property
nebula> CREATE TAG user (userId int);

-- To create a tag named "course", with two properties
nebula> CREATE TAG course (courseId int, courseName string);

-- To create an edge type named "action", with seven properties
nebula> CREATE EDGE action (actionId int, duration double, label bool, \
feature0 double, feature1 double, feature2 double, feature3 double);

If the preceding statements are executed successfully, the schema is created. You can run the statements as follows to view the schema.

 -- To list all the tags in the current graph space
nebula> SHOW TAGS;

-- To list all the edge types in the current graph space
nebula> SHOW EDGES;

-- To view the definition of the tags and edge types
nebula> DESCRIBE TAG user;
nebula> DESCRIBE TAG course;
nebula> DESCRIBE EDGE action;

If the schema is created successfully, in the result window, you can see the definition of the tags and edge types. For example, this figure shows the result of the DESCRIBE EDGE action statement.

The result window shows the definition of the action edge

Next to do

When a schema is created, you can import data.

Last update: April 15, 2021