
数据库
Claroja
这个作者很懒,什么都没留下…
展开
-
乐观锁&悲观锁
悲观锁(Pseeimistic Lock)每次去拿数据的时候都认为别人会修改,所以每次在拿数据的时候都会上锁,这样别人想拿这个数据就会block直到它拿到锁。传统的关系型数据库里边就用到了很多这种锁机制,比如行锁,表锁等,读锁,写锁等,都是在做操作之前先上锁。乐观锁(Optimistic Lock)每次去拿数据的时候都认为别人不会修改,所以不会上锁,但是在更新的时候会判断一下在此期间别人有没有去更新这个数据,可以使用版本号等机制。乐观锁适用于多读的应用类型,这样可以提高吞吐量两种锁各有优缺点,不可认原创 2020-08-08 21:33:01 · 144 阅读 · 1 评论 -
数据仓库工具箱维度建模权威指南-第一章 数据仓库、商业智能及维度建模初步
数据仓库和商业智能(Data Warehousing and Business Intelligence, DW/BI),DW/BI 系统的数据结构与标识必须符合业务用户的思维过程和词汇信息两个目的:1.操作性记录的保存(oltp)2.分析型决策的制定(olap)维度建模(维度表)两种方式:1)维度建模不要求满足第3范式。2)在关系数据库管理系统中实现的维度模型称为星型模式,在多为数据...原创 2019-11-20 22:27:51 · 1028 阅读 · 0 评论 -
neo4j
1.聚合函数过滤MATCH (david { name: 'David' })--(otherPerson)-->()WITH otherPerson, count(*) AS foafWHERE foaf > 1RETURN otherPerson.name2.排序MATCH (n)WITH nORDER BY n.name DESC LIMIT 3RETURN...原创 2018-11-15 09:27:42 · 137 阅读 · 0 评论 -
neo4j unwind
1.将列表转换为行UNWIND [1, 2, 3, NULL ] AS xRETURN x, 'val' AS y2.返回元素唯一的行WITH [1, 1, 2, 2] AS collUNWIND coll AS xWITH DISTINCT xRETURN collect(x) AS setOfVals3.列表相加WITH [1, 2] AS a,[3, 4] AS bU...原创 2018-11-15 09:40:42 · 2658 阅读 · 0 评论 -
neo4j
基础使用1.布尔逻辑判断AND OR XOR NOTMATCH (n)WHERE n.name = 'Peter' XOR (n.age < 30 AND n.name = 'Timothy') OR NOT (n.name = 'Timothy' OR n.name = 'Peter')RETURN n.name, n.age2.通过节点标签过滤MATCH (n)WHE...原创 2018-11-15 10:02:45 · 300 阅读 · 0 评论 -
neo4j limit
MATCH (n)RETURN n.nameORDER BY n.nameLIMIT 3原创 2018-11-15 10:43:54 · 696 阅读 · 0 评论 -
neo4j order by
MATCH (n)RETURN n.name, n.ageORDER BY n.name2.多属性排序MATCH (n)RETURN n.name, n.ageORDER BY n.age, n.name3.降序MATCH (n)RETURN n.name, n.ageORDER BY n.name DESC4.nullMATCH (n)RETURN n.l...原创 2018-11-15 10:46:37 · 1322 阅读 · 0 评论 -
neo4j
1.跳过前几个结果MATCH (n)RETURN n.nameORDER BY n.nameSKIP 32.返回中间几个结果MATCH (n)RETURN n.nameORDER BY n.nameSKIP 1LIMIT 2参考文献:https://neo4j.com/docs/developer-manual/3.4/cypher/clauses/skip/...原创 2018-11-15 10:50:43 · 170 阅读 · 0 评论 -
neo4j 增 create
创建节点1.创建单个节点CREATE (n)2.创建多个节点CREATE (n),(m)3.创建一个标签的节点CREATE (n:Person)4.创建多标签的节点CREATE (n:Person:Swedish)5.创建带属性的节点CREATE (n:Person { name: 'Andy', title: 'Developer' })6.返回创建的节点CRE...原创 2018-11-15 11:05:33 · 325 阅读 · 0 评论 -
neo4j 删 delete
1.删除单个节点MATCH (n:Person { name: 'UNKNOWN' })DELETE n2.删除多个节点和关系MATCH (n)DETACH DELETE n3.删除单个节点和所有和他相关的关系MATCH (n { name: 'Andy' })DETACH DELETE n4.只删除关系MATCH (n { name: 'Andy' })-[r:KNO...原创 2018-11-15 11:12:54 · 254 阅读 · 0 评论 -
neo4j python
安装:pip install neo4j-driver参考文献:https://neo4j.com/docs/developer-manual/3.4/drivers/cypher-values/原创 2018-11-19 18:17:36 · 344 阅读 · 0 评论 -
py2neo 数据类型
from py2neo.data import Node, Relationshipa = Node("Person", name="Alice") # 创建一个节点b = Node("Person", name="Bob") # 创建另一个节点ab = Relationship(a, "KNOWS", b) # 两个节点建立关系ab1.Nodeclass py2neo.dat...原创 2018-11-20 10:36:38 · 3339 阅读 · 0 评论 -
py2neo database
1.Databasefrom py2neo import Databasedb = Database("bolt://camelot.example.com:7687")default_db = Database()default_db类描述config返回配置信息default_graph默认的图类kernel_start_timeneo4j实...原创 2018-11-20 10:58:30 · 1375 阅读 · 3 评论 -
neo4j 返回 return
如果只想要获得属性的值,注意不要返回所有的节点和关系,这样效率会更高.1.返回节点MATCH (n { name: 'B' })RETURN n2.返回关系MATCH (n { name: 'A' })-[r:KNOWS]->(c)RETURN r3.返回属性MATCH (n { name: 'A' })RETURN n.name4.返回所有元素MATCH p ...原创 2018-11-15 09:20:46 · 858 阅读 · 0 评论 -
neo4
neo4j Cypher match原创 2018-11-15 09:08:36 · 1368 阅读 · 0 评论 -
py2neo 通过对象操作
class Movie(GraphObject): __primarykey__ = "title" title = Property() tag_line = Property("tagline") released = Property() actors = RelatedFrom("Person", "ACTED_IN") director...原创 2018-11-20 17:36:28 · 416 阅读 · 0 评论 -
neo4j 简介
这个库用起来比官方给的舒服安装:pip install py2neo参考文献:https://github.com/technige/py2neohttps://py2neo.org/v4/index.htmlhttps://www.jianshu.com/p/a2497a33390f原创 2018-11-20 17:40:09 · 223 阅读 · 0 评论 -
neo4j 改 set
1.添加节点属性MATCH (n { name: 'Andy' })SET n.surname = 'Taylor'RETURN n.name, n.surname2.限定条件下添加节点属性MATCH (n { name: 'Andy' })SET (CASEWHEN n.age = 36THEN n END ).worksIn = 'Malmo'RETURN n.name...原创 2018-11-16 11:04:43 · 391 阅读 · 0 评论 -
neo4j remove
1.删除一个属性MATCH (a { name: 'Andy' })REMOVE a.ageRETURN a.name, a.age2.删除所有属性REMOVE不能同时去除所有存在的属性,使用set进行操作.3.删除一个标签MATCH (n { name: 'Peter' })REMOVE n:GermanRETURN n.name, labels(n)4.删除多个标签...原创 2018-11-16 11:15:21 · 298 阅读 · 0 评论 -
neo4j
MATCH p =(begin)-[*]->(END )WHERE begin.name = 'A' AND END .name = 'D'FOREACH (n IN nodes(p)| SET n.marked = TRUE )参考文献:https://neo4j.com/docs/developer-manual/3.4/cypher/clauses/foreach/...原创 2018-11-16 11:18:23 · 175 阅读 · 0 评论 -
neo4j merge
merge可以看成是match和create的合体merge 节点1.找不到标签则创建MERGE (robert:Critic)RETURN robert, labels(robert)2.找不到属性则创建MERGE (charlie { name: 'Charlie Sheen', age: 10 })RETURN charlie3.找不到标签和属性则创建MERGE (m...原创 2018-11-16 14:38:29 · 10362 阅读 · 0 评论 -
neo4j call
执行程序1.查看所有标签CALL `db`.`labels`参考文献:https://neo4j.com/docs/developer-manual/3.4/cypher/clauses/call/原创 2018-11-16 14:51:05 · 1702 阅读 · 0 评论 -
neo4j union
1.合并两个查询MATCH (n:Actor)RETURN n.name AS nameUNION ALL MATCH (n:Movie)RETURN n.title AS name参考文献:https://neo4j.com/docs/developer-manual/3.4/cypher/clauses/union/原创 2018-11-16 15:21:08 · 831 阅读 · 1 评论 -
neo4j 导入
1,ABBA,19922,Roxette,19863,Europe,19794,The Cardigans,19921.导入csvLOAD CSV FROM 'https://neo4j.com/docs/developer-manual/3.4/csv/artists.csv' AS lineCREATE (:Artist { name: line[1], year: toInte...原创 2018-11-16 16:29:06 · 227 阅读 · 0 评论 -
neo4j values
1.属性类型类型|描述数字|Number, an abstract type, which has the subtypes Integer and Float字符串|String布尔|Boolean点|The spatial type Point时间|Temporal types: Date, Time, LocalTime, DateTime, LocalDateTime and ...原创 2018-11-19 10:16:15 · 292 阅读 · 0 评论 -
neo4j Cypher
1.节点语法()用来表示节点()(matrix)(:Movie)(matrix:Movie)(matrix:Movie {title: "The Matrix"})(matrix:Movie {title: "The Matrix", released: 1997})matrix是该节点的变量(variable):Movie是该节点的标签(label){}中是该节点的属性(p...原创 2018-11-19 10:54:27 · 212 阅读 · 0 评论 -
neo4j 查 match
节点获取1.获得所有的节点MATCH (n)RETURN n注意这里的n是一个变量名,代表了我们所取的所有节点2.获得相应标签节点MATCH (movie:Movie)RETURN movie.title获得所有电影的名称3.获得关系节点MATCH (director { name: 'Oliver Stone' })--(movie)RETURN movie.titl...原创 2018-11-14 18:05:08 · 1009 阅读 · 0 评论 -
py2neo match
class py2neo.matching.NodeMatcher(graph)类描述get(identity)match(*labels, **properties)class py2neo.matching.NodeMatch(graph, labels=frozenset(), conditions=(), order_by=(), skip=None...原创 2018-11-20 17:30:57 · 4233 阅读 · 0 评论