Data storage and query method
Through two-level database storage solutions and equal-to-element numbering technology, the problem of slow database retrieval speed is solved, and fast retrieval and efficient data retrieval are realized, which is suitable for large-scale data storage.
Patent Information
- Application Number
- CN202310540793.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-15
- Publication Date
- 2024-11-15
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing databases are slow to retrieve data and have a large processor load, resulting in low information retrieval efficiency.
A two-level database storage scheme is adopted, in which one database stores all information, and the other database stores part of the index information, and is numbered equally according to the information weight, so that quick retrieval is achieved through calculation.
It significantly reduces the amount of database search information, improves the search efficiency, reduces the processor load, and is suitable for rapid retrieval of large amounts of data.
Smart Images

Figure CN118964429A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data storage and query, and in particular to a data storage and query method. Background Art
[0002] A database is a "warehouse that organizes, stores and manages data according to data structures". It is a collection of large amounts of data that is stored in a computer for a long time, organized, shareable and uniformly managed. When existing campuses, hospitals or other units store information on students, patients or other personnel, the amount of information stored is large due to the large number of personnel. Therefore, once the information of a certain person or certain persons needs to be retrieved, all the stored data needs to be retrieved in sequence, resulting in a large amount of retrieval, slow results and high processor requirements. Summary of the invention
[0003] The object of the present invention is to provide a method for storing and querying data, so as to solve the problems of slow speed and heavy processor load caused by large amount of data in the existing database.
[0004] To achieve the above object, the present invention provides the following technical solution: a method for storing and querying data, comprising the following steps: The data information is routinely stored through the first database, storing all the information of the students and arranging them according to ID; The data information is indexed and stored through the second database, partial information of students is stored and arranged according to the same ID, and each different type of information is composed of different search columns according to the weight; The search columns in the second database are numbered sequentially, and the numbering is a geometric progression; When retrieving data information, firstly, a quick search is performed from the second database through an AND operation. When matching data information is retrieved, the ID column of the first database is quickly searched according to the ID to which the information belongs, and the complete information of the data is obtained.
[0005] Preferably, the data information is routinely stored in the first database, all the information of the students is stored and arranged according to the ID, including: Get the complete information of the students, and then store the information in the form of a table in the first database, with the information of the same student in one row and the information of the same category in one column, and arrange the IDs downward in sequence according to different data.
[0006] Preferably, the data information is indexed and stored through the second database, partial information of students is stored and arranged according to the same ID, and each different type of information is composed of different search columns according to the weight, including: Obtain partial information of students, and then store the information in the second database in the form of a table, and arrange it in the same order as the data information table ID in the first database. Part of the data information is arranged in columns backwards according to the search weight.
[0007] Preferably, the search columns in the second database are numbered sequentially, and the numbering is a geometric progression, including: The search columns of the data information table in the second database are numbered in sequence, and are numbered 1, 2, 4, 8...n in sequence according to the priority of the weight.
[0008] Preferably, when retrieving data information, firstly, a quick search is performed from the second database through an AND operation. When matching data information is retrieved, the ID column of the first database is quickly searched according to the ID to which the information belongs, and complete information of the data is obtained, including: S1. When retrieving data information, first transmit the number to be retrieved, then perform an AND operation on the transmitted retrieval number parameter and the retrieval column to determine whether the result is 0. If not, continue to execute step S2, otherwise end; S2. Determine the search column included in the number parameter, then perform a search, and after the result is retrieved, obtain the ID to which the information belongs; S3. Return to the first database and perform a quick search based on the ID to which the information belongs to obtain complete information of the data with the same ID.
[0009] The present invention also provides a data storage and query device, comprising: An information establishment module, which is used to perform conventional storage of data information through the first database, store all the information of students and arrange them according to ID; The information establishment module is also used to index and store the data information through the second database, store part of the students' information and arrange them according to the same ID, and each different type of information forms a different search column according to the weight; The information establishment module is also used to sequentially number the search columns in the second database, and the numbering is a geometric progression; The information retrieval module is used to retrieve data information. First, it quickly searches from the second database through an AND operation. When the matching data information is retrieved, it enters the first database ID column for quick search according to the ID to which the information belongs, and obtains the complete information of the data.
[0010] The present invention also provides a data storage and query device, the data storage and query device is a physical device, and the data storage and query device includes: A processor and a memory, wherein the processor and the memory are communicatively connected with the processor; The memory is used to store at least one executable instruction executed by the processor, and the processor is used to execute the executable instruction to implement the above-mentioned data storage and query method.
[0011] The present invention also provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the method for storing and querying data as described above is implemented.
[0012] Compared with the prior art, the present invention has the following beneficial effects: By setting up two data storage databases separately, one of which stores all information and the other stores partial index information, and arranging the index columns according to weight numbers, and the two databases store the same ID arrangement, when you need to retrieve the information of one of the IDs, you only need to quickly search from the index database according to the numbering parameters of the known information, obtain the information ID after retrieving the information, and return to the storage database for a quick search to obtain all the information of the ID, which greatly reduces the amount of retrieval when retrieving information in the database, and has a good effect of reducing the burden and speeding up the storage and retrieval of large amounts of data. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] Figure 1 A main flow chart of a data storage and query method provided by an embodiment of the present invention; Figure 2 A flowchart of the specific steps of a method for storing and querying data provided by an embodiment of the present invention; Figure 3 A structural block diagram of a data storage and query device provided by an embodiment of the present invention. Implementation
[0014] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0015] The execution subject of the method of this embodiment is a terminal, which can be a mobile phone, tablet computer, PDA, notebook or desktop computer, etc. Of course, it can also be other devices with similar functions, which is not limited in this embodiment. Example
[0016] See also Figures 1 to 3 The present invention provides a data storage and query method, which is applied to data storage and rapid retrieval, and includes: Step 101, routinely store data information through the first database, store all student information and arrange them according to ID.
[0017] Specifically, the complete information of the students is obtained, and then the information is stored in the first database in the form of a table, with the information of the same student in one row and the information of the same category in one column. The IDs are arranged downward in sequence according to different data, such as the following table: First database data information table
[0018] Step 102, indexing and storing the data information through the second database, storing partial information of students and arranging them according to the same ID, and each different type of information forms different search columns according to the weight.
[0019] Specifically, partial information of the data is obtained, and then the information is stored in the second database in the form of a table, and the arrangement order is the same as that of the data information table ID in the first database. Part of the data information is arranged in columns backwards according to the search weight, such as the following table: Second database data information index table
[0020] Step 103: number the search columns in the second database in sequence, and the numbering is a geometric progression.
[0021] Specifically, the search columns of the data information table in the second database are numbered in sequence, and are numbered 1, 2, 4, 8...n according to the priority of the weight. For example, in the above-mentioned second database data information index table, the top search column is the student number.
[0022] Step 104, when retrieving data information, firstly, a quick search is performed from the second database through an AND operation. When matching data information is retrieved, a quick search is performed by entering the ID column of the first database according to the ID to which the information belongs, and the complete information of the data is obtained.
[0023] Specifically, the step 104 further includes the following steps: S1. When retrieving data information, first transmit the number to be retrieved, then perform an AND operation on the transmitted retrieval number parameter and the retrieval column to determine whether the result is 0. If not, continue to execute step S2, otherwise end; S2. Determine the search column included in the number parameter, then perform a search, and after the result is retrieved, obtain the ID to which the information belongs; S3. Return to the first database and perform a quick search based on the ID to which the information belongs to obtain complete information of the data with the same ID.
[0024] If you need to search for a student's name and student ID, since ID 1 contains both the name and student ID, you only need to transfer 1. If you need to search for name, student ID and age, you need to find number 1 and number 2. The sum of number 1 and number 2 is 3, so 3 is transmitted; The transmitted parameter is the sum of the numbers. If you need to search for numbers 1, 2, 3, and 4, you need to transmit 1+2+4+8=15. Perform AND operations on the transmitted parameters and the search column in turn. If it is 0, do not search, and if it is 1, search. After the data is searched, the data id column is returned, and then the corresponding data can be queried in the first database according to the data id.
[0025] In this embodiment, two data storage databases are separately set up, one of which stores all information and the other stores partial index information, and the index columns are arranged according to weight numbers, and the two databases store the same ID arrangement. Therefore, when it is necessary to retrieve the information of one of the IDs, it is only necessary to quickly search from the index database according to the numbering parameters of the known information, obtain the information ID after retrieving the information, and return to the storage database for a quick search to obtain all the information of the ID. This greatly reduces the amount of retrieval when retrieving information in the database, and has a good effect of reducing the burden and speeding up the storage and retrieval of large amounts of data. Example
[0026] In order to better understand the above embodiments, Figure 2 As shown, the present invention also provides a flowchart of specific steps of a method for data storage and query, the method at least comprising: Step 201, conventionally storing data information through the first database, storing all the information of students and arranging them according to ID; Step 202, indexing and storing the data information through the second database, storing partial information of students and arranging them according to the same ID, and each different type of information forms different search columns according to the weight; Step 203, the search columns in the second database are numbered in sequence, and the numbering is a geometric progression, and is numbered 1, 2, 4, 8 ... n in sequence according to the weight; Step 204, when searching for data information, first transmit the number to be searched, then perform an AND operation on the transmitted search number parameter and the search column, and determine whether the result is 0. If so, end the search, otherwise, jump to step 205; Step 205, determine the search column included in the number parameter, then perform a search, and after the search result is found, obtain the ID to which the information belongs; Step 206, return to the first database, and perform a quick search based on the ID to which the information belongs to obtain complete information of the data with the same ID. Example
[0027] Based on the above embodiments, Figure 3 As shown, the present invention also provides a data storage and query device, which is used to support the data storage and query method of the above embodiment, and the data storage and query device includes: An information establishment module 301 is used to perform conventional storage of data information through a first database, store all information of students and arrange them according to IDs; The information establishment module 301 is also used to index and store the data information through the second database, store partial information of students and arrange them according to the same ID, and each different information type forms a different search column according to the weight; The information establishment module 301 is also used to sequentially number the search columns in the second database, and the numbering is a geometric progression; The information retrieval module 302 is used to retrieve data information. First, it quickly searches from the second database through an AND operation. When matching data information is retrieved, it quickly searches the ID column of the first database according to the ID to which the information belongs, and obtains complete information of the data.
[0028] Furthermore, the data storage and query device may run the data storage and query method described above. For specific implementation, please refer to the method embodiment, which will not be described in detail here.
[0029] Based on the above embodiment, the present invention further provides a device for data storage and query, the device for data storage and query comprising: A processor and a memory, wherein the processor is communicatively connected with the memory; In this embodiment, the memory may be implemented in any appropriate manner, for example, the memory may be a read-only memory, a mechanical hard disk, a solid-state hard disk, or a USB flash drive, etc.; the memory is used to store at least one executable instruction executed by the processor; In this embodiment, the processor can be implemented in any appropriate manner. For example, the processor can take the form of a microprocessor or a processor and a computer-readable medium storing computer-readable program code (such as software or firmware) that can be executed by the (micro)processor, logic gates, switches, application specific integrated circuits (ASIC), programmable logic controllers, and embedded microcontrollers, etc.; the processor is used to execute the executable instructions to implement the data storage and query method as described above.
[0030] Based on the above embodiments, the present invention further provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the method for storing and querying data as described above is implemented.
[0031] Those of ordinary skill in the art will appreciate that the modules and method steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0032] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices, equipment and modules can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0033] In the several embodiments provided in the present application, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation, such as multiple modules or units can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or equipment, which can be electrical, mechanical or other forms.
[0034] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0035] In addition, each functional module in each embodiment of the present invention may be integrated into one processing module, or each module may exist physically separately, or two or more modules may be integrated into one module.
[0036] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program instructions, such as a USB flash drive, a mobile hard disk, a read-only storage server, a random access storage server, a magnetic disk or an optical disk.
[0037] In addition, it should be noted that the combination of the various technical features in this case is not limited to the combination described in the claims of this case or the combination described in the specific embodiments. All technical features described in this case can be freely combined or combined in any way unless there is a contradiction between them.
[0038] It should be noted that the above examples are only specific embodiments of the present invention, and the present invention is obviously not limited to the above examples, and there are many similar variations. All variations directly derived or associated from the contents disclosed by the technicians in this field should fall within the protection scope of the present invention.
[0039] The above are only preferred embodiments of the present invention and are not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for storing and querying data, characterized in that: The following steps are involved: The data information is routinely stored through the first database, storing all the information of the students and arranging them according to ID; The data information is indexed and stored through the second database, partial information of students is stored and arranged according to the same ID, and each different type of information is composed of different search columns according to the weight; The search columns in the second database are numbered sequentially, and the numbering is a geometric progression; When retrieving data information, firstly, a quick search is performed from the second database through an AND operation. When matching data information is retrieved, the ID column of the first database is quickly searched according to the ID to which the information belongs, and the complete information of the data is obtained.
2. The data storage and query method according to claim 1, characterized in that: The first database is used to store the data information in a conventional manner, storing all the information of the students and arranging them according to the ID, including: Get the complete information of the students, and then store the information in the form of a table in the first database, with the information of the same student in one row and the information of the same category in one column, and arrange the IDs downward in sequence according to different data.
3. The data storage and query method according to claim 1, characterized in that: The data information is indexed and stored through the second database, partial information of students is stored and arranged according to the same ID, and each different type of information is composed of different search columns according to the weight, including: Obtain partial information of students, and then store the information in the second database in the form of a table, and arrange it in the same order as the data information table ID in the first database. Part of the data information is arranged in columns backwards according to the search weight.
4. The data storage and query method according to claim 1, characterized in that: The search columns in the second database are numbered sequentially, and the numbering is a geometric progression, including: The search columns of the data information table in the second database are numbered in sequence, and are numbered 1, 2, 4, 8...n in sequence according to the priority of the weight.
5. The data storage and query method according to claim 1, characterized in that: When retrieving data information, firstly, a quick search is performed from the second database through an AND operation. When matching data information is retrieved, the ID column of the first database is quickly searched according to the ID to which the information belongs, and complete information of the data is obtained, including: S1. When retrieving data information, first transmit the number to be retrieved, then perform an AND operation on the transmitted retrieval number parameter and the retrieval column to determine whether the result is 0. If not, continue to execute step S2, otherwise end; S2. Determine the search column included in the number parameter, then perform a search, and after the result is retrieved, obtain the ID to which the information belongs; S3. Return to the first database and perform a quick search based on the ID to which the information belongs to obtain complete information of the data with the same ID.
6. A data storage and query device, characterized in that: include: An information establishment module, which is used to perform conventional storage of data information through the first database, store all the information of students and arrange them according to ID; The information establishment module is also used to index and store the data information through the second database, store part of the students' information and arrange them according to the same ID, and each different type of information forms a different search column according to the weight; The information establishment module is also used to sequentially number the search columns in the second database, and the numbering is a geometric progression; The information retrieval module is used to retrieve data information. First, it quickly searches from the second database through an AND operation. When the matching data information is retrieved, it enters the first database ID column for quick search according to the ID to which the information belongs, and obtains the complete information of the data.
7. A data storage and query device, characterized in that: The data storage and query equipment includes: A processor and a memory, wherein the processor and the memory are communicatively connected with the processor; The memory is used to store at least one executable instruction executed by the processor, and the processor is used to execute the executable instruction to implement the data storage and query method according to any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method for storing and querying data according to any one of claims 1 to 5 is implemented.
