Coder Social home page Coder Social logo

augustyou / closuretable Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kaciras/closuretable

0.0 1.0 0.0 439 KB

基于 ClosureTable 的数据库无限级分类实现。

Home Page: https://blog.kaciras.com/article/6

License: MIT License

Java 77.05% CSS 6.31% HTML 5.65% JavaScript 10.98%

closuretable's Introduction

ClosureTable

Test GitHub license Supported database

基于闭包表的数据库无限级分类示例。

闭包表用一张额外的表存储节点之间的关系、其中包含了任何两个有关系(祖先与子代)节点的关联信息,共有 3 个字段:

  • ancestor 祖先节点的 ID
  • descendant 子代节点的 ID
  • distance 子代到祖先中间隔了几代

以这三个字段作为条件,能够很方便的应对各种操作。闭包表是牺牲空间和修改效率来换取查询效率的典型设计。

配套文章 https://blog.kaciras.com/article/6/store-tree-in-database

运行

screenshot

本项目带有一个演示网页,能够直观地展示分类结构以及各种操作对应的 SQL,运行前需要修改application.properties,配置数据库连接。

然后使用以下命令构建并启动:

mvn package
java -jar target/closure-table-2.1.0.jar

访问 http://localhost:6666 查看演示页面。

  • 测试数据和建表脚本位于 src/main/resources 下。
  • SQL 见 CategoryMapper.java
  • 完整的 API 见 Repository.javaCategory.java

closuretable's People

Contributors

kaciras avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.