{"id":23043941,"url":"https://github.com/willsoss/closure-tree","last_synced_at":"2026-04-28T08:31:38.345Z","repository":{"id":85261096,"uuid":"300466596","full_name":"WillSoss/closure-tree","owner":"WillSoss","description":"A closure table implementation in C#/MSSQL.","archived":false,"fork":false,"pushed_at":"2023-06-26T09:18:46.000Z","size":11,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-03T01:41:20.644Z","etag":null,"topics":["closure-table","csharp","mssql","tree"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WillSoss.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-02T01:10:41.000Z","updated_at":"2023-06-26T09:18:52.000Z","dependencies_parsed_at":"2025-02-09T22:31:02.753Z","dependency_job_id":null,"html_url":"https://github.com/WillSoss/closure-tree","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/WillSoss/closure-tree","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WillSoss%2Fclosure-tree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WillSoss%2Fclosure-tree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WillSoss%2Fclosure-tree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WillSoss%2Fclosure-tree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WillSoss","download_url":"https://codeload.github.com/WillSoss/closure-tree/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WillSoss%2Fclosure-tree/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32373422,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-27T20:07:02.737Z","status":"online","status_checked_at":"2026-04-28T02:00:07.250Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["closure-table","csharp","mssql","tree"],"created_at":"2024-12-15T20:50:07.009Z","updated_at":"2026-04-28T08:31:38.329Z","avatar_url":"https://github.com/WillSoss.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Closure Tree\nA simple C#/MSSQL closure table implementation for fun and learning.\n\n## Get Started\n\n1. Create an MSSQL database named `closure-tree`, or whatever you'd like to name it. \n1. Open the file `create.sql` in the `ClosureTree` folder and run the script in the newly created database to add the tables and stored procedures needed to run the code.\n3. Edit the connection string in `Test.cs` to target your database. Run the tests from Visual Studio or by running `dotnet test` from the `Tests` folder.\n\n## What's a Closure Table?\n\nA closure table is a technique for storing hierarchical data in a database table. A table stores the relationship between each ancestor/descendant pair of nodes in the tree, as well as the number of nodes between them, known as depth. This enables tree-based operations, like getting, adding, deleting, or moving nodes or sub-trees, in a manner that is easy to implement and fast to execute.\n\nFor example, the following tree:\n\n```\n    a\n   / \\\n  b   c\n     / \\\n    d   e\n```\n\nWould be stored in a closure table like this:\n\n|Parent|Child|Depth|\n|------|-----|-----|\n|a|a|0|\n|b|b|0|\n|c|c|0|\n|d|d|0|\n|e|e|0|\n|a|b|1|\n|a|c|1|\n|c|d|1|\n|c|e|1|\n|a|d|2|\n|a|e|2|\n\nSee the tests for examples of what a closure table can do!\n\n## Who's this for?\n\nAnyone, really! Whether you're a student learning data structures or a developer starting to build an accounting system, hopefully this will be useful. It's a project that was just a little fun, something pure and academic between real world work.\n\nIf you find it useful, let me know! If you improve it, open a PR so others can see your handiwork!\n\n## How do I make use of this?\n\nThe code in this repo just stores the table structure, but no information about a node beyond an ID. Columns could be added to `dbo.Node` to store data or a foreign key to an existing table. `dbo.Node` could also be dropped and the IDs in `dbo.Closure` could point directly to another table. This code is just a starting point for building something real on top of it.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillsoss%2Fclosure-tree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwillsoss%2Fclosure-tree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwillsoss%2Fclosure-tree/lists"}