Database table design method, device, readable storage medium and electronic device

By distinguishing between computation type and non-computation type fields and storing non-computation type fields in string format, the storage space and maintenance complexity brought about by changes in database table structure is solved, and more efficient database table management and query performance is achieved.

CN113094356BActive Publication Date: 2025-01-17NEW ORIENTAL EDUCATION & TECH GRP CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110395348.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-04-13
Publication Date
2025-01-17
Estimated Expiration
2041-04-13

AI Technical Summary

Technical Problem

The database table structure changes frequently as demand changes, resulting in complex fields increasing, deleting and maintenance, and the storage space occupied continues to increase, affecting the performance and maintenance difficulty of the database.

Method used

By distinguishing between computed type and non-computed type fields in database tables, storing non-computed type fields in string format, and performing single-table queries and updates when needed, reducing field redundancy and optimizing storage space and query efficiency.

Benefits of technology

It effectively reduces the storage space of database tables, reduces the complexity of adding fields, and improves the maintenance efficiency and query performance of database tables.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113094356B_ABST
    Figure CN113094356B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a database table design method, device, readable storage medium and electronic device to reduce the storage space occupied by the database table and reduce the complexity of adding fields. The design method includes: in response to receiving a request to add a field, determining the type of the field to be added, the type including a calculation type and a non-calculation type; if the type of the field to be added is the non-calculation type, adding the field to be added to a first database table other than a Java object and a SQL query statement using a string format, so as to store the field to be added in the first database table in the string format.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular, to a database table design method, device, readable storage medium and electronic device. Background Art

[0002] In the process of business development, the database table is the most basic element in the database and the basis of other objects. Database tables are required to persist data in the database and implement addition, deletion, modification, and query. Usually, many database tables need to be created in a database, and the addition, deletion, modification, and list query functions of the tables need to be implemented.

[0003] Whenever existing requirements change, for example, when a new query condition or a new display field is added, fields must be added to the database table structure because the original database table structure does not meet the requirements. At the same time, many fields that were previously added due to certain requirements are abandoned, but in accordance with the principle of safety, fields are often not deleted, so there will be more and more fields in the database table, resulting in more and more storage space occupied by the database table, making the database table difficult to maintain. Summary of the invention

[0004] The purpose of the present disclosure is to provide a database table design method, device, readable storage medium and electronic device to reduce the storage space occupied by the database table and reduce the complexity of adding fields.

[0005] In order to achieve the above-mentioned object, the present disclosure provides a first aspect of a database table design method, comprising:

[0006] In response to receiving a request to add a field, determining a type of the field to be added, the type including a calculation type and a non-calculation type;

[0007] If the type of the field to be added is the non-calculated type, the field to be added is added to the first database table except the Java object and the SQL query statement in a string format, so as to store the field to be added in the first database table in the string format.

[0008] Optionally, the first target field stored in the string format in the first database table is a field in a second database table associated with the first database table; the method further includes:

[0009] In response to receiving a query request for the first target field, a single-table query is used to perform the query.

[0010] Optionally, the method further comprises:

[0011] In response to receiving an update request for a field stored in the string format in the first database table, determining whether the field to be updated has an identifier of a third database table associated with the first database table;

[0012] If there is an identifier of the third database table, determining the current content of the field to be updated in the third database table according to the identifier of the third database table;

[0013] The content of the to-be-updated field in the first database table is updated using the current content in the third database table, so that the content of the to-be-updated field in the first database table is consistent with its current content in the third database table.

[0014] Optionally, the method further comprises:

[0015] When it is detected that the content of the field stored in the string format in the first database table changes in the third database table, the update request is generated.

[0016] Optionally, the method further comprises:

[0017] Determine a second target field to be deleted from the fields stored in the string format in the first database table; and

[0018] The second target field is deleted, and the storage space corresponding to the second target field is released.

[0019] Optionally, determining the second target field to be deleted includes:

[0020] Counting the time when each field stored in the string format in the first database table was last used, and determining the second target field to be deleted according to the time when each field was last used and the current time; or

