gsql/ GSQL 101 Tutorial
Last Updated: October 20, 2018A 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:
PersontoPerson - 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:
gsqlterminalGSQL > DROP ALL
3. Data Setup
Imagine two CSV files:
person.csv
csvterminalname,gender,age,state Tom,male,40,ca Dan,male,34,ny Jenny,female,25,tx
friendship.csv
csvterminalperson1,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).quitorexit: Exit the GSQL shell.help: Display a summary of available commands.
Next Steps
Once your environment is ready, the typical workflow follows this sequence:
- Define the Schema: Create vertex and edge types.
- Define the Graph: Group types into a graph container.
- Load Data: Map CSV files to the schema.
- Query: Write logic to analyze the data.
On this page
TigerGraph Book
v1.0 Curated