Data management method and device and electronic equipment

By building a full N fork tree and generating organization node encoding, the problems of slow speed and large resource utilization in the prior art query and organizational device data are solved, and efficient data query and resource conservation are achieved.

CN120067149APending Publication Date: 2025-05-30BEIJING DEEPGLINT INFORMATION TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510142328.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-08
Publication Date
2025-05-30

AI Technical Summary

Technical Problem

In the existing database storage system, when querying data generated by all devices in a certain organization, it is necessary to recursively query the organization tree, resulting in slow data query speed and occupies a lot of processor resources, especially when the number of organizations is very large.

Method used

By building a full N fork tree, the organization node encoding is generated based on the set organization level and the upper limit value of the sub-organization node corresponding to each organization node; when adding a device, determine the organization identifier and organization node encoding of the device to which the device belongs; when querying the device data under the target organization, determine the organization node encoding range array, and query the data of the organization node encoding tags in the range array in the data table.

Benefits of technology

By querying and organizing node encoding range arrays instead of querying one by one, each data query only needs to compare the maximum and minimum values ​​of the encoding range, which significantly improves the efficiency of data query and saves processor resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120067149A_ABST
    Figure CN120067149A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a data management method and device and electronic equipment, and relates to the technical field of computers.The method comprises the steps that a full-N-way tree is constructed according to a set organization level and a sub organization node upper limit value corresponding to each organization node; generating a code for each organization node according to a preset rule; when a device is added in the data storage system, determining an organization identifier and an organization node code to which the device belongs; when equipment data under a target organization is queried, determining an organization node coding range array corresponding to the target organization; and querying data marked by each organization node code in the organization node code range array in a data table as a data query result. Through the data management method, the data query efficiency can be improved, and processor resources can be saved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a data management method and device, and an electronic device. Background Art

[0002] Currently, database storage systems typically use an organizational tree structure. This system requires the connection of numerous devices, each belonging to a different organization on the organizational tree. These devices generate a large amount of data, which is then written to database tables for subsequent querying.

[0003] When you need to query the data generated by all devices under a certain organization from the data table, you need to recursively query the organization tree. Specifically, you first recursively query the organization and all its sub-organizations, and then query the data written by each recursively queried device from the data table one by one. For example, if you need to query all device data for organization ID X, the query steps are as follows: Step 1. Recursively query all sub-organizations: First, query the IDs of the target organization X and all its sub-organizations; Step 2. Get all devices: Use the recursive query results to find all devices belonging to these organizations; Step 3. Query device data: Based on the found devices, query all matching data in the device data table device_data. Existing data query solutions query the database one by one based on all sub-organizations contained in the selected organization. When there are many organizations (such as hundreds or thousands), the database will be queried hundreds or thousands of times. On the one hand, the data query speed is slow and it takes up a lot of processor resources. Summary of the Invention

[0004] In order to solve one of the above technical defects, the embodiments of the present application provide a data management method and device, and an electronic device.

[0005] An embodiment of the present invention provides a data management method, the method comprising:

[0006] Construct a full N-ary tree based on the set organizational hierarchy and the upper limit of the sub-organization nodes corresponding to each organizational node;

[0007] Generate codes for each organization node according to preset rules;

[0008] When a device is added to the data storage system, determining the organization identifier and organization node code to which the device belongs;

[0009] When querying device data under a target organization, determine the organization node code range array corresponding to the target organization;

[0010] The data of each organization node code mark in the organization node code range array is searched in the data table as the data search result.

[0011] Optionally, the step of generating a code for each organization node according to a preset rule includes:

[0012] Perform a pre-order traversal on the full N-ary tree and generate a code for each organization node in an ascending manner, wherein the code of each organization node is smaller than the code of each child organization node of the organization node and the code of the sibling organization node on the right.

[0013] Optionally, when querying device data under a target organization, the step of determining the organization node code range array corresponding to the target organization includes:

[0014] When querying device data under a target organization, determining the target level of the target organization, the rank of the target organization in the target level, and the total number of organizational levels contained in the full N-ary tree;

[0015] An organization node code range array corresponding to the target organization is determined based on the target level, the rank, the total number of organization levels, and a geometric progression sum formula.

