Data storage method and data reading method based on a relational database

By using a first preset table in a relational database to store file information and serial numbers, and making the second preset table indexable after the file is successfully written, the problem of incomplete storage of unstructured data in relational databases is solved, thus achieving data integrity and validity.

CN114238320BActive Publication Date: 2025-12-12HUNAN KYLIN XINAN TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202111497579.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-09
Publication Date
2025-12-12
Estimated Expiration
2041-12-09

AI Technical Summary

Technical Problem

Relational databases struggle to effectively store and query unstructured data, such as text, images, reports, and audio/video, and cannot meet the needs of complex business scenarios.

Method used

The first preset table stores file information and serial numbers, and sets it to be unindexable. It is then set to be indexable after the stored file is written to the second preset table, ensuring data integrity and validity.

Benefits of technology

It avoids the return of stored errors or incomplete data, ensuring data integrity and validity, and meeting the business needs of file storage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114238320B_ABST
    Figure CN114238320B_ABST
Patent Text Reader

Abstract

The embodiment of the application discloses a data storage method and a data reading method based on a relational database. In the storage method, a server acquires file information of a to-be-stored file corresponding to a file storage request according to the file storage request sent by a terminal; then, a serial number corresponding to the to-be-stored file is generated, the serial number and the file information are stored into a first preset table, and the state of the first preset table is set as not indexable; then, the serial number and the to-be-stored file are stored into a second preset table, that is, the server writes the to-be-stored file into data; finally, when the database generates storage success information corresponding to the to-be-stored file, the state of the first preset table is set as indexable. Thus, when the file storage fails, since the first preset table is not indexable and the second preset table does not contain the file name of the to-be-read file, the server cannot return the to-be-read file to the terminal, and the situation that the server sends the error data stored to the terminal is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of database, in particular to a data storage method and a data reading method based on a relational database. BACKGROUND

[0002] The relational database uses a two-dimensional table model to establish the relationship between data, and uses structured query language as the entrance of data reading and writing, so that the user can easily complete data storage and query.

[0003] However, for non-structured data such as text, pictures, various reports, images and audio and video, the relational database is difficult to effectively complete the storage and query of non-structured data, and is difficult to meet the needs of complex business scenarios. SUMMARY

[0004] Therefore, the present application provides a data storage method and a data reading method based on a relational database to improve the current situation that the relational database is difficult to effectively complete the storage and query of non-structured data.

[0005] In a first aspect, the present application provides a data storage method based on a relational database, applied to a server, wherein the server is provided with a relational database, the relational database includes a first preset table and a second preset table, and the method comprises:

[0006] In response to a file storage request, file information of a to-be-stored file corresponding to the file storage request is obtained, wherein the file information includes a file name and a file size;

[0007] A serial number corresponding to the to-be-stored file is generated, the serial number and the file information are stored in the first preset table, and the state of the first preset table is set to be not indexable;

[0008] The serial number and the to-be-stored file are stored in the second preset table;

[0009] When the relational database generates storage success information corresponding to the to-be-stored file, the state of the first preset table is set to be indexable.

[0010] Optionally, in an embodiment provided by the present application, the method further comprises:

[0011] When the relational database generates storage failure information corresponding to the to-be-stored file, the first preset table and the second preset table are deleted.

[0012] Optionally, in an embodiment provided by the present application, the file information further includes a current timestamp.

[0013] After the step of generating the serial number corresponding to the file to be stored, storing the serial number and the file information into the first preset table, and setting the state of the first preset table as not indexable, before the step of setting the state of the first preset table as indexable when the relational database generates the storage success information corresponding to the file to be stored, the method further comprises:

[0014] obtaining a current time and a longest time of being not indexable corresponding to the first preset table;

[0015] judging whether a time difference between the current time and the current timestamp exceeds the longest time of being not indexable;

[0016] if yes, deleting the first preset table and the second preset table.

[0017] Further, in an embodiment provided by the present application, the method further comprises:

[0018] if no, executing the step of setting the state of the first preset table as indexable when the relational database generates the storage success information corresponding to the file to be stored.

[0019] Optionally, in an embodiment provided by the present application, the step of storing the serial number and the data of the file to be stored into the second preset table comprises:

[0020] receiving the data of each block of the file to be stored and the serial number of each block;