[0021] In response to receiving a field deletion request input by a user, the field included in the field deletion request is determined as a second target field to be deleted.

[0022] Optionally, the fields of the calculation type include at least one of the following: a field related to a filtering operation, a field related to a sorting operation, a field related to an aggregation operation, and an identifier corresponding to a field stored in the string format.

[0023] Optionally, the method further comprises:

[0024] If the type of the field to be added is the calculation type, the field to be added is added to the first database table using a single-value format.

[0025] Optionally, the string format is JSON format.

[0026] A second aspect of the present disclosure provides a database table design device, comprising:

[0027] A first determination module, configured to determine the type of the field to be added in response to receiving a request to add a field, wherein the type includes a calculation type and a non-calculation type;

[0028] The first adding module is used to add the field to be added to the first database table other than the Java object and the SQL query statement using a string format if the type of the field to be added is the non-calculation type, so as to store the field to be added in the first database table in the string format.

[0029] A third aspect of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method provided in the first aspect of the present disclosure.

[0030] A fourth aspect of the present disclosure provides an electronic device, including:

[0031] a memory having a computer program stored thereon;

[0032] A processor is used to execute the computer program in the memory to implement the steps of the method provided in the first aspect of the present disclosure.

[0033] Through the above technical solution, when it is determined that the type of the field to be added is a non-calculation type, the field to be added is added to the first database table using a string format. In this way, compared with the method of storing fields in a single-value format in the related art, the storage space of the database table can be effectively reduced, thereby facilitating the maintenance of the database table. In addition, when the field to be added is stored in a string format, it is only necessary to add the field to the first database table, without adding the corresponding field in the Java object and the SQL query statement. In this way, the complexity of adding fields is reduced and the efficiency of adding fields is improved.

[0034] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] The accompanying drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the following specific embodiments, they are used to explain the present disclosure but do not constitute a limitation of the present disclosure. In the accompanying drawings:

[0036] Figure 1 The figure is a flow chart of a method for designing a database table according to an exemplary embodiment.

[0037] Figure 2 The diagram is a schematic diagram of calculation type fields and non-calculation type fields in a course product query page according to an exemplary embodiment.

[0038] Figure 3 It is a schematic diagram of a database table according to an exemplary embodiment.

[0039] Figure 4 It is a schematic diagram of another database table according to an exemplary embodiment.

[0040] Figure 5 It is a schematic diagram of another database table according to an exemplary embodiment.

[0041] Figure 6 The figure is a block diagram of a device for designing a database table according to an exemplary embodiment.

[0042] Figure 7 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION

[0043] In the process of technology development, the biggest pain point is changing the database table structure, because it means that the previously designed database table is unreasonable. When the database table structure changes, a series of changes will occur, increasing the workload of developers. For example, when adding a new database field, taking the current typical spring mvc+spring+mybatis development framework as an example, the field is stored in a single-value format. On the one hand, the Java objects and corresponding SQL query statements in the program corresponding to the database table will also need to add fields, making the process of adding fields more cumbersome. On the other hand, the increasing number of fields in the database table will cause the storage space occupied by the database table to become larger and larger, making it difficult to maintain.

[0044] In view of this, the present disclosure provides a database table design method, device, readable storage medium and electronic device, which can reduce the storage space occupied by the database table and facilitate the maintenance of the database table on the one hand, and reduce the complexity of adding fields on the other hand.

[0045] The specific implementation of the present disclosure is described in detail below in conjunction with the accompanying drawings. It should be understood that the specific implementation described herein is only used to illustrate and explain the present disclosure, and is not used to limit the present disclosure.

[0046] Figure 1 FIG. 1 is a flow chart showing a method for designing a database table according to an exemplary embodiment. Figure 1 As shown, the method may include the following steps.

[0047] In step 101, in response to receiving a request to add a field, the type of the field to be added is determined, where the type includes a calculation type and a non-calculation type.