[0016] Optionally, the method further includes:

[0017] When the data generated by the device is written into the corresponding data table, the code of the organization node where the device is located is written accordingly.

[0018] Optionally, the step of performing a pre-order traversal on the full N-ary tree and generating a code for each organization node in an ascending order of organization node codes includes:

[0019] Accessing the root organization node of the full N-ary tree and generating a first code for the root organization node;

[0020] Traverse the left subtree of the root organization node in pre-order, and generate codes for each child organization node in the right subtree layer by layer;

[0021] The right subtree of the root organization node is traversed in pre-order, and codes are generated for each child organization node in the right subtree layer by layer.

[0022] Optionally, the method further includes:

[0023] When receiving the add organization operation, the add organization pop-up window is displayed;

[0024] Receiving the organization name entered in the add organization pop-up window, and establishing a correspondence between the organization name and the code of the added organization when receiving the organization save instruction;

[0025] When receiving the add device operation, output the add device pop-up window;

[0026] Receiving the device information entered in the add device pop-up window, and establishing a correspondence between the device name and the code of the bound organization when receiving the device save instruction;

[0027] The device information includes: device name, video stream information corresponding to the device, and address information.

[0028] An embodiment of the present invention further provides a data management device, comprising:

[0029] A construction module is used to construct a full N-ary tree based on the set organizational hierarchy and the upper limit of the sub-organization nodes corresponding to each organization node;

[0030] A generation module is used to generate codes for each organization node according to preset rules;

[0031] A code determination module, configured to determine, when a device is added to the data storage system, the organization identifier and the organization node code to which the device belongs;

[0032] A range determination module, configured to determine an organization node code range array corresponding to a target organization when querying device data under the target organization;

[0033] The query module is used to query the data of each organization node code mark in the organization node code range array in the data table as the data query result.

[0034] Optionally, the generation module is specifically used to:

[0035] Perform a pre-order traversal on the full N-ary tree and generate a code for each organization node in an ascending manner, wherein the code of each organization node is smaller than the code of each child organization node of the organization node and the code of the sibling organization node on the right.

[0036] Optionally, the range determination module includes:

[0037] The first submodule is configured to determine, when querying device data under a target organization, the target level of the target organization, the position of the target organization in the target level, and the total number of organizational levels contained in the full N-ary tree;

[0038] The second submodule is used to determine the organization node code range array corresponding to the target organization based on the target level, the rank, the total number of organizational levels and the geometric progression sum formula.

[0039] Optionally, the device further comprises:

[0040] The writing module is used to write the code of the organization node where the device is located when writing the data generated by the device into the corresponding data table.

[0041] Optionally, the generating module includes:

[0042] A third submodule is configured to access the root organization node of the full N-ary tree and generate a first code for the root organization node;

[0043] A fourth submodule is configured to traverse the left subtree of the root organization node in pre-order, and generate codes for each child organization node in the right subtree layer by layer;

[0044] The fifth submodule is used to traverse the right subtree of the root organization node in pre-order, and generate codes for each child organization node in the right subtree layer by layer.

[0045] Optionally, the device further comprises:

[0046] The first output module is used to output a pop-up window for adding an organization when receiving an operation to add an organization;

[0047] A first receiving module is configured to receive the organization name entered in the add organization pop-up window and establish a correspondence between the organization name and the code of the added organization upon receiving an organization save instruction;

[0048] The second output module is used to output a pop-up window for adding a device when receiving an operation to add a device;

[0049] A second receiving module is configured to receive the device information input in the add device pop-up window and establish a correspondence between the device name and the code of the bound organization upon receiving a device save instruction;

[0050] The device information includes: device name, video stream information corresponding to the device, and address information.

[0051] In another aspect of the implementation of the present invention, an electronic device is provided, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; the memory is used to store computer programs; and the processor is used to implement any of the above-mentioned data management methods when executing the programs stored in the memory.

