Here's how to create a simple property graph in Supabase

Property graphs are a great way to model highly relational data. They make relationships easy to understand and, therefore, easy to build queries. Down the road, you can use the data for graph-powered machine learning.
For example, you could query the data and load them into python libraries like networkx and stellargraph. Or, if the data is more extensive, use graph databases like neo4j or memgraph.
Although you can use graph databases natively as a standalone backend, graph databases can be expensive to use, and for many day-to-day query operations, they can be overkill.
Ok, so let’s get to it. First, you’ll need to create a supabase account and a Postgres database.

Then you’ll need to turn on the store extension; this is for storing key, value pairs. Turning on the extension is accessible on the Database Extensions page.
Now let’s model this simple property graph with two tables: Node and Relationship.

We are starting with the Node table. We’ll add an id column as a primary key, a text column as the name/type of node, and finally, the hstore column with the name properties.
Now for the relationship table. Like the node table, the table will have a text column for the name/type of relationship.
We’ll assume these relationships represent a single direction or “predicate” in a graph. For that reason, we’ll add two ID columns with the names source_node_id and target_node_id
After creating the two tables, all we need to do is create indexes for the hstore columns.
And that’s it! You have a simple property graph that can store nodes, the relationship between the nodes, and properties for both nodes and relationships.

• • •

Missing some Tweet in this thread? You can try to force a refresh

Keep Current with Adrian Moses 🚢

Adrian Moses 🚢 Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!


Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @marsmoses

11 Oct
3 Automated Data Labeling Approaches

Manual labeling is expensive. It often requires the time of engineers and subject matter experts (SMEs). Or the cost of using custom labeling platforms and crowdsourcing.
Unlabeled data, in contrast, is usually cheap and easy to obtain. Finding ways to reduce the amount of manual labeling can reduce costs and speed up the iterative ML development workflow.
1. One approach to reducing manual labeling is called Semi-supervised learning
Read 13 tweets

Did Thread Reader help you today?

Support us! We are indie developers!

This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!