[0048] In the present disclosure, a field of calculation type refers to a field that needs to be calculated when used. For example, a field used as a screening condition, a field used as a query condition, a field involved in sorting, and so on. When using these fields, the background needs to perform certain processing on these fields, and then return the filtered, queried, or sorted data. In addition, considering that the identifier corresponding to the field is unique, when updating the field, there is no need to update the identifier corresponding to the field, that is, when updating the field stored in a string format, its corresponding identifier does not need to be updated, therefore, the identifier corresponding to the field stored in a string format may not be stored in a string format, that is, the field of calculation type may also be the identifier corresponding to the field stored in a string format. Therefore, in the present disclosure, the field of calculation type includes at least one of the following: a field related to a screening operation, a field related to a sorting operation, a field related to an aggregation operation, and an identifier corresponding to a field stored in a string format.

[0049] Among them, the fields related to the filtering operation will appear after the where in the SQL query statement to play a filtering role. If the field is stored in JSON format, the current MySQL also supports querying, but the query performance is poor. If you want to improve the performance, you can add indexes through virtual columns, which will make the overall operation more cumbersome. Therefore, the fields related to the filtering operation are usually not stored in string format.

[0050] The fields related to the aggregation operation are typically group by operations. If the group by operation is performed under the premise of paging, it can be performed in memory and stored in JSON format. If it is performed in the entire table, it cannot be stored in string format.

[0051] Non-calculated fields are fields that do not require calculations when used. For example, display fields can directly display data when used, and the background does not need to process the displayed data. In other words, such non-calculated fields do not affect the performance of the database table.

[0052] Example picture, Figure 2 FIG. 1 is a schematic diagram showing a calculation type field and a non-calculation type field in a course product query page according to an exemplary embodiment. Figure 2The fields in the query condition area are of calculation type, that is, when using the fields in this area, the background needs to perform query calculations before obtaining the queried data. The fields in the display column area are of non-calculation type, that is, when using the fields in this area, the background directly displays the data to be displayed without performing calculations.

[0053] In one possible manner, for the business to which the database table to be designed belongs, the fields that may be used in the business are pre-divided into non-calculated type fields and calculated type fields. For example, a non-calculated type field list and a calculated type field list are constructed respectively, and the non-calculated type fields are stored in the non-calculated type field list, and the calculated type fields are stored in the calculated type field list. In this way, when a request to add a field is received, it is determined in which of the above lists the field to be added is located. If it is in the non-calculated type field list, it is determined that the type of the field to be added is a non-calculated type. If it is in the calculated type field list, it is determined that the type of the field to be added is a calculated type.

[0054] In step 102, if the type of the field to be added is a non-calculated type, the field to be added is added to the first database table except the Java object and the SQL query statement in a string format, so as to store the field to be added in the first database table in a string format.

[0055] In order to avoid the drawbacks of storing all added fields in a single-value format, which results in a large number of fields in the database table, a large storage space occupied by the database table, and inconvenient maintenance, in the present disclosure, non-calculation type fields that do not require calculation processing can be stored in a string format. The string format is JSON format.

[0056] It is worth noting that when fields are stored in a database table in string format, the number of fields stored in the database table will not increase, only the strings corresponding to the fields stored in string format will become longer. In this way, the storage space of the database table will not be increased, which makes it easier to maintain the database.

[0057] For example, Figure 3 It is a schematic diagram of a database table according to an exemplary embodiment. Figure 4 FIG. 1 is a schematic diagram of another database table according to an exemplary embodiment. Figure 3 In the database table shown, fields are stored in single-value format, and the number of fields stored is 4. Figure 4In the database table shown, "student_name" and "student_code" are stored in JSON format. The number of fields stored in the database table is 3, but the string corresponding to the field "student_json" becomes longer. It is worth noting that compared with the increase in the number of fields, the increase in string length has less impact on the storage space of the database table. Therefore, storing the fields to be added in string format can effectively reduce the storage space of the database table and facilitate the maintenance of the database table.

[0058] In addition, when storing fields in string format, you only need to add the fields to the database table (for the convenience of subsequent distinction, the database table here is called the first database table), and there is no need to add corresponding fields in the Java object and SQL query statement. In this way, the operation of adding fields can be effectively reduced and the efficiency of adding fields can be improved.