[0052] The data management solution disclosed in this application constructs a full N-ary tree based on the set organizational hierarchy and the upper limit of the sub-organization nodes corresponding to each organization node; generates a code for each organization node according to preset rules; when a device is added to the data storage system, determines the organization identifier and organization node code to which the device belongs; when querying device data under a target organization, determines the organization node code range array corresponding to the target organization; and queries the data table for the data marked by each organization node code in the organization node code range array as the data query result. The data management solution disclosed in this application not only improves data query efficiency but also saves processor resources by querying the organization node code range array instead of constructing SQL query statements for each organization in existing query solutions. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0054] Figure 1 is a flowchart showing the steps of a data management method according to an embodiment of the present application;

[0055] Figure 2 2 is a schematic diagram showing a full N-ary tree numbering result according to an embodiment of the present application;

[0056] Figure 3 It is a diagram showing a conventional tree-like organizational structure;

[0057] Figure 4 Schematic diagram of a full N-ary tree organizational structure according to an embodiment of the present application;

[0058] Figure 5 It is a structural block diagram of a data management device according to an embodiment of the present application. DETAILED DESCRIPTION

[0059] In order to make the technical solutions and advantages of the embodiments of the present application more clearly understood, the exemplary embodiments of the present application are further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present application, and are not an exhaustive list of all the embodiments. It should be noted that the embodiments and features in the embodiments of the present application can be combined with each other unless they conflict.

[0060] The data management solution provided by the embodiment of the present application is described in detail below through specific embodiments and their application scenarios in conjunction with the accompanying drawings.

[0061] As attached Figure 1 As shown, the data management method of the embodiment of the present application includes the following steps:

[0062] Step 101: Construct a full N-ary tree based on the set organizational hierarchy and the upper limit of the sub-organization nodes corresponding to each organization node.

[0063] The organization tree structure contains the parent-child relationship between each organization node (also referred to as organization). Each organization node can have multiple child nodes, forming a hierarchical tree structure. Each device is associated with an organization node.

[0064] Assume that the organization tree structure is stored in a database table organizations, and the table structure is as follows:

[0065] id: unique identifier of the organization;

[0066] name: organization name;

[0067] parent_id: The ID of the parent organization (the parent node of each child organization node is considered its parent organization). NULL indicates the root organization.

[0068] The relationship between devices and organizations is stored in a table called devices. The table structure is as follows:

[0069] id: unique identifier of the device

[0070] name: device name

[0071] organization_id: The organization ID to which the device belongs

[0072] The data generated by the device is stored in the device_data table. The table structure is as follows:

[0073] id: unique identifier of the data record

[0074] device_id: The device ID that generated the data

[0075] data: data generated by the device

[0076] timestamp: the time when the data is generated.

[0077] In the embodiment of the present application, a full N-ary tree is constructed based on the scale of the organization tree of the scenario. Each organization node has a maximum of n child organization nodes, and the organization hierarchy has a maximum of m layers. The total number of nodes in the constructed full N-ary tree is n^0+n^1+n^2+....+n^(m-1)=(1-n^m) / (1-n). It should be noted that both the organization node and the organization subnode are considered as one node, and each node corresponds to a node code (referred to as code).

[0078] The data management method provided in the embodiment of the present application can be applied to an electronic device. The electronic device is provided with a storage medium, and the storage medium stores a data management computer program. When the data management computer program is executed by a processor, the data management method process is executed.

[0079] Step 102: Generate a code for each organization node according to preset rules.

[0080] An optional method of generating a code for each organization node according to preset rules can be: performing a pre-order traversal of the full N-ary tree, and generating a code for each organization node in an ascending manner of the organization node code, wherein the code of each organization node is smaller than the code of each child organization node of the organization node and the code of the sibling organization node on the right.

[0081] Pre-order traversal is a depth-first traversal method, which is usually used in scenarios such as copying tree structures and calculating the depth of tree nodes.

[0082] A feasible method of performing a pre-order traversal on a full N-ary tree and generating a code for each organization node in an incremental manner may include the following sub-steps:

[0083] Sub-step 1: Access the root organization node of the full N-ary tree and generate the first code for the root organization node;

[0084] Sub-step 2: Pre-order traverse the left subtree of the root organization node and generate codes for each child organization node in the right subtree level by level;

[0085] Sub-step 3: Pre-order traverse the right subtree of the root organization node, and generate codes for each child organization node in the right subtree level by level.

