Getting Started

Start from real data

From a demo database to SQL + graph queries.

Load a ready-made database, connect to it, and run SQL, graph and hybrid queries.
Every query on this page runs as it is on the e-commerce demo database, and the results shown are what it returns.

Get CoraDB Download Load Connect SQL Graph Multi-hop Variable length Hybrid

  1. Step 1

    Get CoraDB

    CoraDB runs on 64-bit Linux; Windows and macOS are coming next.
    The evaluation version (installer or Docker image) is available on request.

    Prefer not to install anything yet?
    The built-in apps run in the browser and can connect to a hosted database that already has the demo data.

    Downloads Ask for access

    Linux 64-bit
    1 GB of memory or more
    2 GB of free disk space or more
    From the system requirements in the manual.
  2. Step 2

    Download the e-commerce demo database

    The e-commerce database models an online apparel and gear store. It is hybrid: customers, products, brands, suppliers, categories and cities are graph vertices linked by edges such as likes, follows and manufactures, while orders, order_items and countries are ordinary relational tables.

    The zip holds:

    • DDL.sql: the schema, with relational tables, vertex tables and edge tables
    • DML.sql: the data
    • Grant to public.sql: read access for every user
    • Demo queries.txt and Advanced queries.md: ready-to-run queries
    • README.md: what the database models
    • schema.png, schema.svg: the schema diagram

    Download e-commerce.zip 493 KB

    Schema diagram of the e-commerce demo database: vertex tables, edge tables and relational tables
  3. Step 3

    Create the database and load the data

    Unzip, create a database named e-commerce, start the CoraDB service and the database server, then run the three scripts in this order with corasql -i.

    % unzip e-commerce.zip && cd e-commerce
    % coradb createdb e-commerce en_US
    % coradb service start
    % coradb server start e-commerce
    % corasql -u dba -i DDL.sql e-commerce
    % corasql -u dba -i DML.sql e-commerce
    % corasql -u dba -i "Grant to public.sql" e-commerce
  4. Step 4

    Connect

    Connect with the corasql interpreter, with WebSQL or Magos in the browser, or from your own code through a driver. The connection details are the same everywhere: the broker listens on port 33000.

    Hostlocalhost
    Broker port33000
    Databasee-commerce
    Userdba (no password on a new database)

    In WebSQL, open Manage connections, add one with these details, then pick it from the connection list above the editor.

    WebSQL connected as dba to the e-commerce database on localhost:33000, with the object tree and a query result
    % corasql -u dba e-commerce
    The command-line interpreter: type a statement, end it with ; and press Enter.
    // npm install @coradb/node-coradb
    const CoraDB = require('@coradb/node-coradb');
    const conn = CoraDB.createConnection({
      host: 'localhost:33000', user: 'dba', password: '',
      database: 'e-commerce'
    });
    const { rows } = await conn.sql(
      'SELECT name FROM MATCH (p:product)-[:part_of]->(c:category) ' +
      'WHERE c.name = ?', ['Seafood']);
    await conn.close();
    // coradb-jdbc-1.0.0.jar on the classpath
    String url = "jdbc:coradb:localhost:33000:e-commerce:dba::";
    try (Connection conn = DriverManager.getConnection(url)) {
        // conn.prepareStatement(...) as with any JDBC driver
    }
  5. Step 5

    Your first SQL query

    The relational tables answer the usual questions with plain SQL.
    Here, the number of orders per year:

    ordersidcustomer_idorder_dateship_address…orders per yearorder_yearordersGROUP BY YEAR(order_date)
    -- How many orders were placed each year?
    SELECT YEAR(order_date) AS order_year, COUNT(*) AS orders
    FROM orders
    GROUP BY YEAR(order_date)
    ORDER BY order_year;
    relational table
    Result5 rows
    order_yearorders
    2021416
    2022482
    2023551
    2024675
    2025786
  6. Step 6

    Your first graph query

    A MATCH pattern in the FROM clause describes the path to find: from a customer, along a resides_in edge, to a city.

    customercuresides_incitycici.name = 'London'
    -- Which customers reside in the city of London?
    SELECT cu.company_name, cu.contact_name
    FROM MATCH (cu:customer)-[:resides_in]->(ci:city)
    WHERE ci.name = 'London';
    graph pattern (PGQL)
    Result35 rows, first 5 shown
    company_namecontact_name
    Bradford-BrownAlexander Fuller
    Thompson, Hart and TorresMichael Johnson
    Blanchard-PhelpsAmanda Bell
    Jones-BoydGregory Burgess
    Brown, Lambert and WellsJoshua Stone
  7. Step 7

    Follow several relationships

    Chain patterns to walk further: supplier → brand → product → category.
    In SQL this would be a chain of joins through link tables; here it reads like the question.

    suppliersbrandbproductpcategorycdistributesmanufacturespart_ofc.name = 'Condiments'
    -- Which suppliers distribute a brand that manufactures
    -- products in the "Condiments" category?
    SELECT DISTINCT s.company_name, b.name AS brand, p.name AS product
    FROM MATCH
      (s:supplier)-[:distributes]->(b:brand),
      (b:brand)-[:manufactures]->(p:product),
      (p:product)-[:part_of]->(c:category)
    WHERE c.name = 'Condiments';
    graph pattern (PGQL)
    Result85 rows, first 5 shown
    company_namebrandproduct
    Cooperativa de Quesos 'Las Cabras'DC ShoesNorthwoods Cranberry Sauce
    Escargots NouveauxBurtonAniseed Syrup
    Escargots NouveauxBurtonChef Antons Cajun Seasoning
    Exotic LiquidsKari TraaGenen Shouyu
    Exotic LiquidsKari TraaGrandmas Boysenberry Spread
  8. Step 8

    Paths of variable length

    {2,2} asks for paths of exactly two follows edges, in either direction: brand ← customer → brand. Use {1,3} for one to three hops.

    customerbrandb1brandb2followsfollows{2,2}exactly two follows edges, in either direction
    -- Find pairs of brands that share at least one follower
    -- (exactly 2 follow-hops).
    SELECT DISTINCT b1.name, b2.name
    FROM MATCH (b1:brand)-[:follows{2,2}]-(b2:brand)
    WHERE b1.id < b2.id;
    graph pattern (PGQL)
    Result105 rows, first 5 shown
    b1.nameb2.name
    AdidasPearl Izumi
    AdidasRossignol
    NikeASICS
    NikeAdidas
    NikeAlo Yoga
  9. Step 9

    Combine SQL and graph

    Graph patterns and relational tables mix in the same statement. Cities are graph vertices with an ISO country code; the relational countries table turns it into a name.

    customercuresides_incitycici.country_code= co.codecountriescodenameco
    -- How many customers reside in each country?
    SELECT co.name AS country, COUNT(cu) AS customers
    FROM MATCH (cu:customer)-[:resides_in]->(ci:city),
      countries co
    WHERE ci.country_code = co.code
    GROUP BY co.name
    ORDER BY customers DESC;
    graph pattern (PGQL)relational table
    Result25 rows, first 5 shown
    countrycustomers
    United States496
    Germany70
    France67
    Brazil50
    United Kingdom45