Quick Start

Get started with NenDB in minutes. This guide will walk you through installation, basic setup, and your first graph operations using batch processing.

!

Prerequisites

Zig version 0.15.1 or higher is required. Make sure you have an updated version of Zig installed. Run zig version to check your current version.

1

Install NenDB

Install NenDB using our simple installation script:

Terminal
curl -sSL https://install.nendb.co | bash

Add NenDB to your PATH

For Unix systems (macOS, Linux):

echo 'export PATH="$HOME/.local/bin:$PATH"' >> "$HOME/.zshrc"
source ~/.zshrc

Verify Installation

To verify that NenDB is installed correctly:

nendb --version
2

Setup Your First Database

Initialize a New Project

Create a new NenDB project directory and initialize it:

nendb init --path my-graph-db
cd my-graph-db

Configure Your Schema

Define your graph schema in the schema.nen file:

schema.nen
// Define node types
node User {
  id: u64,
  name: string,
  email: string,
  created_at: timestamp
}

node Post {
  id: u64,
  title: string,
  content: string,
  created_at: timestamp
}

// Define relationships
edge Follows {
  from: User,
  to: User,
  since: timestamp
}

edge Authored {
  from: User,
  to: Post,
  created_at: timestamp
}
3

Start the Database

Start your NenDB instance with the TCP server:

nendb start --port 6969

Success!

If you see "NenDB TCP server listening on port 6969", you're ready to run operations!

4

Perform Your First Operations

Connect to NenDB

Open a new terminal and connect using the CLI client:

nendb client --host localhost --port 6969

Create Nodes (Batch Operation)

Create multiple users in a single batch for optimal performance:

BATCH_CREATE_NODES User [
  { id: 1, name: "Alice", email: "alice@example.com" },
  { id: 2, name: "Bob", email: "bob@example.com" },
  { id: 3, name: "Charlie", email: "charlie@example.com" }
]

Create Relationships

Establish relationships between users:

BATCH_CREATE_EDGES Follows [
  { from: 1, to: 2, since: "2024-01-01T00:00:00Z" },
  { from: 2, to: 3, since: "2024-01-02T00:00:00Z" }
]

Query the Graph

Find all users that Alice follows:

TRAVERSE FROM User(1) FOLLOW Follows LIMIT 10

Next Steps

Learn Batch Processing

Understand how to maximize throughput with NenDB's batch operations and data-oriented design.

Batch Processing Guide →

Explore the Architecture

Deep dive into NenDB's data-oriented design and static memory allocation principles.

Architecture Guide →

API Reference

Complete API documentation for all NenDB operations, query language, and TCP protocol.

API Documentation →

Performance Optimization

Learn advanced techniques for optimizing your graph queries and batch operations.

Performance Guide →

Was this page helpful?