Graph Database Basics
2022/08/01
Key-value—Represents all data by a unique identifier (a key) and an associated data object (the value). Examples include Berkeley DB, RocksDB, Redis, and Memcached.
Wide-column (or column-oriented)—Stores data in rows with a potentially large number or possibly varying numbers of columns in each row. Examples include Apache HBase, Azure Table Storage, Apache Cassandra, and Google Cloud Bigtable.
Document—Stores data in a uniquely keyed document that can have varying schema and that can contain nested data. Examples include MongoDB and Apache CouchDB.
Relational—Stores data in tables containing rows with strict schema. Relationships can be established between tables allowing the joining of rows. Examples include PostgreSQL, Oracle Database, and Microsoft SQL Server.
Graph—Stores data as vertices (nodes, components) and edges (relationships). Examples include Neo4j, Apache TinkerPop’s Gremlin Server, JanusGraph, and TigerGraph.
Recursive query
比如公司的架构图,每一层查上级是谁,一层一层查,sql就很难写。而且会有性能问题
Modeling
Entity—Commonly represented by nouns, entities describe the things or the type of things in the domain (for example, vehicles, users, or geographic locations). As we move from problem definition and conceptual modeling, entities often become vertices in the logical model and technical implementation.
Relationship—Often represented by verbs (or verbal phrases), relationships describe how entities interact with one another. It could be something like moves as in “a vehicle moves to a location,” or friends as in the Facebook sense of this word as a verb (for example, “a person friends another person”). As we move from problem definition and conceptual modeling, relationships often become edges in the logical model and technical implementation.
Attribute—Like entities, also represented by a noun, but always in the context of an entity or relationship. Attributes describe a quality about the entity or relationship. We limit our use of attributes as we feel that these can distract from the more critical parts of the model development process.
Access pattern—Describes either questions or methods of interaction in the domain. Examples can be questions like, Where is this vehicle going? or Who are this person’s friends? As we move from problem definition and conceptual modeling, access patterns often become queries in the logical model and technical implementation.
Uniqueness
一对一,一对多
比如movie和人,人可以看多次同一部电影,因此会有多个edge
这本书后面的例子用的都是Gremlin
图数据库也很多。比如neo4j,cayley, dgraph, nebula.
Gremlin server(apache tinkerpop)
https://tinkerpop.apache.org/download.html
有一个gremlin server,一个gremlin console
这个好像在mac上还装不上,在windows上能装上。
添加边
g.addE('friends').from(dave).to(jim).
步骤
1 Translating entities to vertices
2 Translating relationships to edges
3 Assigning properties to those vertices and edges
4 Testing the model
Known walk
已知的点和边的集合,path是一种特殊的walk