[0021] storing the data of each block, the serial number of each block and the serial number into the second preset table.

[0022] In a second aspect, an embodiment of the present application provides a data reading method based on a relational database, applied to a server, wherein the server is provided with a relational database, and the data in the relational database is stored by the data storage method based on a relational database according to any one of the first aspect, and the method comprises:

[0023] in response to a file reading request, obtaining index information of a file to be read corresponding to the file reading request, wherein the index information comprises a file name and / or a file size;

[0024] if there is a first preset table matching the index information in the relational database, obtaining a serial number in the first preset table;

[0025] sending a file in a second preset table containing the serial number to a terminal corresponding to the file reading request.

[0026] In a third aspect, an embodiment of the present application provides a data storage device based on a relational database, applied to a server, wherein the server is provided with a relational database, the relational database comprises a first preset table and a second preset table, and the device comprises:

[0027] A storage response module is configured to respond to a file storage request, and acquire file information of a to-be-stored file corresponding to the file storage request, wherein the file information comprises a file name and a file size.

[0028] A first storage module is configured to generate a serial number corresponding to the to-be-stored file, store the serial number and the file information into the first preset table, and set a state of the first preset table as unindexable.

[0029] A second storage module is configured to store the serial number and the to-be-stored file into the second preset table.

[0030] A state updating module is configured to set the state of the first preset table as indexable when the relational database generates storage success information corresponding to the to-be-stored file.

[0031] In a fourth aspect, an embodiment of the present application provides a data reading device based on a relational database, applied to a server, wherein the server is provided with a relational database, and data in the relational database is stored by the data storage device based on a relational database as described in the third aspect, and the reading device comprises:

[0032] A reading response module is configured to respond to a file reading request, and acquire index information of a to-be-read file corresponding to the file reading request, wherein the index information comprises a file name and / or a file size.

[0033] An acquisition module is configured to acquire a serial number in a first preset table if the first preset table matching the index information exists in the relational database.

[0034] A sending module is configured to send a file in a second preset table containing the serial number to a terminal corresponding to the file reading request.

[0035] In a fifth aspect, an embodiment of the present application provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the computer program is executed on the processor to perform the data storage method based on a relational database as disclosed in any one of the first aspect, or the data reading method based on a relational database as disclosed in the second aspect.

[0036] In a sixth aspect, an embodiment of the present application provides a computer readable storage medium, and the computer readable storage medium stores a computer program. When the computer program runs on a processor, the computer program performs the data storage method based on a relational database as disclosed in any one of the first aspect, or the data reading method based on a relational database as disclosed in the second aspect.

[0037] In the data storage method based on a relational database provided by the embodiment of the present application, the server acquires file information of a to-be-stored file corresponding to a file storage request sent by a terminal according to the file storage request; then, the server generates a serial number corresponding to the to-be-stored file, stores the serial number and the file information into the first preset table, and sets a state of the first preset table as unindexable, so as to ensure that an external interface cannot acquire data in the first preset table before the to-be-stored file is successfully written into the relational database; then, the server stores the serial number and the to-be-stored file into the second preset table, that is, the server writes the to-be-stored file into the relational database; finally, when the relational database generates storage success information corresponding to the to-be-stored file, the server sets the state of the first preset table as indexable, so that the external interface can access the first preset table in the relational database to obtain the serial number of the to-be-read file, and then can acquire the file in the second preset table containing the serial number of the to-be-read file.

[0038] Therefore, if the to-be-stored file fails to be written into the second preset table, and the terminal wants to read the file by reading the file containing the to-be-read file, since the first preset table in the server is unindexable and the second preset table does not contain the file name of the to-be-read file, the server cannot return the to-be-read file to the terminal, thereby avoiding the case that the server returns error data or incomplete data to the terminal. Moreover, since the state of the first preset table is set as indexable only after the to-be-stored file is successfully written into the second preset table, the embodiment of the present application ensures the integrity and validity of the data returned by the server according to the request of the terminal, and meets the business requirement of storing the file into the relational database. BRIEF DESCRIPTION OF DRAWINGS

