gsql/ GSQL 101 Tutorial
Last Updated: October 20, 2018

A beginner's guide to building a friendship social graph using GSQL.

GSQL 101: Your First Graph

This tutorial walks you through the core workflow of building a graph database: defining a schema, loading data, and running simple queries.

1. Concepts: Vertices and Edges

  • Vertex: At TigerGraph, we call data entities "vertices."
  • Edge: The connection between two vertices.
  • Schema: The blueprint that defines the types of vertices and edges in your graph.

The Friendship Social Graph

We will build a simple network where Person vertices are connected by Friendship edges.

Vertex (Person):

  • Attributes: id, gender, age, state

Edge (Friendship):

  • Connects: Person to Person
  • Attributes: connect_day

2. Preparing the Environment

Access the GSQL shell from your Linux terminal:

bashterminal
$ gsql GSQL >

If you are starting fresh, use DROP ALL to clear any existing schema or data:

gsqlterminal
GSQL > DROP ALL

3. Data Setup

Imagine two CSV files:

person.csv

csvterminal
name,gender,age,state Tom,male,40,ca Dan,male,34,ny Jenny,female,25,tx

friendship.csv

csvterminal
person1,person2,date Tom,Dan,2017-06-03 Tom,Jenny,2015-01-01

4. Basic Shell Commands

  • ls: List the current database catalog (vertices, edges, graphs, queries).
  • quit or exit: Exit the GSQL shell.
  • help: Display a summary of available commands.

Next Steps

Once your environment is ready, the typical workflow follows this sequence:

  1. Define the Schema: Create vertex and edge types.
  2. Define the Graph: Group types into a graph container.
  3. Load Data: Map CSV files to the schema.
  4. Query: Write logic to analyze the data.