[0086] Assuming that the organizational level n=3, the upper limit of the sub-organization nodes corresponding to each organizational node is m=3, an exemplary diagram of the coding full N-ary tree numbering result after coding each organizational node according to the pre-order traversal is shown as follows: Figure 2 shown.

[0087] Step 103: When a device is added to the data storage system, the organization identifier and organization node code to which the device belongs are determined.

[0088] In the data management method provided by the embodiment of the present application, there is a column for storing organization node codes in the data table generated by the device. When performing data management, when writing the data generated by the device into the corresponding data table, the code of the organization node where the device is located is written accordingly, so that the data corresponding to the device can be subsequently filtered based on the code of the organization node.

[0089] Step 104: When querying the device data under the target organization, determine the organization node code range array corresponding to the target organization.

[0090] An optional method for determining the organization node code range array corresponding to the target organization when querying device data under the target organization is as follows:

[0091] When querying device data under the target organization, determine the target level of the target organization, the target organization's rank in the target level, and the total number of organization levels contained in the full N-ary tree; based on the target level, rank, total number of organization levels, and the geometric progression sum formula, determine the organization node code range array corresponding to the target organization.

[0092] The formula for summing a geometric sequence can be: for a full N-ary tree with m levels, the organization node code range corresponding to the b-th organization node in the a-th layer is:

[0093] [n^(a-1)+(b-1)((1-n^(m+1-a)) / (1-n)), n^(a-1)+((1-n^(m+1-a)) / (1-n))+1)

[0094] N is the total number of forks in the full N-ary tree, and the organization node codes contained in this range are the organization node code range array corresponding to the target organization.

[0095] Step 105: Query the data table for the data of each organization node code mark in the organization node code range array as the data query result.

[0096] By attaching Figure 2 As you can see, the codes of each organization node's child organization nodes and sibling organization nodes to the right are greater than the code of the organization node itself. If you want to retrieve all organizations from the root organization, including its child organization nodes, the determined organization node code range, i.e., the org_code range, is [1, 14). If you want to retrieve the organizations whose first organization node in the first level includes its child organization nodes, the determined org_code range is [2, 6). If you want to retrieve the organizations whose second organization node in the first level includes its child organization nodes, the org_code range is [6, 10).

[0097] If the traditional solution is used to retrieve data for all organization nodes of the root organization, the SQL statement is select * from Data where org_code in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13). Each query results in 13 database comparisons. However, after optimization, the SQL statement becomes select * from Data where org_code >= 1 and org_code < 14. This way, each data entry only needs to be compared twice. This significantly reduces database overhead when the number of organization nodes is sufficient.

[0098] In an optional embodiment, the data management method further includes a process of adding an organization and binding a device to the organization according to a user operation, specifically including the following steps:

[0099] When receiving an add organization operation, a pop-up window for adding an organization is displayed; the organization name entered in the pop-up window is received, and when receiving an organization save instruction, a corresponding relationship is established between the organization name and the code of the added organization;

[0100] When receiving the add device operation, output the add device pop-up window; receive the device information entered in the add device pop-up window, and establish a correspondence between the device name and the code of the bound organization when receiving the device save instruction; wherein the device information includes: device name, video stream information corresponding to the device, and address information.

[0101] In this optional embodiment, a code is generated for each organization node in advance after the full N-ary tree is established. When adding organizations or binding devices to devices in the future, there is no need to waste time generating codes, which can save time and effectively avoid duplication of organization node codes.

[0102] The data management method provided in the embodiment of the present application constructs a full N-ary tree based on the set organizational hierarchy and the upper limit of the sub-organization nodes corresponding to each organization node; generates a code for each organization node according to preset rules; when a device is added to the data storage system, determines the organization identifier and organization node code to which the device belongs; when querying device data under the target organization, determines the organization node code range array corresponding to the target organization; and queries the data table for the data marked with each organization node code in the organization node code range array as the data query result. The data management method provided in the embodiment of the present application not only improves data query efficiency but also saves processor resources by querying the organization node code range array instead of constructing SQL query statements for each organization in the existing query solution.

[0103] The following combination Figure 3 、 Figure 4 The data management method provided in the embodiment of the present application is described with a specific example.