[0039] In order to more clearly illustrate the technical solutions of the present application, the following will briefly introduce the drawings needed to be used in the embodiments. It should be understood that the following drawings only show some of the embodiments of the present application, and therefore should not be regarded as a limitation to the protection scope of the present application. In each of the drawings, similar components are denoted by similar reference numerals.

[0040] Figure 1 Fig. 1 shows a flow diagram of the data storage method based on a relational database provided by the embodiment of the present application;

[0041] Figure 2A flowchart of a data reading method based on a relational database is shown.

[0042] Figure 3 A structural diagram of a data storage device based on a relational database is shown.

[0043] Figure 4 A structural diagram of a data reading device based on a relational database is shown. DETAILED DESCRIPTION

[0044] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments of the present application.

[0045] The components of the embodiments of the present application generally described and illustrated in the accompanying drawings can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but only represents selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present application.

[0046] Hereinafter, the terms "include", "have", and their conjugates used in various embodiments of the present application are only intended to denote a certain characteristic, number, step, operation, element, component, or combination of the foregoing, and should not be construed as excluding the presence or addition of one or more other characteristics, numbers, steps, operations, elements, components, or combinations thereof.

[0047] In addition, the terms "first", "second", "third", and the like are only used to distinguish descriptions, and cannot be understood as indicating or implying relative importance.

[0048] Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which various embodiments of the present application belong. The terms (such as those defined in commonly used dictionaries) will be interpreted as having a meaning that is the same as the contextual meaning in the relevant technical field and will not be interpreted as having an idealized or overly formal meaning unless clearly defined in various embodiments of the present application.

[0049] Reference Figure 1 , Figure 1A flowchart of the data storage method based on the relational database is shown, the data storage method based on the relational database provided by the embodiment of the application is applied to a server, the server is provided with a relational database, the relational database comprises a first preset table and a second preset table, and the method comprises the following steps of:

[0050] In S110, file information of a to-be-stored file corresponding to the file storage request is acquired in response to the file storage request, wherein the file information comprises a file name and a file size.

[0051] It can be understood that the data storage method based on the relational database provided by the embodiment of the application is applied to a server in a C / S (Client / Server) architecture, and is used for performing corresponding operations according to a request sent by a client, i.e., a terminal, such as storing a to-be-stored file into a storage of the server according to a file storage request and the to-be-stored file sent by the terminal.

[0052] Further, the server in the embodiment of the application is provided with the relational database, and the relational database is used for storing the to-be-stored file sent by the terminal. The relational database is provided with the first preset table and the second preset table, the first preset table is used for storing file information of the to-be-stored file, such as a file name and a file size, and the second preset table is used for storing the to-be-stored file.

[0053] Further, the process of storing the to-be-stored file into the server by the terminal can comprise the following steps of: generating a file storage request according to the file information of the to-be-stored file by the terminal, sending the file storage request to the server, generating a serial number of the to-be-stored file after the server receives the file storage request and parses the file information, storing the serial number and the file information into the first preset table, sending storage request confirmation information to the terminal, sending the to-be-stored file to the server after the terminal receives the storage request confirmation information, and storing the to-be-stored file into the second preset table by the server.

[0054] It should be understood that the specific process of storing the to-be-stored file into the server by the terminal can be set according to actual conditions, and the embodiment of the application does not limit this. For example, in an implementable manner, the terminal sends the to-be-stored file to the server at the same time of sending the file storage request, so that the server writes into the first preset table and the second preset table at the same time.

[0055] It should also be understood that the file information is used to identify the file in the database after the file to be stored is successfully written into the relational database. For example, if the terminal sends a data reading request containing the file name or file size to the server, the server searches the first preset table containing the file name or file size of the file to be read according to the file name or file size of the file to be read in the data reading request, and then determines the file to be read in the database, so as to send the file to be read to the terminal.

[0056] It should also be understood that the specific content of the file information can also be set according to actual conditions. For example, in one possible way, the file information includes the file name and the file size, and further includes the hash value corresponding to the file to be stored.

[0057] In addition, it should be clear that the data storage method based on the relational database disclosed in the embodiment of the application describes a storage process of a file to be stored, wherein one file to be stored corresponds to one first preset table and one second preset table. However, the embodiment of the application can be applied to the case that multiple files to be stored need to be stored, that is, when the server needs to store multiple files to be stored, the server will generate a corresponding first preset table and a second preset table for each file to be stored, so as to realize the storage of multiple files to be stored.

