Introduction to Neo4j

Create a test database

 
create database test;



Switch to a specific database

 
:use databasename


Drop a Database

 
drop database test


Show all databases

 
show databases


Useful Commands

 
:sysinfo - Displays System information
:history - Displays your recent history
:clear - Clear your frames 

Keyboard short cuts

Comment ctrl + /
Editor focus  /
Multiline mode shift    + enter
Run your query   ctl + enter
Command History CTL up/down
undo CTRL Z
redo CTRL Y


Creating a Node

 
Create (n)

Create multiple nodes

 
 Create (n),(m)

Creating node with a label

 
create (u:user)

Creating node with multiple labels

 
create (e:employee:Professor)

Create a graph database for the following User Data

 
  name : satish 
  address:vellore
  salary :10000
  phone: 87777
  worksfor - VIT from 2020 March 21
  College - CEG
  school - KPC 
  knows-chris and ram
  
  name : ram
  address:chennai
  salary :5000
  phone: 98877
  worksfor - VIT from 2015 April 1
  college - CEG
  school - kpc
  knows - chris
  
  name : chris 
  address:chennai
  salary :20000
  phone: 4134
  worksfor - VIT from 2017 June 2 
  college - IIT
  school - kpc
  knows-tom
  
  name : Jeff 
  address:vellore
  salary :4000
  phone: 2344
  worksfor - Microsoft from 2021 March 21
  college - IIT
  school - kmk
  knows-tom
  
  name : tom
  address:chennai
  salary :34000
  phone: 5434
  worksfor Microsoft from 2021 August 4 
  college - NIT 
  school - kmk 
  knows - satish

  The solution is given below.


Create a node for every User

 
  create(u:user{name:'satish',address:'vellore',salary:10000,phone:8777})
  create(u:user{name:'ram',address:'chennai',salary:5000,phone:98877})
  create(u:user{name:'chris',address:'chennai',salary:20000,phone:4134}
  create(u:user{name:'jeff',address:'vellore',salary:4000,phone:2344})


Create a Node for every Organization

 
  create(o:organization{name:"VIT"})
  create(o:organization{name:"Microsoft"})


Create a node for every College

 
  create(c:college{name:"ceg"})
  create(c:college{name:"NIT"})
  create(c:college{name:"IIT"})


Create a node for every School

 
  create(s:school{name:"kpc"})
  create(s:school{name:"kmk"})


Creating Multiple Nodes with Properties

 
create (u:user{name:'satish'}),(u:user{name:"ram"}),(u:user{name:'tom'}) return m,c,o


Returning all Created Nodes

 
Match(n) return (n)