[0104] In the prior art, when the number of all sub-organization nodes of a certain organization node is too large, the response speed is very slow when querying device data, and it will cause the database server processor to soar, and even affect other SQL queries. When the organization tree exceeds a certain upper limit, causing the number of SQL characters to exceed 65535, it will cause the SQL to be too large and the query will directly report an error. In response to the above problems, this application provides a tree-like organization encoding scheme for optimizing database query performance. No matter how many organization nodes there are, the query is within an organization node encoding range, and the length of the SQL query statement will not increase indefinitely as the number of organization nodes to be queried increases. And when the full table is scanned, the number of comparisons for each piece of data is always twice, and it will not increase as the number of organizations increases. This solution can be applied to large-scale public security projects. After optimization, the query SQL that once took several minutes will be returned within one second.

[0105] In an embodiment of the present application, based on a common organization tree, a full N-ary tree is constructed in the organization tree to occupy a space for non-existent organization nodes, and then each organization node in the organization tree is encoded during pre-order traversal.

[0106] A full n-ary tree is a special tree structure in which each organization node has zero or exactly n child organization nodes. In other words, in a full n-ary tree, if an organization node has child organization nodes, then it has exactly n child organization nodes. If an organization node has no child organization nodes (i.e., leaf nodes), it is a leaf node.

[0107] For example: an organization tree structure is root node A with 3 child nodes (B, C, D), node B has 3 child nodes (E, F, G), and node C has 1 child node (H). However, in the strict definition of a full ternary tree, node C should have 0 or 3 child nodes, so node C does not meet the definition of a full ternary tree; node D has 3 child nodes (I, J, K). If the tree is constructed according to the definition of a full ternary tree, then each non-leaf node must have 3 child nodes, and any node must have 3 child nodes.

[0108] A full N-ary tree has the following characteristics: fixed number of child nodes: each non-leaf node has a fixed number of n child nodes; tree height (i.e., the number of levels the organization tree contains): the height of a full N-ary tree is relatively low because the number of nodes in each layer grows exponentially (powers of n); the relationship between the total number of nodes and height: for a full N-ary tree of height h (i.e., a full N-ary tree), the total number of nodes can be calculated using the following formula: T = nh+1-1n-1T = \frac{n^{h+1}-1}{n-1}T = n-1nh+1-1, where T is the total number of nodes, n is the number of forks, and h is the height of the tree.

[0109] In another example, Figure 3It is a diagram showing a conventional tree-like organizational structure; Figure 4 2 is a schematic diagram of a full N-ary tree organizational structure according to an embodiment of the present application.

[0110] Figure 3 It is shown that there are three nodes b, d, and e under the root organization a, a node c under b, no child nodes under d, and three nodes f, g, and h under the e node. If the existing data query method is used to query the data of the e node and all organizations below the e node, it is necessary to query the four nodes e, f, g, and h respectively. Using the full N-ary tree organizational structure provided by the embodiment of the present application, because the organization has a maximum of three child nodes, the nodes are first completed according to the full 3-ary tree (non-existent nodes are denoted as x). It can be seen that there are two more x child nodes under the b node and three more x child nodes under the d node. Then, a pre-order traversal is performed to encode each node. If the data of the e node and all organizations below the e node are queried, it is only necessary to query the organizational code with a coding interval of [10,13). Similarly, to query the data of the b node and all organizations below the b node, it is sufficient to query the organizational code with a coding interval of [2,6). Since the data of the x node does not exist, it will not affect the query results while improving performance.

[0111] Encoding according to the pre-order traversal of a full N-ary tree has the following characteristics: the codes of each node's children and right siblings are greater than the code of the node itself. Since each level satisfies the geometric progression, with the ratio being N of the full N-ary tree, the range of any node and its subordinate nodes is calculated using the geometric progression summation formula. That is, for a full N-ary tree with m levels (full N-ary tree), the code range of the b-th organization at level a can be expressed as:

[0112] [n^(a-1)+(b-1)((1-n^(m+1-a)) / (1-n)),n^(a-1)+((1-n^(m+1-a)) / (1-n))+1)

