Database tiny Group learning Experiment



  • Hi,
    I want to learn a bit about Neo4J which is a graph database and learning together is even better.
    Therefore I thought it would be nice to store some data from volunteers from the DataCamp Bootcamp
    with small code snippets that you copy and adapt and put into the DB.
    so,
    from time to time I will update step-by-step with small tasks of code, hope you join…

    Access:
    https://ec2-35-180-109-214.eu-west-3.compute.amazonaws.com:7473/browser/
    username: neo4j
    password: digityser
    (Host: bolt://ec2-35-180-109-214.eu-west-3.compute.amazonaws.com:7687)

    Backup:
    https://github.com/albert-kevin/digitiser-bootcamp-2018/tree/master/neo4j-digityser-database/graph.db



  • This post is deleted!


  • TASK 1:
    test access to the database and if you can find the command line in the top “marked in red”.

    0_1536393771035_2018-09-08 09_56_33-neo4j@bolt___ec2-35-180-109-214.eu-west-3.compute.amazonaws.com_7687 - Neo4j Bro.png



  • @beire_2018 👌 great initiative, I will join after the 18th.



  • TASK 2:
    Create single node(s). Later we will add real data…
    but first let’s Understand what is going on here:
    CREATE (n) creates a node, n is a variable name not a node name that we can call upon
    MATCH (n) RETURN n view all created nodes
    mouse hover over node to see properties:
    <id>:0 this unique index ID (created and controlled by the database automatically)
    CREATE (n),(m) create multiple nodes (example: n and m)
    MATCH (n) RETURN n view all created nodes (three nodes = last node + 2 new nodes)
    MATCH (n) RETURN n LIMIT 2 to view only the first 2 nodes, with ID 0 and ID 1
    MATCH (n) WHERE id(n)=1 RETURN n search one node by ID (example ID=1) (= < <= > >= <>)
    MATCH (n) WHERE id(n) IN [1,2,0] RETURN n search multiple nodes by ID (example ID 0, 1, 2)

    Later we will figure out how to remove nodes



  • Indeed, great initiative! I also contacted Rik & Tom from Neo4J, I’ll do my best to provide you a Neo4J day, and if there are any Neo4J workshop event, you will be informed



  • @olivier Thank you.
    I suggest a workshop about using py2neo as well
    https://neo4j.com/graphacademy/online-training/



  • This post is deleted!


  • Delete single node:
    MATCH (n) WHERE id(n)=0 DELETE n match all nodes from variable n, select value 0 in column ‘id’ from all nodes, then delete
    verify: MATCH(n) RETURN n

    Delete multiple nodes:
    MATCH (n) WHERE id(n) IN[20,21] DELETE n the [n,m,…] list all id values

    Delete all nodes ! (skip this)
    MATCH (n) DELETE n grab all nodes in variable “n”, then delete
    (query only works on stand-alone nodes)

    LABELS
    with a tag name called a “label” we can group Nodes, more efficient to execute commands on.
    First let’s create:
    CREATE (n:Person) create a node with one Labelname “Person” for example
    (can only be applied to Nodes)
    (Label naming convention = first letter Uppercase)
    CREATE (n:Person:Animal:Dog)create node with multiple Labels
    (node can have more than one labels, labels can have more than one nodes)

    MATCH (n) WHERE n:Person RETURN n search node(s) by Label
    MATCH (n) WHERE n:Dog:Animal RETURN n search node by multiple Labels
    MATCH (n) WHERE n:Dog OR n:Animal RETURN n search by Dog OR Animal Labels

    MATCH (n) SET n:Employee RETURN n add the Label “Employee” to every node
    MATCH (n) WHERE id(n)=1 SET n:Dog RETURN n add a Label to specific node id
    MATCH (n) WHERE id(n) IN[2,3] SET n:Dog RETURN n add a Label to a list of node id’s

    remove and update Labels:
    MATCH (n) REMOVE n:Person RETURN n remove the Label “Person” from all nodes
    MATCH (n) WHERE id(n) IN[2,3] REMOVE n:Dog RETURN n remove a Label from Selective Nodes (ex: id 2, id 3)
    MATCH (n) REMOVE n:Food:Vacation RETURN n remove multiple Labels from the nodes
    MATCH (n) WHERE id(n)=0 REMOVE n:Person SET n:Dog RETURN n Update Labels, replace Label “Person” to “Dog” on id=0

    Property
    This property is another attribute of a node, these can be associated with Nodes or Relationships.
    a Property is like a list of key:value pairs like a dictionary with {‘key1’:‘value1’, ‘key2’:‘value2’, etc…}
    CREATE (x:Book{title:"The White Tiger"}) RETURN x create a Node with one Property

    • Node variable = x
    • Node Label = Book
    • Property name = “title”
    • Property value = “The White Tiger”
    • Neo4J CREATE a unique Node ID #

    CREATE (x:Book{title:"Moby Dick",author:"Herman Melville"}) RETURN x create multiple Properties for a Node
    (note: Property names are case sensitive)
    (note: if blank spaces in Property names use {`property name`:“Moby Dick”})

    TASK 3:
    Create node(s) about yourself together.
    For example substitute the values with your own data:

    • Node variable = kevin
    • Node Label = Person
    • Property name = “FirstName”
    • Property value = “Kevin”
    • Property name = “LastName”
    • Property value = “Albert”
    CREATE (kevin:Person{FirstName:"Kevin",LastName:"Albert"})
    RETURN kevin
    

    You may create your own Node, DataCamp style 😀

    CREATE (_____:Person{FirstName:"________",LastName:"________"})
    RETURN _____
    

    Please do Fuck-up & mess around, maybe clean-up, enjoy !
    Later we will talk about the third property “Relationship”… seen below

    0_1537354937216_TASK 3.png



  • Task 4:
    Let’s create a few more nodes:

    1. programming languages you know
      MERGE (python:Language{LanguageName:"Python"})
      MERGE (excel:Language{LanguageName:"Excell"})
      MERGE (_____:Language{LanguageName:"_______"})"
      
    2. domain knowledge you have
      MERGE (linux:Domain{DomainKnowledge:"GNU/Linux"})
      MERGE (it:Domain{DomainKnowledge:"IT Infrastructure"})
      MERGE (_____:Domain{DomainKnowledge:"_______"})"
      

    Domain knowledge is understanding, ability and information that applies to a specific topic, profession or activity. The term is commonly used to describe the knowledge of experts in a particular area.

    Note: It is better to use MERGE even when creating new data