[0058] S120, generating a serial number corresponding to the file to be stored, storing the serial number and the file information into the first preset table, and setting the state of the first preset table as not indexable.

[0059] That is, after the server in the embodiment of the application obtains the file information of the file to be stored, a unique string corresponding to the file to be stored, that is, a serial number, is generated; then the serial number and the file information are written into the first preset table in the relational database, and the state of the first preset table is set as not indexable, that is, any element of the first preset table cannot be accessed by an external interface. It is not difficult to understand that if the state of the first preset table is not indexable, when the server wants to send the data in the first preset table to the terminal, the server cannot obtain and send the data in the first preset table to the terminal.

[0060] S130, storing the serial number and the file to be stored into the second preset table.

[0061] That is, the unique identification string of the file to be stored and the file to be stored are stored into the second preset table. It can be understood that the first preset table and the second preset table both contain the serial number of the file to be stored, and are associated with each other.

[0062] Optionally, in one embodiment provided by the embodiment of the application, S130 includes:

[0063] receiving data of each of the sub-blocks of the file to be stored and a serial number of each of the sub-blocks;

[0064] storing the data of each of the sub-blocks and the serial number and the sequence number into the second preset table.

[0065] That is, after the terminal splits the file to be stored into a plurality of sub-blocks, the terminal sends the plurality of sub-blocks corresponding to the file to be stored and the serial number of each of the sub-blocks to the server; the server stores the file to be stored into the second preset table according to the serial number and the sub-blocks, so as to complete the storage of the file to be stored. In an implementable manner, the serial number of the sub-blocks is the offset of the sub-block in the file to be stored.

[0066] Thus, when the file to be stored is large, the terminal can split the file to be stored so that the server stores the file to be stored in the form of sub-blocks, thereby realizing reasonable storage of the file to be stored and reducing the risk of errors in the process of storing the large file by the server.

[0067] It can be understood that the embodiments of the present application do not limit the specific process of the terminal sending the sub-blocks to the server and the server receiving the sub-blocks and storing them, which can be set according to actual conditions.

[0068] In an implementable manner, after the terminal splits the file to be stored into a plurality of sub-blocks and generates the serial numbers in sequence, the terminal sends the sub-blocks and the serial numbers of the sub-blocks to the server in sequence according to the serial number sequence of all the sub-blocks; after the server receives the sub-blocks and the serial numbers of the sub-blocks, the server writes the sub-blocks and the serial numbers of the sub-blocks into the second preset table, and after the writing is successful, the server sends the sub-block storage completion information to the terminal; after the terminal receives the sub-block storage completion information, the terminal sends the next sub-block and the serial number of the next sub-block to the server. Thus, the stable storage of the file to be stored is ensured.

[0069] In another implementable manner, the terminal sends a preset number of sub-blocks and corresponding serial numbers to the server at the same time, the server simultaneously receives the preset number of sub-blocks and corresponding serial numbers, and stores each of the sub-blocks and the serial number of each of the sub-blocks into the second preset table in a concurrent manner, thereby efficiently completing the file storage.

[0070] S140, when the relational database generates the storage success information corresponding to the file to be stored, setting the state of the first preset table as indexable.

[0071] That is, in the embodiments of the present application, after the file to be stored is successfully written into the second preset table of the relational database, that is, the relational database has verified that the file stored into the second preset table is complete and valid, a storage success information corresponding to the file to be stored is generated, so that the server executes the subsequent process.

[0072] When the relational database in the server generates storage success information corresponding to the to-be-stored file, the server sets the state of the first preset table in the relational database as indexable, that is, any element in the first preset table can be accessed by an external interface.

[0073] It should be understood that when the relational database stores non-structured data such as text, pictures, various reports, images, and audio and video, due to the architecture setting and storage mode of the relational database, part of the non-structured data is easy to be lost in the storage process, resulting in that the non-structured data stored in the relational database is incomplete or incorrect, and the terminal is difficult to obtain correct files from the relational database of the server.

[0074] Based on this, the embodiment of the application stores the file information of the to-be-stored file and the serial number for identifying the to-be-stored file by using the first preset table, stores the to-be-stored file by using the second preset table, and keeps the state of the first preset table as unindexable before the to-be-stored file is successfully written into the second preset table.

