Skip to main content

Demo data

To quickly test out SurrealDB and SurrealQL functionality, we've included demo data here in .surql files which you can download and import into SurrealDB using the CLI

Surreal Deal - deals so good it's surreal!

Surreal Deal is a demo dataset based on a simplified e-commerce platform that sells artwork. The dataset is made up of 8 tables using both graph relations and record links: person, order, product, review, artist, create, avg_product_review, daily_sales.

In the diagram below, the nodes in pink are the standard tables, the ones in purple represent the edge tables which shows relationships between records and SurrealDB as a graph database. While the nodes in gray are the pre-computed table views.

Download

DatasetURL
Surreal Dealhttps://datasets.surrealdb.com/surreal-deal-v2.surql
Surreal Deal (mini)https://datasets.surrealdb.com/surreal-deal-mini-v2.surql

Import

First, download any of the available datasets.

Secondly, start the server.

# Create a new in-memory server
surreal start --user root --pass root --allow-all

Lastly, use the import command to add the dataset.

Use the command below to import the surreal deal dataset:

surreal import --conn http://localhost:8000 --user root --pass root --ns test --db test surreal-deal-v2.surql

To import the surreal downloaded the Surreal Deal (mini) use the command below:

surreal import --conn http://localhost:8000 --user root --pass root --ns test --db test surreal-deal-mini-v2.surql

Please be aware that the import process might take a few seconds.

Using Curl

First, start the surrealdb server

# Create a new in-memory server
surreal start --user root --pass root --allow-all

Then, download the file and load it into the database

# Download the file
curl -L "https://datasets.surrealdb.com/surreal-deal-v2.surql" -o surreal-deal-v2.surql

# Load the file into the database using the rest endpoint
curl -v -X POST -u "root:root" -H "NS: test" -H "DB: test" -H "Accept: application/json" --data-binary @surreal-deal-v2.surql http://localhost:8000/import

If you want to use the mini version:

# Download the file
curl -L "https://datasets.surrealdb.com/surreal-deal-mini-v2.surql" -o surreal-deal-mini-v2.surql

# Load the file into the database using the rest endpoint
curl -v -X POST -u "root:root" -H "NS: test" -H "DB: test" -H "Accept: application/json" --data-binary @surreal-deal-mini-v2.surql http://localhost:8000/import

Sample queries

-- Using record links to select from the person and product table
SELECT
rating,
person.name,
product.name AS product_name
FROM review;

-- Using graph relations to select from the person and product table
SELECT
order_date,
product_name,
<-person.name as person_name,
->product.description
FROM order;

-- Conditional filtering based on an embedded object property.
SELECT
name,
email
FROM person
WHERE address.country = "England";

-- Conditional filtering using record links.
SELECT * FROM review
WHERE product.category = "charcoal";

-- Count orders based on order status
SELECT count() FROM order
WHERE order_status IN ["delivered", "processing", "shipped"]
GROUP ALL;

-- Get a deduplicated list of products that were ordered
SELECT
array::distinct(product_name) as ordered_products
FROM order
GROUP ALL;

-- Get the average price per product category
SELECT
->product.category AS product_category,
math::mean(price) AS avg_price
FROM order
GROUP BY product_category
ORDER BY avg_price DESC;

-- Using V2 dataset above - encapsulating logic in a function
RETURN fn::number_of_unfulfilled_orders();

-- Using V2 dataset above - using a custom fuction for currency conversion
SELECT
product_name,
fn::pound_to_usd(price) AS price_usd
FROM order