Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

sumerbabel/hierarchicalDataInSql

Open more actions menu
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

hierarchicalDataInSql

Using closure tables to model hierarchy in T-SQL

Closure Table Node Paths

credit https://www.slideshare.net/billkarwin/models-for-hierarchical-data

TESTING

  • open an SQL server database
  • run createTables.sql - creates tables
  • run InsertNode.sql - creates stored procedure for inserting nodes
  • run DeleteNode.sql - creates stored procedure for deleting nodes
  • run DeleteSubtree.sql - creates stored procedure for deleting subtrees
  • run GetSubTree.sql - creates stored procedure for getting subtrees
  • run TestData.sql - insert some test data
  • start playing: e.g exec dbo.GetSubTree 1

The idea is that we store nodes using the Closure table approach to model hierarchy. In our case, the node would be a "ProjectItem". ProjectItems are either library items, products and containers.

About

Using closure tables to model hierarchy in T-SQL

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PLpgSQL 100.0%
Morty Proxy This is a proxified and sanitized view of the page, visit original site.