All Projects → developerworks → Hierarchy Data Closure Table

developerworks / Hierarchy Data Closure Table

Licence: other
This is a mysql and postgresql store procedure and trigger implementation of closure table in RDBMS about hierarchy data model.

Projects that are alternatives of or similar to Hierarchy Data Closure Table

Panda Cloud
Base on SpringCloud MicroService Framework
Stars: ✭ 108 (-20%)
Mutual labels:  plpgsql
Pg2go
PostgreSQL script that generates Go struct definitions for all tables in a database
Stars: ✭ 116 (-14.07%)
Mutual labels:  plpgsql
Ccap
open source and transparent cryptocurrency analysis platform
Stars: ✭ 128 (-5.19%)
Mutual labels:  plpgsql
Triprecord
咔咔出行——基于高德地图API,Vue+Express实现的移动端webapp,服务器受到攻击网站暂时下掉了
Stars: ✭ 1,495 (+1007.41%)
Mutual labels:  plpgsql
Vocabulary V5.0
PALLAS: Build process for OMOP Standardized Vocabularies. Currently not available as independent release. Therefore, do not clone or try to replicate. It is work in progress and not ready for replication.
Stars: ✭ 114 (-15.56%)
Mutual labels:  plpgsql
Sqlite Parser
An ANTLR4 grammar for SQLite statements.
Stars: ✭ 119 (-11.85%)
Mutual labels:  plpgsql
Aws Database Migration Samples
A set of sample database and associated items to allow customers to among other things follow along with published database migration recipes.
Stars: ✭ 105 (-22.22%)
Mutual labels:  plpgsql
Keel
Kubernetes Operator to automate Helm, DaemonSet, StatefulSet & Deployment updates
Stars: ✭ 1,870 (+1285.19%)
Mutual labels:  trigger
Scaledger
A double-entry accounting database with a typed GraphQL API
Stars: ✭ 115 (-14.81%)
Mutual labels:  plpgsql
Temporal tables
Stars: ✭ 126 (-6.67%)
Mutual labels:  plpgsql
Bible Database
Bible databases as XML, JSON, SQL & SQLITE3 Database format for various languages. Developers can download it freely for their development works. Freely received, freely give.
Stars: ✭ 111 (-17.78%)
Mutual labels:  plpgsql
Node Sqlcipher
SQLCipher bindings for Node
Stars: ✭ 114 (-15.56%)
Mutual labels:  plpgsql
Mytap
MySQL Unit Testing Suite
Stars: ✭ 118 (-12.59%)
Mutual labels:  plpgsql
Common schema
DBA's framework for MySQL
Stars: ✭ 108 (-20%)
Mutual labels:  plpgsql
Pg jobmon
PostgreSQL extension which provides persistent logging within transactions and functions.
Stars: ✭ 128 (-5.19%)
Mutual labels:  plpgsql
Screampay
screamPay聚合支付,一个强大到让你尖叫的聚合支付系统,使用Java开发,spring-boot架构,已接入环讯、九派、杉德等主流支付渠道,可直接用于生产环境。
Stars: ✭ 107 (-20.74%)
Mutual labels:  plpgsql
Pg Auth
A complete authentication system built in Postgres using schemas and functions
Stars: ✭ 117 (-13.33%)
Mutual labels:  plpgsql
Subzero Starter Kit
Starter Kit and tooling for authoring GraphQL/REST API backends with subZero
Stars: ✭ 136 (+0.74%)
Mutual labels:  plpgsql
Dropwizard Jobs
Scheduling / Quartz integration for Dropwizard
Stars: ✭ 132 (-2.22%)
Mutual labels:  trigger
Partition magic
Скрипт-сниппет для Postgresql на plpgsql, позволяющий лёгко, быстро и просто создавать партицированные таблицы в вашем проекте, а также изменять, добавлять и удалять данные.
Stars: ✭ 120 (-11.11%)
Mutual labels:  plpgsql

Closure Table

This is a mysql store procedure and trigger implementation of closure table in RDBMS about hierarchy data model.

Closure Table Node Paths

Closure Table Node Paths

Query the subtree nodes

Query the subtree nodes

Features

  • Automatically add new paths when you insert a new node

  • Automatically update(DELETE old paths and INSERT new paths) paths when you update parent_id of a node. (This means move a node/subtree to a new parent)

  • A store procedure that is used to select a whole subtree by a node_id (if the node_id has descendant)

Triggers

  • trigger_add_paths

The trigger is execute when insert a node into prefix_nodes table, and call p_node_add to add update paths.

  • prefix_node_move:

The trigger is execute when update the parent_id column of prefix_nodes table only if OLD.parent_id != NEW.parent_id

Store Procedures

  • p_node_add(param_node_new_id INT UNSIGNED,param_node_parent_id INT UNSIGNED)

    Add new paths when insert a node to prefix_nodes table

  • p_get_tree(node_id INT UNSIGNED)

    Get subtree by a node id

  • p_node_move(node_old_parent_id INT UNSIGNED,node_new_parent_id INT UNSIGNED)

    Update paths when move a node to a new parent node

  • p_node_hide(node_id INT UNSIGNED, is_deleted INT UNSIGNED)

    Hide or show nodes from subtree, explains as following:

    • Step 1. call p_get_tree(6) get the HARDWARE subtree,
    • Step 2. call p_node_hide(6, 0) to hide a subtree,
    • Step 3. call p_get_tree(6) get the HARDWARE subtree, when you get a subtree, it is not show in the result.
    • Step 4. call p_node_hide(6, 1) show HARDWARE subtree

MySQL Files

  • ./mysql/tables.sql

    Create tables.

  • ./mysql/sample_data.sql

    Some insert statements for testing

Postgresql Files

TODO::

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].