[0113] The present application provides a method for constructing a full N-ary tree, which uses a pre-order traversal method to encode each node in the full N-ary tree. When it is necessary to find all the nodes under a certain node, there is no need to return a bunch of node IDs (for example, n), but instead a coding range is returned. In this way, the database is searched through the returned coding range, and each data only needs to be compared with the maximum and minimum values ​​of the range, only twice. If the existing technical solution is used to compare one by one through the returned organization ID, n comparisons are required. When n is much larger than 2, the database performance will be significantly reduced.

[0114] The data management method provided in this specific example automatically generates a full N-ary tree based on the level of user numbers and the maximum number of sub-organizations at each level, and automatically encodes the organization nodes of the full N-ary tree using the pre-order traversal method. This allows for querying a certain organization node and all sub-organization nodes under the organization to use the organization node code range instead of traversing each organization node to construct an SQL query statement, which can effectively optimize database query performance.

[0115] The data management method provided by this application is described below from the perspective of practical application, which may specifically include the following:

[0116] When adding an organization node under the root organization node in the operating system, select the root organization node and click "Add Organization." A pop-up window will pop up to add an organization. In the pop-up window, enter the organization name, such as "Test," without specifying a code. Click Save to complete the addition. After adding the organization node, view the database organization table to see the added Test organization node. The organization node code has been automatically encoded, for example, to 63750000000000000000.

[0117] After adding the organization node, you can further add devices. Switch to the device addition page and click the "Add Device" button to trigger the system to pop up the add device pop-up window. In the pop-up add device pop-up window, the required items to be filled in are only the device name, video stream and its address (used for video parsing to extract data) and the organization node to which it belongs. There is no need to fill in the organization code. After filling in the information, click Save to complete the device addition. After adding the device, check the device table and find that the newly added test device has been marked with the organization node code: 63750000000000000000, and the device id (device identification) is: 856e6e82-4ed1-40ea-8892-1a1db0b91243.

[0118] Enter the task management module and click the "New Task" button; fill in the task name in the new task pop-up window, select the device (for example, select the test device) and the task type (for example: full target type) and confirm. After the task runs successfully, check the records in the database pedestrian data table and find that the data of this device has been written into the data table, and there are both device ID and organization node code.

[0119] When selecting a test organization node during the front-end selection of organization node queries, all the query results are the results generated by the devices under the selected test organization node. The data query logic for the devices under the test organization node is as follows: The organization node code range from 6375000000000000000 to 6390625000000000000 is obtained by calling the service for getting the range of subordinate organization nodes with the organization node code 6375000000000000000 passed from the front-end. By using SQL query through the database client, it is found that the devices within this organization node code range all belong to the selected organization node.

[0120] If the root organization node is selected, calling the organization range conversion service can obtain an organization node code range of: 0 to 9223372036854775807. When querying data, only the following SQL statement is needed to query the device data under all organization nodes under the root organization node: select * from pedestrian_capture_index where org_code >= 0 and org_code <9223372>036854775807.

[0121] In the case of having 5 organization nodes under the root organization node, the traditional way requires writing the SQL query statement as select * from pedestrian_capture_index where org_code in (0, 6234375000000000000, 1568937500000000000, 6375000000000000000, 5828125000000000000, 1562500000000000000). It can be seen that as the number of organizations increases, the SQL statement will become longer and longer, eventually leading to being unavailable due to exceeding the maximum length of the database.

[0122] Considering from the perspective of the execution plan, through the execution plan of the SQL statement with the organization node code range, the database uses the index; while for the SQL statement with the organization array, it performs a full table scan, and if the amount of data is large, the database will freeze.

[0123] Figure 5 To implement the structural block diagram of a data management device according to an embodiment of the present application.

[0124] The data management device provided by the embodiment of the present application includes the following functional modules:

[0125] A construction module 501, configured to construct a full N-ary tree according to the set organization hierarchy and the upper limit value of the sub-organization nodes corresponding to each organization node;

[0126] A generation module 502 is used to generate a code for each organization node according to a preset rule;

[0127] The code determination module 503 is used to determine the organization identifier and organization node code to which the device belongs when a device is added to the data storage system;

[0128] A range determination module 504 is configured to determine an organization node code range array corresponding to a target organization when querying device data under the target organization;

[0129] The query module 505 is used to query the data of each organization node code mark in the organization node code range array in the data table as the data query result.

[0130] Optionally, the generation module is specifically used to:

[0131] Perform a pre-order traversal on the full N-ary tree and generate a code for each organization node in an ascending manner, wherein the code of each organization node is smaller than the code of each child organization node of the organization node and the code of the sibling organization node on the right.

[0132] Optionally, the range determination module includes:

[0133] The first submodule is configured to determine, when querying device data under a target organization, the target level of the target organization, the position of the target organization in the target level, and the total number of organizational levels contained in the full N-ary tree;

[0134] The second submodule is used to determine the organization node code range array corresponding to the target organization based on the target level, the rank, the total number of organizational levels and the geometric progression sum formula.

[0135] Optionally, the device further comprises:

[0136] The writing module is used to write the code of the organization node where the device is located when writing the data generated by the device into the corresponding data table.

[0137] Optionally, the generating module includes:

[0138] A third submodule is configured to access the root organization node of the full N-ary tree and generate a first code for the root organization node;

[0139] A fourth submodule is configured to traverse the left subtree of the root organization node in pre-order, and generate codes for each child organization node in the right subtree layer by layer;

[0140] The fifth submodule is used to traverse the right subtree of the root organization node in pre-order, and generate codes for each child organization node in the right subtree layer by layer.

[0141] Optionally, the device further comprises:

[0142] The first output module is used to output a pop-up window for adding an organization when receiving an operation to add an organization;

[0143] A first receiving module is configured to receive the organization name entered in the add organization pop-up window and establish a correspondence between the organization name and the code of the added organization upon receiving an organization save instruction;

[0144] The second output module is used to output a pop-up window for adding a device when receiving an operation to add a device;

[0145] A second receiving module is configured to receive the device information input in the add device pop-up window and establish a correspondence between the device name and the code of the bound organization upon receiving a device save instruction;

[0146] The device information includes: device name, video stream information corresponding to the device, and address information.

[0147] The embodiments of the present application provide Figure 5 The data management device shown can achieve Figure 1 To avoid repetition, the various processes implemented in the method embodiment are not described here.

[0148] The data management device provided in the embodiment of the present application constructs a full N-ary tree based on the set organizational hierarchy and the upper limit of the sub-organization nodes corresponding to each organizational node; generates a code for each organizational node according to preset rules; when a device is added to the data storage system, determines the organization identifier and organization node code to which the device belongs; when querying device data under a target organization, determines the organization node code range array corresponding to the target organization; and queries the data table for the data marked by each organization node code in the organization node code range array as the data query result. The data management device provided in the embodiment of the present application not only improves data query efficiency but also saves processor resources by querying the organization node code range array instead of constructing SQL query statements for each organization in the existing query solution.

[0149] An embodiment of the present invention further provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus.

[0150] Memory for storing computer programs;

[0151] The processor is configured to implement the data management method shown in the above method embodiment when executing the program stored in the memory.

[0152] The communication bus mentioned in the terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is used in the figure, but this does not mean that there is only one bus or only one type of bus.

[0153] The communication interface is used for communication between the above terminal and other devices.

[0154] The memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage. Alternatively, the memory may be at least one storage device located away from the processor.

[0155] In another embodiment of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium stores instructions that, when executed on an electronic device, enable the electronic device to implement any of the data management methods described in the above embodiments.

[0156] In another embodiment of the present invention, a computer program product including instructions is provided. When the computer program product is run on an electronic device, the electronic device implements the data management method described in any one of the above embodiments.

[0157] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code. The scheme in the embodiment of the present application can be implemented in various computer languages, for example, C language, VHDL language, Verilog language, object-oriented programming language Java, and directly interpreted scripting language JavaScript, etc.

[0158] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the steps in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0159] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0160] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0161] In the description of this application, it should be understood that the terms "center", "longitudinal", "lateral", "length", "width", "thickness", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", etc., indicating the orientation or position relationship, are based on the orientation or position relationship shown in the accompanying drawings, and are only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on this application.

[0162] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be understood to indicate or imply relative importance or implicitly specify the number of the technical features indicated. Thus, a feature specified as "first" or "second" may explicitly or implicitly include one or more of the features. Throughout the description of this application, "plurality" means at least two, such as two, three, etc., unless otherwise specifically defined.