[0059] By adopting the above technical solution, when it is determined that the type of the field to be added is a non-calculation type, the field to be added is added to the first database table using a string format. In this way, compared with the method of storing fields in a single-value format in the related art, the storage space of the database table can be effectively reduced, thereby facilitating the maintenance of the database table. In addition, when the field to be added is stored in a string format, it is only necessary to add the field to the first database table, without adding the corresponding field in the Java object and the SQL query statement. In this way, the complexity of adding fields is reduced and the efficiency of adding fields is improved.

[0060] If the type of the field to be added is a calculation type, that is, the background needs to perform calculation processing when using the field, at this time, in order to ensure the performance of the database table, the field to be added can be added to the first database table in a single-value format. In this way, on the basis of reducing the storage space of the database table, the performance of the database table can be improved as much as possible.

[0061] In actual applications, new functional requirements may be encountered. For example, in the development process of preset classes and workbench services, both services have requirements for class business-related fields, and need to query the standard department, course start date, minimum payroll department, etc. to which the class belongs in the class business. In the related art, when developing preset classes and workbench services, the usual design scheme is to only redundantly identify the class in the database table corresponding to the new business. When it is necessary to query the standard department, course start date, and minimum payroll department to which the class belongs, first, according to the redundant class identifier in the database table corresponding to the new business, determine the database corresponding to the class, and then query the data corresponding to the corresponding field in the database table corresponding to the class. That is, when querying the relevant fields in the class business in the new business, it is necessary to query the database corresponding to the class in association, that is, a joint table query is required. This results in a slow query speed and poor efficiency.

[0062] Therefore, in one embodiment, when designing the first database table for a new service, the first database table may be designed according to Figure 1 The design method of the database table shown in the figure is used for design. In this embodiment, since the non-calculation type fields can be stored in the string format, the storage space of the first database table is small. Therefore, all the fields required by the new business can be completely redundant in the first database table. That is, the first target field stored in the string format in the first database table is a field in the second database table associated with the first database table. In this way, during the query process, when a query request for the first target field is received, a single-table query method can be used for query, that is, the first target field is directly queried in the first database table, and there is no need to associate it with the second target data table to query from the second database table, which effectively improves the query efficiency.

[0063] In addition, according to Figure 1 After the method shown generates a database table, the fields in the database table can also be updated, wherein the fields stored in a single-value format can be updated with reference to the updating method of the fields in the database table in the prior art, which is not specifically limited in the present disclosure. The following will describe in detail the updating method for the fields stored in the string format in the first database table.

[0064] In the present disclosure, the process of updating the fields stored in the string format in the first database table is as follows:

[0065] (1) In response to receiving an update request for a field stored in a string format in a first database table, determining whether the field to be updated has an identifier of a third database table associated with the first database table.

[0066] When updating the content of the field stored in the string format, the update method can be set according to the tolerance of the business corresponding to the first database table to the data. For example, if the tolerance of the business corresponding to the first database table to the data is high, the asynchronous update method can be used, and if the tolerance of the business corresponding to the first database table to the data is low, the real-time update method can be used. This disclosure does not make specific limitations on this.

[0067] In one possible manner, it is possible to detect in real time or periodically whether the content of the field stored in the string format in the first database table has changed in the third database table. If so, an update request for the field stored in the string format in the first database table is generated.

[0068] In another possible manner, when a query request for a field stored in a string format in a first database table is received, it is determined whether the content of the field in the first database table is consistent with the content in a third database table associated with the first database table. If they are consistent, no update is required. If they are inconsistent, an update request for the field is generated.

[0069] In the present disclosure, it is possible to preset whether each field stored in a string format has an identifier of a third database table associated with the first database table. For example, it is assumed that it is preset that the field "student_json" stored in a string format does not have an identifier of a third database table associated with the first database table, and the field "class_json" stored in a string format has an identifier of a third database table associated with the first database table, and the identifier of the third database table is "1". In this way, if the field to be updated is the field "student_json" stored in a string format, it is determined that the field to be updated does not have an identifier of the third database table associated with the first database table. If the field to be updated is the field "class_json" stored in a string format, it is determined that the field to be updated has an identifier of the third database table associated with the first database table.

