The function of the architecture module of the Organization is to display a tree-type corporate organizational architecture mode, which can add a department at each layer of the last layer. You can also delete any department, if you delete the department of the sub-department, then the sub- The department is deleted together. As,
General manager
Manufacturing office
Manufacturing one
Creation
Product Engineering Department
Protection
IQC
FQC
Management office
Management
Procurement class
Security Department
The above is a tree structure. If we want to display its structure in the format, you can add people under the management department. You can add the marketing office to the general manager.
If you delete the management office, if you delete the management office, the management department, procurement class, and the security department will be deleted.
This is a typical tree structure, the function we want to implement is to display, add, delete
The database includes the concept of layers, the establishment is as follows:
CREATE TABLE NGB_ORG (ID Number (8) Primary Key, // Automatically adds to SEQUENCE.NEXTVAL to implement p_layer varchar2 (8), // Father, bp_id varchar2 (8), // Father ID 10C_Layer varcha2 (8), // Current layer, sub-layer cc_id varcha2 (8), // The number 10 TOTAL VARCHAR2 (16) Not null, // p_layer, p_id, c_layer, c_id string together: b10c10 manufacturing Name varchar2 (32 NOT NULL, // Department name create_by varchar2 (32), // Create Create_Date Date, // Create Date Update_by varchar2 (32), // Modifier Update_Date Date); // Modify Date
Create sequence ngb_org_seqincrement by 1start with 1maxValue 9999999 Cyclenocacche
Here, the entire company is A10, the general manager is A10B10 (first repeating the parent ID number, then write the layer number of the current department). The manufacturing office is B10C10, manufacturing a C10D10. The same level number is 1 Increasing, minimum is 10, maximum of 99 (no company has 89 parties?)
This way we understand its database, realize the logic of the tree, and then write the display portion.
It is also important to establish a database reasonably. This is also the importance of DBA. Unfortunately, these analytics work is also my little programmer :)