[0075] Therefore, if the to-be-stored file fails to be written into the second preset table in the relational database, and the terminal wants to read the file by including the file reading of the to-be-read file, since the first preset table in the server is unindexable, the second preset table does not include the file name of the to-be-read file, and thus the server cannot return the to-be-read file to the terminal, avoiding the case that the server returns incorrect or incomplete data stored to the terminal.

[0076] Moreover, since the state of the first preset table is set as indexable only after the to-be-stored file is successfully written into the second preset table, the integrity and validity of the data returned by the server according to the request of the terminal are ensured, and the business requirement of storing the file into the relational database is met.

[0077] Optionally, in an implementation provided by the embodiment of the application, after S130, the method further includes:

[0078] When the relational database generates storage failure information corresponding to the to-be-stored file, the first preset table and the second preset table are deleted.

[0079] That is, when the to-be-stored file is not successfully written into the relational database, so that the relational database generates storage failure information, the server deletes the first preset table and the second preset table corresponding to the to-be-stored file, to eliminate the waste of storage space caused by the to-be-stored file with storage failure.

[0080] Further, in an alternative, after deleting the first preset table and the second preset table corresponding to the to-be-stored file, the server further sends storage failure notification information corresponding to the to-be-stored file to the terminal, to inform the terminal that the to-be-stored file sent by the terminal fails to be written into the database, so that the terminal can re-send the file storage request and the to-be-stored file to the server, to make the server execute again the step of writing the to-be-stored file into the relational database.

[0081] Optionally, in an implementation provided by the embodiment of the application, the file information further comprises a current timestamp;

[0082] Further, after S120 and before S140, the method further comprises:

[0083] obtaining a current time and an unindexable longest time corresponding to the first preset table;

[0084] determining whether a time difference between the current time and the current timestamp exceeds the unindexable longest time;

[0085] if yes, deleting the first preset table and the second preset table.

[0086] That is, after writing the file information and the serial number into the first preset table and setting the state of the first preset table as unindexable, the server obtains an unindexable longest time corresponding to the first preset table, that is, the longest time during which the state of the first preset table is unindexable. It can be understood that the timestamp in the file information is used to represent the time at which the terminal generates the file storage request. It should be noted that in this implementation, the first preset table in the database is set with an unindexable longest time when it is initialized.

[0087] It can be understood that the storage process of the file should be completed within a preset time length, and if the file is not stored within the preset time length, it can be determined that an unpredictable error occurs when the server writes the to-be-stored file into the database, so that the storage process is terminated and the file cannot be stored within the preset time length. In the embodiment of the application, when the storage process of the to-be-stored file is completed, the state of the first preset table is set as indexable, so that whether the storage process of the to-be-stored file is normally executed can be determined by judging whether the time during which the state of the to-be-stored file is indexable exceeds the preset time length, that is, the unindexable longest time.

[0088] Specifically, the server obtains a current time, to obtain a time difference between the current time and the timestamp in the first preset table, and then determine whether the time difference exceeds the unindexable longest time, that is, whether the to-be-stored file is successfully written into the second preset table within the unindexable longest time.

[0089] Further, if the relational database includes multiple first preset tables in the state of being unindexable, the server obtains the current time, and then calculates the time difference between the current time and the time stamp in each first preset table in the state of being unindexable. Then, if the time difference of any first preset table exceeds the longest unindexable time, the server deletes the first preset table with the time difference exceeding the longest unindexable time.

[0090] It can also be understood that the timing of the server obtaining the current time is not limited in the embodiments of the present application, and can be set according to actual conditions. For example, in one possible way, the server obtains the current time constantly after the first preset table is set to be unindexable, and then calculates the time difference between the current time and the time stamp in the first preset table, so as to determine whether the time difference exceeds the longest unindexable time in real time.

[0091] In another possible way, the server obtains the current time every preset time interval after the first preset table is set to be unindexable, so as to reduce the resources required by the server for calculating the time difference.

[0092] In the case that the relational database includes multiple first preset tables in the state of being unindexable, the server can obtain the current time every preset time interval, and obtain all the first preset tables in the state of being unindexable in the relational database, so as to calculate the time difference and perform the corresponding judgment process.