[0070] It is worth noting that, as mentioned above, the identifier corresponding to the field stored in the string format is usually stored in a single-value format, that is, the schematic diagram of the generated first database table is as follows: Figure 5 shown.

[0071] (2) If there is an identifier of the third database table, the current content of the field to be updated in the third database table is determined according to the identifier of the third database table.

[0072] (3) Using the current content in the third database table, update the content of the field to be updated in the first database table, so that the content of the field to be updated in the first database table is consistent with its current content in the third database table.

[0073] For example, suppose the field to be updated is Figure 5 The field "class_json" in the first database table shown in the figure is first determined according to the identifier of the third database table, and the current content of the field to be updated in the third database table is determined. For example, if the current contents of "class_name", "current_count", and "audit" in the third database table are respectively "Children Qingyun Class VIP", "5", and "Audited", then Figure 5The content of the field "class_json" in the first database table shown is updated from {"class_name":"Children's Qingyun Class VIP","current_count":"0","audit":"audited"} to {"class_name":"Children's Qingyun Class VIP","current_count":"5","audit":"audited"}, so that the content of the field to be updated in the first database table is consistent with its current content in the third database table, ensuring the accuracy of the content of the field to be updated in the first database table.

[0074] It is worth noting that the above only shows the updating of the attribute value of a certain attribute (for example, current_count) in the content of the field to be updated. In actual applications, the attributes in the content of the field to be updated can also be updated. Figure 5 The content of the field "class_json" in the first database table shown is updated from {"class_name": "Children Qingyun Class VIP", "current_count": "0", "audit": "audited"} to {"class_name": "Children Qingyun Class VIP", "student_code": "STU001, STU002", "audit": "audited"}. The present disclosure does not limit the specific content of the update.

[0075] In addition, in the present disclosure, when a field stored in a string format is no longer used as the business develops, it can be no longer maintained to save space in the database table. For example, the field no longer used can be deleted.

[0076] For example, first, a second target field to be deleted is determined among the fields stored in a string format in a first database table.

[0077] The method of determining the second target field to be deleted may include but is not limited to the following two methods: In the first method, a field stored in a string format that has not been used in the recent period of time may be determined as the second target field to be deleted. For example, the time when each field stored in a string format in the first database table was last used is counted, and the second target field to be deleted is determined based on the time when each field was last used and the current time. For example, a field whose difference between the time when it was last used and the current time is greater than a preset value may be determined as a field that has not been used in the recent period of time, that is, the field is determined as the second target field to be deleted.

[0078] In the second manner, the second target field to be deleted is defined by the user. For example, in response to receiving a field deletion request input by the user, the field included in the field deletion request is determined as the second target field to be deleted.

[0079] Afterwards, the second target field is deleted, and the storage space corresponding to the second target field is released.

[0080] After determining the second target field to be deleted in any of the above methods, the second target field can be directly deleted from the first database table, and at the same time, the storage space corresponding to the second target field can be released.

[0081] For example, assuming that the second target field to be deleted is Figure 5 The field "class_name" shown in the figure can be directly Figure 5 The "class_name": "Children Qingyun Class VIP" in the first database table is deleted, and the storage space corresponding to "class_name": "Children Qingyun Class VIP" is released. Among them, the storage space corresponding to the second target field can be occupied by other fields, such as "current_count": "0" and "audit": "audited".

[0082] By adopting the above technical solution, the fields stored in the string format can be directly deleted, and the storage space corresponding to the deleted fields can be released, and the released storage space can be used by other fields, thus improving the utilization rate of the storage space.

[0083] Based on the same inventive concept, the present disclosure also provides a device for designing a database table. Figure 6 FIG. 1 is a block diagram of a database table design device according to an exemplary embodiment. Figure 6 As shown, the database table design device 600 may include:

[0084] A first determination module 601 is used to determine the type of the field to be added in response to receiving a request to add a field, wherein the type includes a calculation type and a non-calculation type;

