j8typz 发表于 2024-10-3 08:48:33

知识图谱构建利器:图数据库Neo4j的环境安排和简单运用


    <h1 style="color: black; text-align: left; margin-bottom: 10px;">Neo4j介绍</h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Neo4j是世界领先的图形数据库。它是一个高性能的图形存储,<span style="color: black;">拥有</span>成熟而健壮的数据库所需的所有功能,如友好的<span style="color: black;">查找</span>语言和ACID事务。程序员<span style="color: black;">运用</span>节点和关系的灵活网络结构,而不是静态表 。<span style="color: black;">针对</span>许多应用程序,与关系数据库相比,Neo4j<span style="color: black;">供给</span>了数量级的性能<span style="color: black;">优良</span>。</p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p26-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/0d534ffb5501453d89b61c8ba0bf8933~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728092039&amp;x-signature=uReEBFxphVj2gGwVttphNTiG0lw%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;">Cypher <span style="color: black;">查找</span>语言</h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">Cypher是Neo4j的图形<span style="color: black;">查找</span>语言</strong>,<span style="color: black;">能够</span>从图形中检索数据。它类似于SQL for graph,<span style="color: black;">因此呢</span>它<span style="color: black;">能够</span>让人专注于<span style="color: black;">期盼</span>从图形中<span style="color: black;">得到</span><span style="color: black;">那些</span>数据(而不是<span style="color: black;">怎样</span>获取数据)。<span style="color: black;">因为</span>它与其他语言的<span style="color: black;">类似</span>性和直观性,它是迄今为止最容易学习的图形语言。</p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/2c4311ab78b145508b3b25c25a95459f~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728092039&amp;x-signature=jwREtNdpMYkfJILKYqb8jdYx9IQ%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;">特点</h1><span style="color: black;">开源-其中社区版开源免费</span><span style="color: black;">无模式(<span style="color: black;">不消</span>预设数据的格式,数据更加灵活)</span><span style="color: black;">图数据库</span><span style="color: black;">noSQL(非关系型数据库,数据更易拓展)</span>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">运用</span></h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Neo4j既可用作独立服务器,<span style="color: black;">亦</span>可用作可嵌入组件。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">1.下载</strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">从官网下载最新版本的neo4j安装文件,<span style="color: black;">这儿</span><span style="color: black;">咱们</span>下载Neo4j Community Edition 4.4.7版本,如下图所示。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">下载<span style="color: black;">位置</span>:</p>https://neo4j.com/download-center/#community
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/bfd3c7e16029411aa9c959947931654b~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728092039&amp;x-signature=sI9MM1ZzXBMqN3YReqo1JV%2FSakA%3D" style="width: 50%; margin-bottom: 20px;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">neo4j下载页</p>
    </div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">下载完成后解压,打开根目录,如下图所示。</p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/e80604b6b5a74b3091dd347d4f377582~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728092039&amp;x-signature=3GPSk%2F5Aatv7Cyh7jbcWTJipBkg%3D" style="width: 50%; margin-bottom: 20px;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">neo4j目录结构</p>
    </div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">2.配置neo4j</strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">根据</span>如下所示添加环境变量:</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">NEO4J_HOME:neo4j数据库的根目录;</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">PATH:%NEO4J_HOME%\ bin。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;"><span style="color: black;">重视</span>:最新版本的neo4j需要jdk11及以上,请<span style="color: black;">自动</span>安装。</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">3.<span style="color: black;">起步</span>neo4j服务</strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">首要</span>安装neo4j服务:</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">打开cmd命令,进入根目录/bin目录,执行如下命令安装服务:</p><span style="color: black;">neo4j</span><span style="color: black;">.bat</span> <span style="color: black;">install-service</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">neo4j服务安装成功后,执行以下命令<span style="color: black;">起步</span>服务:</p><span style="color: black;">neo4j</span><span style="color: black;">.bat</span> <span style="color: black;">start</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">服务<span style="color: black;">起步</span>成功如下图所示。</p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/43f0fcc7e6d04cbe96ecc5c051196ab6~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728092039&amp;x-signature=5QaRN0ZQXwzLfSazC26ax8fkOJA%3D" style="width: 50%; margin-bottom: 20px;">
      <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">起步</span>服务成功</p>
    </div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">如上图所示,端口7474为浏览服务的端口,打开http://localhost:7474进入neo4j管理工具的登录界面,输入用户名<span style="color: black;">秘码</span>(初始化用户名为:neo4j,<span style="color: black;">秘码</span>:neo4j),登录成功后修改<span style="color: black;">秘码</span>。</p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/e0bbd5d640464bc089b2fcba7e6c7595~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728092039&amp;x-signature=TraYuNf52VXubDR9Q9%2BZO%2FuJWGE%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">至此neo4j安装完成。</p>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;">Neo4j数据结构模型</h1><span style="color: black;">节点</span><span style="color: black;">属性</span><span style="color: black;">关系</span><span style="color: black;">标签</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">节点</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">一般</span>用于存储实体信息。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">关系</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">用来将节点连接起来构建实体,它们相当于在关系数据库管理系统中显式存储和预先计算的连接<span style="color: black;">查找</span>。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">节点之间的关系是图数据库很重要的一部分。<span style="color: black;">经过</span>关系<span style="color: black;">能够</span>找到<span style="color: black;">非常多</span><span style="color: black;">相关</span>的数据,<span style="color: black;">例如</span>节点集合,关系集合以及<span style="color: black;">她们</span>的属性集合。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">属性</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">属性是用于描述图节点和关系的键值对</span><strong style="color: blue;"><span style="color: black;">:Key =Value,</span></strong><span style="color: black;">其中Key是一个字符串,Value值<span style="color: black;">能够</span><span style="color: black;">经过</span><span style="color: black;">运用</span>任何Neo4j数据类型来<span style="color: black;">暗示</span>。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">标签</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">运用</span>标签能够快速高</span><span style="color: black;">效地对节点<span style="color: black;">归类</span>并创建子图 给节点分配标签, Neo4j </span><span style="color: black;">使得大</span><span style="color: black;"><span style="color: black;">都数</span>用户的数据模型变得更加简单。</span></p>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;">Neo4j简单<span style="color: black;">运用</span></h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">常用命令:</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Create:创建,merge:关系,Set:,DELETE:删除,REMOVE:移除,FOREACH:遍历,IMPORT CSV:导出csv文件,MATCH:<span style="color: black;">查找</span>,WHERE:<span style="color: black;">要求</span>。</p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">1.创建</strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">打开neo4j管理器,创建一个节点为emp的标签名<span style="color: black;">叫作</span>为Employee的节点。</p><span style="color: black;">CREATE</span> (<span style="color: black;">emp</span>:Employee)<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/40d9f15325e34e8f948a71bb7aeabf3d~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728092039&amp;x-signature=xqDpxb%2BcF34NG4wSr%2FMERPBvk9A%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">2.<span style="color: black;">查找</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">查找</span>一个节点为emp,标签为Employee的节点。</p>MATCH (emp:Employee) <span style="color: black;">return</span> emp<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/16c4a544e6be49ff92a0fe802ee42c52~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728092039&amp;x-signature=c3JLyhJGRTagAa6eInixEGWsEE0%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">3.删除</strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">删除一个节点为emp,标签为Employee的节点。</p><span style="color: black;">MATCH</span> (<span style="color: black;">emp</span>: Employee) <span style="color: black;">delete</span> <span style="color: black;">emp</span>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/33a9e21649d241ef8710654ddc9b6bce~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1728092039&amp;x-signature=vU%2Fo1NUMiZNPFwV8%2B4YvXGTlDSU%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">至此完<span style="color: black;">成为了</span>一个简单的增删查的功能。</p>




nykek5i 发表于 2024-10-15 03:23:27

我们有着相似的经历,你的感受我深有体会。
页: [1]
查看完整版本: 知识图谱构建利器:图数据库Neo4j的环境安排和简单运用