[0093] If the time difference exceeds the longest unindexable time, the server determines that the file to be stored fails to be written, and deletes the first preset table and the second preset table, so as to avoid wasting the storage space of the server by the file failing to be written.

[0094] Optionally, after the server determines that the time difference exceeds the longest unindexable time and deletes the first preset table and the second preset table, the server can also send storage failure notification information corresponding to the file to be stored to the terminal, so that the terminal can send the file to be stored and the storage request to the server again, and the server performs the storage process again.

[0095] If the time difference does not exceed the longest unindexable time, that is, the file to be stored is successfully written into the second preset table within the longest unindexable time, the server normally performs the corresponding process, that is, S140.

[0096] Therefore, the embodiments of the present application further ensure the effective storage of the file to be stored, and avoid the situation that the server stores useless first preset tables and second preset tables when the file to be stored is written into the relational database.

[0097] Corresponding to the above data storage method based on a relational database, the embodiment of the application further provides a data reading method based on a relational database, referring to Figure 2 , Figure 2 The flowchart of the data reading method based on a relational database provided by the embodiment of the application is shown, the data reading method based on a relational database provided by the embodiment of the application is applied to a server, the server is provided with a relational database, and the data in the relational database is stored by the data storage method based on a relational database shown in the method embodiment. Figure 1 The method comprises the following steps:

[0098] S210, in response to a file reading request, obtaining index information of a file to be read corresponding to the file reading request, wherein the index information comprises a file name and / or a file size.

[0099] That is, the terminal sends a file reading request containing index information to the server, so that the server retrieves the first preset table according to the index information, that is, the server retrieves the first preset table containing the index information according to the index information.

[0100] S220, if the first preset table matching the index information exists in the relational database, obtaining the serial number in the first preset table.

[0101] That is, after the server searches the first preset table containing the index information, the serial number in the first preset table is obtained. It can be understood that, in the data storage method based on a relational database shown, Figure 1 In the data storage method based on a relational database shown, the first preset table and the second preset table both contain the unique serial number of the file to be stored, and then the server can search the second preset table according to the serial number.

[0102] Optionally, if the first preset table matching the index information does not exist in the relational database, the server sends file nonexistence notification information to the terminal corresponding to the file reading request.

[0103] S230, sending the file in the second preset table containing the serial number to the terminal corresponding to the file reading request.

[0104] That is, the server searches the second preset table according to the serial number in the first preset table, and sends the file in the second preset table to the terminal, so as to complete data reading.

[0105] Optionally, if the second preset table of the relational data in the server stores the file to be stored in the form of blocks and block serial numbers, the server will send each block to the terminal in an appended manner according to the serial number of each block; the blocks are spliced according to the order of the blocks sent by the server to obtain the complete file to be read.

[0106] Based on this, since the files that can be read in the server are all successfully written into the database, the situation that the terminal reads an error file or an incomplete file after the server fails to store is avoided, and the effective reading of the file to be read is ensured.

[0107] Corresponding to the above-mentioned data storage method based on a relational database, the embodiment of the application also provides a data storage device based on a relational database. Referring to Figure 3 , Figure 3 The structure of the data storage device based on a relational database provided by the embodiment of the application is shown, and the data storage device based on a relational database 300 provided by the embodiment of the application is applied to a server, the server is provided with a relational database, the relational database includes a first preset table and a second preset table, and the device includes:

[0108] The storage response module 310 is configured to respond to a file storage request, obtain file information of a file to be stored corresponding to the file storage request, and the file information includes a file name and a file size;

[0109] The first storage module 320 is configured to generate a serial number corresponding to the file to be stored, store the serial number and the file information into the first preset table, and set the state of the first preset table as unindexable;

[0110] The second storage module 330 is configured to store the serial number and the file to be stored into the second preset table;

[0111] The state updating module 340 is configured to set the state of the first preset table as indexable when the relational database generates storage success information corresponding to the file to be stored.

[0112] The data storage device based on a relational database provided by the embodiment of the application can realize Figure 1 the processes of the data storage method based on a relational database in the method embodiment, and can achieve the same technical effects. To avoid repetition, details are not repeated here.