[0085] The first adding module 602 is used to add the field to be added to the first database table other than the Java object and the SQL query statement using a string format if the type of the field to be added is the non-calculation type, so as to store the field to be added in the first database table in the string format.

[0086] Optionally, the first target field stored in the string format in the first database table is a field in a second database table associated with the first database table; the device further includes:

[0087] The query module is configured to perform a query in a single table query manner in response to receiving a query request for the first target field.

[0088] Optionally, the device further comprises:

[0089] a second determination module, configured to, in response to receiving an update request for a field stored in the string format in the first database table, determine whether the field to be updated has an identifier of a third database table associated with the first database table;

[0090] a third determining module, configured to determine the current content of the to-be-updated field in the third database table according to the identifier of the third database table if there is an identifier of the third database table;

[0091] The updating module is used to update the content of the to-be-updated field in the first database table by using the current content in the third database table, so that the content of the to-be-updated field in the first database table is consistent with its current content in the third database table.

[0092] Optionally, the device further comprises:

[0093] A generating module is used to generate the update request when detecting that the content of the field stored in the string format in the first database table changes in the third database table.

[0094] Optionally, the device further comprises:

[0095] a fourth determining module, configured to determine, among the fields stored in the string format in the first database table, a second target field to be deleted; and

[0096] A deleting module is used to delete the second target field and release the storage space corresponding to the second target field.

[0097] Optionally, the fourth determination module is used to: count the time when each field stored in the string format in the first database table was last used, and determine the second target field to be deleted according to the time when each field was last used and the current time; or

[0098] In response to receiving a field deletion request input by a user, the field included in the field deletion request is determined as a second target field to be deleted.

[0099] Optionally, the device further comprises:

[0100] The second adding module is used to add the field to be added to the first database table using a single-value format if the type of the field to be added is the calculation type.

[0101] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0102] Figure 7 FIG. 1 is a block diagram of an electronic device according to an exemplary embodiment. Figure 7 As shown, the electronic device 700 may include: a processor 701 and a memory 702. The electronic device 700 may also include one or more of a multimedia component 703, an input / output (I / O) interface 704, and a communication component 705.

[0103] The processor 701 is used to control the overall operation of the electronic device 700 to complete all or part of the steps in the above-mentioned database table design method. The memory 702 is used to store various types of data to support the operation of the electronic device 700, and these data may include, for example, instructions for any application or method used to operate on the electronic device 700, and application-related data, such as contact data, sent and received messages, pictures, audio, video, etc. The memory 702 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (Static Random Access Memory, referred to as SRAM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, referred to as EEPROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, referred to as EPROM), programmable read-only memory (Programmable Read-Only Memory, referred to as PROM), read-only memory (Read-Only Memory, referred to as ROM), magnetic memory, flash memory, magnetic disk or optical disk. The multimedia component 703 may include a screen and an audio component. The screen may be, for example, a touch screen, and the audio component is used to output and / or input audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signal may be further stored in the memory 702 or sent through the communication component 705. The audio component also includes at least one speaker for outputting audio signals. The I / O interface 704 provides an interface between the processor 701 and other interface modules, and the other interface modules may be keyboards, mice, buttons, etc. These buttons may be virtual buttons or physical buttons. The communication component 705 is used for wired or wireless communication between the electronic device 700 and other devices. Wireless communication, such as Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G, 4G, NB-IOT, eMTC, or other 5G, etc., or a combination of one or more of them, is not limited here. Therefore, the corresponding communication component 705 may include: Wi-Fi module, Bluetooth module, NFC module, etc.

[0104] In an exemplary embodiment, the electronic device 700 can be implemented by one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), controllers, microcontrollers, microprocessors or other electronic components to execute the above-mentioned database table design method.

[0105] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, and when the program instructions are executed by a processor, the steps of the above-mentioned method for designing a database table are implemented. For example, the computer-readable storage medium may be the above-mentioned memory 702 including program instructions, and the above-mentioned program instructions may be executed by the processor 701 of the electronic device 700 to complete the above-mentioned method for designing a database table.

