Graph Databases with Dgraph
What is Dgraph?
- Dgraph is an open source, distributed, graph database... let's pick that apart
- Graph
- Nodes and Edges (Things and Relationships)
- Each node can point to another node or a "value" such as a string, integer, etc...
- Database
- Stores values long term
- Has guarantees about integrity.
- Distributed
- Automatically handles spreading the work of storing and querying across multiple servers
- Graph
What's a Graph Database? Or Why don't I just use Postgres?
Relational databases compute their joins at runtime using an index. Every time you have to do a join you have to lookup right before you do it. They also require you to be very explicit about your data model before you store it.
Whenever you run the equivalent of a JOIN operation, the database just uses this list and has direct access to the connected nodes, eliminating the need for a expensive search / match computation.
What's so cool about Dgraph
It aims at being an every day driver of a database that's just easier to use, yet still fast.
It makes joins as simple as breathing, and all your data normalized. This means that there's almost no
nulls
Did I mention it's free and open source?
Other reasons:
- Helps you understand GraphQL better
- More natural way to express many complex ideas
- Can be faster to do many joins
- Query language is much more friendly than SQL for many things.
- Most permissive of all data structures, you can model trees, linked-lists, maps, or singletons easily.
- There's no way to make a big table, everything must be broken up.
What's not so cool about Dgraph
- It's kind of in beta status. It just nearly turned 1.0. Don't expect it to replace Postgres just yet.
- As such there's not a Ruby or Elixir client that's 100% up to date (although it wouldn't be hard to write one)
Re-learning to model data
What if you took all your tables and broke them up into little pieces till they where just a big pile of cells, they take those cells and draw lines between them to show their relationships with each other. This is what you do with Graph databases.
Things you don't need:
- Rows, Columns, Schema's
- Join Tables, etc...
Query language 101
Demo
- Show how it can solve problems we have, on big data.