[0113] Corresponding to the data reading method based on a relational database provided by the embodiment of the application, the embodiment of the application also provides a data reading device based on a relational database. Referring to Figure 4 ,Figure 4 A structural schematic diagram of the data reading device based on a relational database provided by the embodiment of the application is shown, and the data reading device based on a relational database provided by the embodiment of the application is applied to a server, wherein a relational database is arranged in the server, and data in the relational database is stored through a data storage device based on a relational database in the device as shown in the embodiment of the application. Figure 3 The data storage device based on a relational database in the device as shown in the embodiment of the application stores, and the device comprises:

[0114] The reading response module 410 is configured to respond to a file reading request and acquire index information of a file to be read corresponding to the file reading request, wherein the index information comprises a file name and / or a file size.

[0115] The acquisition module 420 is configured to acquire a serial number in a first preset table in the relational database if the first preset table matches the index information.

[0116] The sending module 430 is configured to send a file in a second preset table containing the serial number to a terminal corresponding to the file reading request.

[0117] The data reading device based on a relational database provided by the embodiment of the application can realize each process of the data reading method based on a relational database in the method embodiment, and can achieve the same technical effects, and for the sake of avoiding repetition, details are not described herein. Figure 2 The data reading method based on a relational database in the method embodiment, and can achieve the same technical effects, and for the sake of avoiding repetition, details are not described herein.

[0118] The embodiment of the application further provides a computer device comprising a memory and a processor, wherein the memory stores a computer program, and the computer program performs the data storage method based on a relational database as shown in the embodiment of the application or the data reading method based on a relational database as shown in the embodiment of the application when running on the processor. Figure 1 The data storage method based on a relational database as shown in the embodiment of the application, or the data reading method based on a relational database as shown in the embodiment of the application. Figure 2 The data storage method based on a relational database as shown in the embodiment of the application, or the data reading method based on a relational database as shown in the embodiment of the application.

[0119] The embodiment of the application further provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program, and the computer program performs the data storage method based on a relational database as shown in the embodiment of the application or the data reading method based on a relational database as shown in the embodiment of the application when running on the processor. Figure 1 The data storage method based on a relational database as shown in the embodiment of the application, or the data reading method based on a relational database as shown in the embodiment of the application. Figure 2 The data storage method based on a relational database as shown in the embodiment of the application, or the data reading method based on a relational database as shown in the embodiment of the application.

[0120] In several embodiments provided in the present application, it should be understood that the disclosed apparatus and method can also be implemented by other manners. The apparatus embodiments described above are merely illustrative, for example, the flowcharts and structural diagrams in the drawings show the possible implementation architecture, function and operation of the apparatus, method and computer program product according to the embodiments of the present application. In this regard, each block in the flowchart or block diagram can represent a module, a program segment or a part of code, which contains one or more executable instructions for implementing the specified logic function. It should also be noted that in alternative implementation manners, the functions noted in the blocks can also occur in different order from that noted in the drawings. For example, two consecutive blocks can actually be executed substantially in parallel, and they can also be executed in reverse order, depending on the functions involved. It should also be noted that each block in the structural diagram and / or flowchart, and the combination of blocks in the structural diagram and / or flowchart, can be implemented by a dedicated hardware-based system for executing the specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions.

[0121] In addition, each functional module or unit in the embodiments of the present application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.