[0106] In another exemplary embodiment, a computer program product is further provided. The computer program product includes a computer program that can be executed by a programmable device. The computer program has a code portion for executing the above-mentioned database table design method when executed by the programmable device.

[0107] The preferred embodiments of the present disclosure are described in detail above in conjunction with the accompanying drawings; however, the present disclosure is not limited to the specific details in the above embodiments. Within the technical concept of the present disclosure, a variety of simple modifications can be made to the technical solution of the present disclosure, and these simple modifications all fall within the protection scope of the present disclosure.

[0108] It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, the present disclosure will not further describe various possible combinations.

[0109] In addition, various embodiments of the present disclosure may be arbitrarily combined, and as long as they do not violate the concept of the present disclosure, they should also be regarded as the contents disclosed by the present disclosure.

Claims

1. A method for designing a database table, characterized in that: include: In response to receiving a request to add a field, determining a type of the field to be added, the type including a calculation type and a non-calculation type; If the type of the field to be added is the non-calculation type, the field to be added is added to the first database table except the Java object and the SQL query statement in a string format, so as to store the field to be added in the first database table in the string format; The method further comprises: In response to receiving an update request for a field stored in the string format in the first database table, determining whether the field to be updated has an identifier of a third database table associated with the first database table; If there is an identifier of the third database table, determining the current content of the field to be updated in the third database table according to the identifier of the third database table; The content of the to-be-updated field in the first database table is updated using the current content in the third database table, so that the content of the to-be-updated field in the first database table is consistent with its current content in the third database table.

2. The design method according to claim 1, characterized in that: The first target field stored in the string format in the first database table is a field in a second database table associated with the first database table; the method further includes: In response to receiving a query request for the first target field, a single-table query is used to perform the query.

3. The design method according to claim 1, characterized in that: The method further comprises: When it is detected that the content of the field stored in the string format in the first database table changes in the third database table, the update request is generated.

4. The design method according to claim 1, characterized in that: The method further comprises: Determine a second target field to be deleted from the fields stored in the string format in the first database table; and The second target field is deleted, and the storage space corresponding to the second target field is released.

5. The design method according to claim 4, characterized in that: The determining the second target field to be deleted includes: Counting the time when each field stored in the string format in the first database table was last used, and determining the second target field to be deleted according to the time when each field was last used and the current time; or In response to receiving a field deletion request input by a user, the field included in the field deletion request is determined as a second target field to be deleted.

6. The design method according to any one of claims 1 to 5, characterized in that: The fields of the calculation type include at least one of the following: a field related to a filtering operation, a field related to a sorting operation, a field related to an aggregation operation, and an identifier corresponding to a field stored in the string format.

7. The design method according to any one of claims 1 to 5, characterized in that: The method further comprises: If the type of the field to be added is the calculation type, the field to be added is added to the first database table using a single-value format.

8. The design method according to any one of claims 1 to 5, characterized in that: The string format is JSON format.

9. A database table design device, characterized in that: include: A first determination module, configured to determine the type of the field to be added in response to receiving a request to add a field, wherein the type includes a calculation type and a non-calculation type; A first adding module, configured to add the field to be added to a first database table other than a Java object and a SQL query statement in a string format if the type of the field to be added is the non-calculation type, so as to store the field to be added in the first database table in the string format; The device also includes: a second determination module, configured to, in response to receiving an update request for a field stored in the string format in the first database table, determine whether the field to be updated has an identifier of a third database table associated with the first database table; a third determining module, configured to determine the current content of the to-be-updated field in the third database table according to the identifier of the third database table if there is an identifier of the third database table; The updating module is used to update the content of the to-be-updated field in the first database table by using the current content in the third database table, so that the content of the to-be-updated field in the first database table is consistent with its current content in the third database table.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method described in any one of claims 1 to 8 are implemented.

11. An electronic device, characterized in that: include: a memory having a computer program stored thereon; A processor, configured to execute the computer program in the memory to implement the steps of the method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Cloud platform-based alarm information storage method and device

    CN109639465A

  • Data query method and device

    CN111488371A