PostgreSQL's ltree extension gives you materialised paths with database-native superpowers: GiST indexes, specialised operators like @> and <@, and powerful pattern matching. If you're committed to PostgreSQL and want the best hierarchy query performance,…
Nested sets encode the entire tree structure into just two integers per node - Left and Right boundaries from a depth-first walk. Finding all descendants becomes a simple range query, and ORDER BY Left gives you perfect display order. The catch? Every insert…
Materialised paths store the complete ancestry as a delimited string - like /1/3/7/ - making ancestors instantly readable without any joins. Perfect for breadcrumb generation and human-readable debugging, though moving subtrees means updating every…
Closure tables precompute and store every ancestor-descendant relationship, trading storage space for blazing-fast reads. This is the approach this blog uses for its comment system - when reads vastly outnumber writes, the extra insert complexity pays off with…
The adjacency list is the simplest and most intuitive approach to storing hierarchical data - each row just points to its parent. It's what most developers reach for first, and for shallow trees with frequent moves, it's often the right choice. This article…
Hierarchical data is everywhere in software development: threaded comments, organisational charts, file systems, product categories, and forum discussions. The eternal question of "how do I store a tree in a relational database?" has haunted developers since…
Running MigrateAsync() at startup? You're giving your app database owner rights and hoping nothing goes wrong. There's a better way - EF migration bundles let you run migrations as a controlled CI step, keeping your production app secure. But here's the thing:…
This is just a quick article as it builds on the others in the full text search series such as the typeahead dropdown and Postgres full text search. In this post, I will show you how to implement a simple search page using HTMX and EF Core in an ASP.NET Core…
One of the key aspects of a blogging site like this is a comments system. So, I decided to build one. This is the first part of a series of posts on how to build a comments system. In this post, I will be setting up the database. Setting up the Database As…
Searching for content is a critical part of any content heavy website. It enhances discoverability and user experience. In this post I'll cover how I added full text searching for this site Next parts in this series: Search Box with Postgres Introduction to…