[0122] 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 solutions of the present application essentially or the part of the prior art that contributes to the technical solutions or the part of the technical solutions can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing a computer device (which can be a smart phone, a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various media that can store program codes.

[0123] The above description is merely a specific implementation of the present application, but the protection scope of the present application is not limited thereto, and any person skilled in the art can easily think of changes or replacements within the technical range disclosed in the present application, which should be covered within the protection scope of the present application.

Claims

1. A data storage method based on a relational database, characterized by, The application is applied to a server, wherein a relational database is arranged in the server, the relational database comprises a first preset table and a second preset table, and the method comprises the following steps: In response to a file storage request, file information of a to-be-stored file corresponding to the file storage request is acquired, wherein the file information comprises a file name and a file size; A serial number corresponding to the to-be-stored file is generated, the serial number and the file information are stored in the first preset table, and a state of the first preset table is set as being not indexable; The serial number and the to-be-stored file are stored in the second preset table; When the relational database generates storage success information corresponding to the to-be-stored file, the state of the first preset table is set as being indexable; After the serial number and the to-be-stored file are stored in the second preset table, the method further comprises the following steps: When the relational database generates storage failure information corresponding to the to-be-stored file, the first preset table and the second preset table are deleted; The file information further comprises a current timestamp; After the serial number corresponding to the to-be-stored file is generated, the serial number and the file information are stored in the first preset table, the state of the first preset table is set as being not indexable, and before the state of the first preset table is set as being indexable when the relational database generates the storage success information corresponding to the to-be-stored file, the method further comprises the following steps: A current time and a longest non-indexable time corresponding to the first preset table are acquired; Whether a time difference between the current time and the current timestamp exceeds the longest non-indexable time is judged; If yes, the first preset table and the second preset table are deleted.

2. The method of claim 1, wherein, Further comprising: If no, the step of setting the state of the first preset table as being indexable when the relational database generates the storage success information corresponding to the to-be-stored file is executed.

3. The method of claim 1, wherein, The serial number and data of the to-be-stored file are stored in the second preset table, comprising the following steps: Data of each block of the to-be-stored file and a serial number of each block are received; Data of each block, the serial number of each block and the serial number are stored in the second preset table.

4. A data reading method based on a relational database, characterized by, The application is applied to a server, wherein a relational database is arranged in the server, data in the relational database is stored by the data storage method based on a relational database in any one of claims 1-3, and the method comprises the following steps: In response to a file reading request, index information of a to-be-read file corresponding to the file reading request is acquired, wherein the index information comprises a file name and / or a file size; If a first preset table matched with the index information exists in the relational database, a serial number in the first preset table is acquired; A file in a second preset table containing the serial number is sent to a terminal corresponding to the file reading request.

5. A relational database based data storage apparatus, characterized by, The application is applied to a server, wherein a relational database is arranged in the server, the relational database comprises a first preset table and a second preset table, and the device comprises the following steps: The storage response module is configured to, in response to a file storage request, acquire file information of a to-be-stored file corresponding to the file storage request, wherein the file information comprises a file name and a file size. The first storage module is configured to generate a serial number corresponding to the to-be-stored file, store the serial number and the file information into the first preset table, and set a state of the first preset table as being not indexable. The second storage module is configured to store the serial number and the to-be-stored file into the second preset table. The state updating module is configured to, when the relational database generates storage success information corresponding to the to-be-stored file, set the state of the first preset table as being indexable. After the serial number and the to-be-stored file are stored into the second preset table, the state updating module is further configured to, when the relational database generates storage failure information corresponding to the to-be-stored file, delete the first preset table and the second preset table. The file information further comprises a current timestamp. After the serial number corresponding to the to-be-stored file is generated, the serial number and the file information are stored into the first preset table, and the state of the first preset table is set as being not indexable, the state updating module is further configured to, before the state of the first preset table is set as being indexable when the relational database generates the storage success information corresponding to the to-be-stored file, acquire a current time and a longest non-indexable time corresponding to the first preset table; determine whether a time difference between the current time and the current timestamp exceeds the longest non-indexable time; and if yes, delete the first preset table and the second preset table.

6. A relational database-based data reading apparatus characterized by comprising: The server is applied to a server, and the server is provided with a relational database, and data in the relational database is stored by the data storage device based on a relational database in claim 5, and the reading device comprises: The reading response module is configured to, in response to a file reading request, acquire index information of a to-be-read file corresponding to the file reading request, wherein the index information comprises a file name and / or a file size. The acquisition module is configured to, if there is a first preset table matching the index information in the relational database, acquire a serial number in the first preset table. The sending module is configured to send a file in a second preset table containing the serial number to a terminal corresponding to the file reading request.

7. A computer device, comprising: The computer readable storage medium stores a computer program, and the computer program executes the data storage method based on a relational database in any one of claims 1-3 or the data reading method based on a relational database in claim 4 when running on the processor.

8. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program executes the data storage method based on a relational database in any one of claims 1-3 or the data reading method based on a relational database in claim 4 when running on the processor.

Citation Information

Patent Citations

  • A fusion method and system of a relational geological database and NoSQL

    CN108984598A

  • Data consistency implementation method and device and readable storage medium

    CN110515959A

  • Shared file management method and storage medium

    CN113254402A