bitnine-oss / agensgraph

AgensGraph, a transactional graph database based on PostgreSQL
http://www.agensgraph.org
Other
1.33k stars 148 forks source link

how to append label or remove label? #461

Open n3xtchen opened 5 years ago

n3xtchen commented 5 years ago

like neo4j

match (a: x) set a:y match (a: x) remove a:x set a:y

bylee5 commented 5 years ago

@n3xtchen How to rename the label: ALTER VLABEL x RENAME TO y;

How to remove the label: DROP VLABEL x CASCADE;

n3xtchen commented 5 years ago

@bylee5

I'm not mean rename label or drop label, I wanna change some vertex's label

ex.
the label of (a, b, c, d) is "label_x",
now I want to change the label of a to "label_y"?

johnberzy-bazinga commented 5 years ago

@n3xtchen If I'm not mistaken, multiple labels aren't supported in Agens since vertices and edges are stored in a table per label. What they do support is table inheritance, which probably won't work if what you want is to "tag" individual vertices or edges. Another possibility is to just have a labels array as a property and use a property index.

n3xtchen commented 5 years ago

@johnberzy-bazinga can I move a vertex from a tabel(label A) to another table(label B)using syntactic sugar if it exists since there is many edges on it

johnberzy-bazinga commented 5 years ago

@n3xtchen you can probably clone the vertex and all the edges associated with it. It is probably pretty easy if your edges don't have self-loops. I'm not sure of one way to do that with one command at present with cypher. You'll likely need two or more. I'd say do it with a plpgsql function but I believe you'd need to wait for #449 to be merged.

gtyun commented 5 years ago

@n3xtchen It can be solved this way. MATCH (oldv:label_x)-[oldr]->(target) CREATE (newv:label_y)-[newr]->(target) SET newv=oldv, newr=oldr DELETE oldr, oldv;