Dgraph
Outline
- What Is Dgraph ?
- Dgraph vs SQL
- Dgraph vs Elastic
- Pro's vs Con's
- Concept
- Basic's
- Demo
Dgraph == Graph Database
_:hamdi
Hamdi
name
23
age
_:ahmadi
_:muzakkiy
friend
friend
_:pet
pet
kitty
Vs
Dgraph
- Good for Analyze
SQL
- Good for Transactional
Vs
Dgraph
- Good when we want to know data relation
Elastic
- Good when we want to know a very specific data ( fast )
Pro's
- Easy to get relationship each data
- fast enough to get relationship data
- what you want, what you get ( graphql )
Con's
- should analyze the mutation well to avoid big changes in the future
- slow on insert
- slow when we search global data
Concept
Node
Value
( Attribute 1 )
Node
( Relationship )
Value
( Attribute 2 )
Node
- As Identifier ( object )
- Have _uid_ ( universal identifier )
- Have Attribute
- Have Relationship
Value
- Value Of Attribute
Attribute
- 1 node have 1 attribute name ( ex : node X have name ( 1 ) ) for this example, attribute == name. The name value is the Value
Relationship
- 1 node have 1/many relationship
- Relationship only happen betwen Node - Node
Basic
Mutation
mutation {
schema {
name: string @index(exact, term) .
age: int @index(int) .
friend: uid @count .
}
}
mutation {
set {
_:naruto <name> "uzumaki naruto" .
_:naruto <child> _:boruto .
_:naruto <child> _:himawari .
_:naruto <job> "hokage" .
_:naruto <pet> _:gamabunta .
_:naruto <friend> _:sasuke .
_:naruto <friend> _:sakura .
_:naruto <teacher> _:kakashi .
_:boruto <father> _:naruto .
_:boruto <sister> _:himawari .
_:boruto <name> "uzumaki boruto" .
_:himawari <name> "himawari hyuga" .
}
}
Query
{
everyone(func: anyofterms(name, "naruto")) {
name
child {
name
friend { expand(_all_) { expand(_all_) } }
}
}
}
Demo
Dgraph
By hamdi ahmadi
Dgraph
Dgraph Sharing Session
- 433