JSP implementation tree structure (1) -- requirement analysis and database

Source: Internet
Author: User

The organizational structure module displays a tree-like corporate organizational structure. You can add departments at each layer of the last layer. you can also delete any department. If you delete the department of the Department, the sub-department to which the Department belongs will be deleted. for example,
General Manager
Manufacturing department
Manufacturing division I
Manufacturing course 1
Product Engineering Department
Quality Assurance Department
IQC
FQC
Management Office
Management Department
Procurement Course
Security Department
The above is a tree structure. If we want to display its structure in the format, we can add a human resources class under the management department. We can add a marketing department under the general manager.
If you delete the management office when you delete it, you need to delete it from the management department, procurement class, and Security Department.
This is a typical tree structure. The function we want to implement is to display, add, delete
The database includes the concept of a layer and is created as follows:
Create table ngb_org (
Id number (8) primary key, // use sequence. nextval to automatically add
P_layer varchar2 (8), // parent layer such as B
P_id varchar2 (8), // parent id 10
C_layer varchar2 (8), // current layer, sub-layer C
C_id varchar2 (8), // ID of the Child Layer 10
Total varchar2 (16) not null, // p_layer, p_id, c_layer, c_id string connected together: B10C10 manufacturing position
Name varchar2 (32) not null, // Department name
Create_by varchar2 (32), // creator
Create_date Date, // creation Date
Update_by varchar2 (32), // Modifier
Update_date date); // modify the date
Create sequence ngb_org_seq
Increment by 1
Start with 1
Max value 9999999
Cycle
Nocache
Here, the company is A10 and the general manager is A10B10 (repeat the layer + number of the parent id and then write the layer + number of the current Department ). manufacturing is B10C10 and manufacturing is C10D10. the number of the same layer increases with 1, with a minimum value of 10 and a maximum value of 99. (which company does not have 89 departments of the same level ?)
In this way, we understand the database, implement the tree logic, and then write the display part.
Reasonable database establishment is very important, which is also the importance of DBA. Unfortunately, these analysis work is also done by a small programmer :)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.