{
  "slug": "Neo4j-Knowledge-Graph-a4a11a46f7b8",
  "title": "Neo4j Knowledge Graph",
  "subtitle": "cypher structure",
  "excerpt": "cypher structure",
  "date": "2025-07-15",
  "tags": [
    "Machine Learning"
  ],
  "readingTime": "1 min",
  "url": "https://medium.com/@mobinshaterian/neo4j-knowledge-graph-a4a11a46f7b8",
  "hero": "https://cdn-images-1.medium.com/max/800/1*2QZ-mbJA1pl_5wAaxR87SA.png",
  "content": [
    {
      "type": "heading",
      "level": 2,
      "text": "cypher structure"
    },
    {
      "type": "image",
      "src": "https://cdn-images-1.medium.com/max/800/1*2QZ-mbJA1pl_5wAaxR87SA.png",
      "alt": "Neo4j Knowledge Graph",
      "caption": "",
      "width": 646,
      "height": 277
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Dataset"
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Create an account on Neo4j Aura"
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Getting started with Neo4j in Docker"
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Creating the Docker Compose Files"
    },
    {
      "type": "paragraph",
      "html": "Create a <code>docker-compose.yml</code> file and copy the following snippet into it:"
    },
    {
      "type": "code",
      "lang": "yaml",
      "code": "services:\n  neo4j:\n    container_name: neo4j\n    image: neo4j:latest\n    ports:\n      - 7474:7474\n      - 7687:7687\n    environment:\n      - NEO4J_AUTH=neo4j/${NEO4J_PASSWORD}\n      - NEO4J_apoc_export_file_enabled=true\n      - NEO4J_apoc_import_file_enabled=true\n      - NEO4J_apoc_import_file_use__neo4j__config=true\n      - NEO4J_PLUGINS=[\"apoc\", \"graph-data-science\"]\n    volumes:\n      - ./neo4j_db/data:/data\n      - ./neo4j_db/logs:/logs\n      - ./neo4j_db/import:/var/lib/neo4j/import\n      - ./neo4j_db/plugins:/plugins"
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Load dataset"
    },
    {
      "type": "code",
      "lang": "cypher",
      "code": "LOAD CSV WITH HEADERS\nFROM 'https://raw.githubusercontent.com/MidnightSkyUniverse/udemyNeo4j/master/data/titles_and_skills.csv'\nAS row\nRETURN row.Title, row.Skills\nLIMIT 15;"
    },
    {
      "type": "image",
      "src": "https://cdn-images-1.medium.com/max/800/1*PZKIvEZbxYidSZC7qipsVw.png",
      "alt": "Neo4j Knowledge Graph",
      "caption": "",
      "width": 1101,
      "height": 523
    },
    {
      "type": "paragraph",
      "html": "Working with docker-compose"
    },
    {
      "type": "code",
      "lang": "bash",
      "code": "sudo\ndocker-compose -f docker-compose.yml exec neo4j /bin/sh"
    },
    {
      "type": "heading",
      "level": 2,
      "text": "neo4j-client"
    },
    {
      "type": "paragraph",
      "html": "Ubuntu"
    },
    {
      "type": "code",
      "lang": "text",
      "code": "$ sudo add-apt-repository ppa:cleishm/neo4j$ sudo apt-get update$ sudo apt-get install neo4j-client\nlibneo4j-client-dev"
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Download UI"
    },
    {
      "type": "code",
      "lang": "text",
      "code": "chmod a+x neo4j-desktop-1.6.0-x86_64.AppImage./neo4j-desktop-1.6.0-x86_64.AppImage"
    },
    {
      "type": "image",
      "src": "https://cdn-images-1.medium.com/max/800/1*jrwnQEdvtPb6HKxrfDMm8g.png",
      "alt": "Neo4j Knowledge Graph",
      "caption": "",
      "width": 1520,
      "height": 641
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Create Constraints"
    },
    {
      "type": "code",
      "lang": "sql",
      "code": "CREATE CONSTRAINT skillUniqueIF NOT EXISTSFOR (s:Skill)REQUIRE s.name IS UNIQUE;\nCREATE CONSTRAINT\ntitleUniqueIF NOT EXISTSFOR (t:Title)REQUIRE t.name IS UNIQUE;\nSHOW ALL CONSTRAINTS;"
    },
    {
      "type": "image",
      "src": "https://cdn-images-1.medium.com/max/800/1*dzJPE-d50P_rENWvkoTpSQ.png",
      "alt": "Neo4j Knowledge Graph",
      "caption": "",
      "width": 1221,
      "height": 269
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Create ‘Title’ nodes"
    },
    {
      "type": "code",
      "lang": "cypher",
      "code": "LOAD CSV WITH HEADERS\nFROM 'https://raw.githubusercontent.com/MidnightSkyUniverse/udemyNeo4j/master/data/titles_and_skills.csv'\nAS row\nMERGE (t:Title {name: row.Title});"
    },
    {
      "type": "image",
      "src": "https://cdn-images-1.medium.com/max/800/1*qLO-lhgwSzKa8dlRSbfPuw.png",
      "alt": "Neo4j Knowledge Graph",
      "caption": "",
      "width": 1223,
      "height": 395
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Match Title"
    },
    {
      "type": "code",
      "lang": "cypher",
      "code": "MATCH (n:Title) RETURN n LIMIT 25"
    },
    {
      "type": "image",
      "src": "https://cdn-images-1.medium.com/max/800/1*5tPd2ZGmAQWuTO8quYrTzQ.png",
      "alt": "Neo4j Knowledge Graph",
      "caption": "",
      "width": 1226,
      "height": 589
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Create ‘Skill’ nodes"
    },
    {
      "type": "code",
      "lang": "cypher",
      "code": "LOAD CSV WITH HEADERS\nFROM 'https://raw.githubusercontent.com/MidnightSkyUniverse/udemyNeo4j/master/data/skills_details.csv'\nAS row\nMERGE (s:Skill {name: row.Skill})\nSET\n    s.id = row.ID,\n    s.description = row.Description,\n    s.category = row.Category;"
    },
    {
      "type": "paragraph",
      "html": "<a href=\"https://raw.githubusercontent.com/MidnightSkyUniverse/udemyNeo4j/master/data/skills_details.csv\" target=\"_blank\" rel=\"noreferrer noopener\">https://raw.githubusercontent.com/MidnightSkyUniverse/udemyNeo4j/master/data/skills_details.csv</a>"
    },
    {
      "type": "image",
      "src": "https://cdn-images-1.medium.com/max/800/1*k6ay9Lj0TWk20Wo-949__w.png",
      "alt": "Neo4j Knowledge Graph",
      "caption": "",
      "width": 1225,
      "height": 397
    },
    {
      "type": "paragraph",
      "html": "Your Business — On AutoPilot with <em>DDImedia AI Assistant</em><br>(<a href=\"https://waitlist.ddimedia.ai/join-the-waitlist-aie\" target=\"_blank\" rel=\"noreferrer noopener\">Join Our Waitlist</a>)"
    },
    {
      "type": "paragraph",
      "html": "Visit us at <a href=\"https://www.datadriveninvestor.com/\" target=\"_blank\" rel=\"noreferrer noopener\"><em>DataDrivenInvestor.com</em></a>"
    },
    {
      "type": "paragraph",
      "html": "Join our creator ecosystem <a href=\"https://join.datadriveninvestor.com/\" target=\"_blank\" rel=\"noreferrer noopener\"><em>here</em></a>."
    },
    {
      "type": "paragraph",
      "html": "DDI Official Telegram Channel: <a href=\"https://t.me/+tafUp6ecEys4YjQ1\" target=\"_blank\" rel=\"noreferrer noopener\">https://t.me/+tafUp6ecEys4YjQ1</a>"
    },
    {
      "type": "paragraph",
      "html": "Follow us on <a href=\"https://www.linkedin.com/company/data-driven-investor\" target=\"_blank\" rel=\"noreferrer noopener\"><em>LinkedIn</em></a>, <a href=\"https://twitter.com/@DDInvestorHQ\" target=\"_blank\" rel=\"noreferrer noopener\"><em>Twitter</em></a>, <a href=\"https://www.youtube.com/c/datadriveninvestor\" target=\"_blank\" rel=\"noreferrer noopener\"><em>YouTube</em></a>, and <a href=\"https://www.facebook.com/datadriveninvestor\" target=\"_blank\" rel=\"noreferrer noopener\"><em>Facebook</em></a>."
    }
  ]
}