[0163] In this application, unless otherwise expressly specified or limited, terms such as "mounted," "connected," "connect," and "fixed" should be understood broadly. For example, they may refer to fixed connections, detachable connections, or integration; mechanical connections, electrical connections, or communication; direct connections or indirect connections through an intermediate medium; and internal communication between two components or interaction between two components. Those skilled in the art will understand the specific meanings of these terms in this application based on specific circumstances.

[0164] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present application.

[0165] Obviously, those skilled in the art may make various changes and modifications to this application without departing from the spirit and scope of this application. Thus, if these modifications and variations of this application fall within the scope of the claims of this application and their equivalents, this application is intended to include these modifications and variations.

Claims

1. A data management method, characterized in that: The method comprises: Construct a full N-ary tree based on the set organizational level and the upper limit of the sub-organization nodes corresponding to each organizational node; Generate codes for each organization node according to preset rules; When a device is added to the data storage system, determining the organization identifier and organization node code to which the device belongs; When querying the device data under the target organization, determine the organization node code range array corresponding to the target organization; The data of each organization node code mark in the organization node code range array is queried in the data table as the data query result.

2. The method according to claim 1, characterized in that The steps of generating a code for each organization node according to a preset rule include: Perform a pre-order traversal on the full N-ary tree, and generate a code for each organization node in an ascending manner, wherein the code of each organization node is smaller than the codes of each child organization node of the organization node and the code of the sibling organization node on the right.

3. The method according to claim 2, characterized in that When querying the device data under the target organization, the step of determining the organization node code range array corresponding to the target organization includes: When querying the device data under the target organization, determine the target level of the target organization, the rank of the target organization in the target level, and the total number of organizational levels contained in the full N-ary tree; According to the target level, the ranking, the total number of organizational levels and the geometric progression sum formula, the organizational node code range array corresponding to the target organization is determined.

4. The method according to claim 1, characterized in that: The method further comprises: When the data generated by the device is written into the corresponding data table, the code of the organization node where the device is located is written accordingly.

5. The method according to claim 2, characterized in that: The step of performing a pre-order traversal on the full N-ary tree and generating a code for each organization node in an incremental manner of the organization node code includes: Accessing the root organization node of the full N-ary tree and generating a first code for the root organization node; Pre-order traversal of the left subtree of the root organization node, generating codes for each child organization node in the right subtree level by level; The right subtree of the root organization node is traversed in pre-order, and codes are generated for each child organization node in the right subtree level by level.

6. The method according to claim 1, characterized in that The method further comprises: When receiving the operation of adding an organization, a pop-up window for adding an organization is output; Receiving the organization name entered in the add organization pop-up window, and establishing a correspondence between the organization name and the code of the added organization when receiving an organization save instruction; When receiving the operation of adding a device, a pop-up window of adding a device is output; Receiving the device information input in the add device pop-up window, and establishing a corresponding relationship between the device name and the code of the bound organization when receiving the device save instruction; The device information includes: device name, video stream information corresponding to the device, and address information.

7. A data management device, characterized in that: The device comprises: A construction module, used to construct a full N-ary tree according to the set organizational level and the upper limit of the sub-organization node corresponding to each organizational node; A generation module, used to generate codes for each organization node according to preset rules; A coding determination module, used to determine the organization identifier and organization node code to which the device belongs when a device is added to the data storage system; A range determination module, used to determine the organization node code range array corresponding to the target organization when querying the device data under the target organization; The query module is used to query the data of each organization node code mark in the organization node code range array in the data table as the data query result.

8. The device according to claim 7, characterized in that The generation module is specifically used for: Perform a pre-order traversal on the full N-ary tree, and generate a code for each organization node in an ascending manner, wherein the code of each organization node is smaller than the codes of each child organization node of the organization node and the code of the sibling organization node on the right.

9. The device according to claim 8, characterized in that The range determination module comprises: The first submodule is used to determine the target level of the target organization, the position of the target organization in the target level, and the total number of organizational levels included in the full N-ary tree when querying the device data under the target organization; The second submodule is used to determine the organization node code range array corresponding to the target organization according to the target level, the ranking, the total number of organization levels and the geometric progression sum formula.

10. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the data management method according to any one of claims 1 to 6 when executing a program stored in a memory.