CN108073712B - Method and device for deleting main data in information system and computer equipment - Google Patents
Method and device for deleting main data in information system and computer equipment Download PDFInfo
- Publication number
- CN108073712B CN108073712B CN201711404896.XA CN201711404896A CN108073712B CN 108073712 B CN108073712 B CN 108073712B CN 201711404896 A CN201711404896 A CN 201711404896A CN 108073712 B CN108073712 B CN 108073712B
- Authority
- CN
- China
- Prior art keywords
- main data
- reference count
- field
- count
- data
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/23—Updating
- G06F16/2358—Change logging, detection, and notification
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/21—Design, administration or maintenance of databases
- G06F16/215—Improving data quality; Data cleansing, e.g. de-duplication, removing invalid entries or correcting typographical errors
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/242—Query formulation
- G06F16/2433—Query languages
- G06F16/2445—Data retrieval commands; View definitions
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- Data Mining & Analysis (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Quality & Reliability (AREA)
- Mathematical Physics (AREA)
- Computational Linguistics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
A method for deleting master data in an information system includes: acquiring main data to be deleted and a corresponding main data identifier; searching the table name, the reference field name and the reference count of the corresponding reference table from a preset reference count table according to the main data identifier; sorting the reference counts to obtain a reference table and a reference field name corresponding to the maximum reference count in a sorting result; judging whether the reference table refers to the main data to be deleted or not; and if not, deleting the maximum reference count, returning to the step of sorting the reference count and acquiring the reference table and the reference field name corresponding to the maximum reference count in the sorting result, and deleting the main data to be deleted until the reference count is completely deleted.
Description
Technical Field
The present invention relates to the field of data processing, and in particular, to a method and an apparatus for deleting master data in an information system, a computer device, and a storage medium.
Background
When deleting main data in the existing information system, in order to ensure the consistency of the data, the reference relationship between the service data and the main data needs to be judged, and if the main data is not referred by the service data, the main data can be deleted. Where primary data refers to data shared between various systems throughout the enterprise (e.g., customer, supplier, account, and organizational unit related data). The general means for judging the reference relationship between the business data and the main data mainly include two: firstly, the external key relation of a database is utilized to determine the reference relation, a large number of external key relations are established in a complex business system by the method, and the performance of the system is reduced due to the increased storage space; and secondly, checking whether the reference is carried out based on the reference relation, wherein the basic method is to establish a reference relation table based on the relation of the tables, and when the reference is checked, circulating all the reference tables and judging one by one. The complexity of the method reference checking time is very unstable, the best condition is checking for 1 time, the worst condition is checking for N times, all application relation tables need to be checked, and the method is very random, so that the performance is poor and unstable, and the efficiency is low.
Disclosure of Invention
In view of the above, it is necessary to provide a method, an apparatus, a computer device, and a storage medium for deleting master data in an information system, which can improve efficiency and have stable performance.
A method for deleting master data in an information system includes:
acquiring main data to be deleted and a corresponding main data identifier;
searching the table name, the reference field name and the reference count of the corresponding reference table from a preset reference count table according to the main data identifier;
sorting the reference counts to obtain a reference table and a reference field name corresponding to the maximum reference count in the sorting result;
judging whether the reference table refers to the main data to be deleted or not;
and if not, deleting the maximum reference count, returning to the step of sorting the reference count, and acquiring the reference table and the reference field name corresponding to the maximum reference count in the sorting result, and deleting the main data to be deleted until the reference count is completely deleted.
In one embodiment, after determining whether the reference table references the main data, the method further includes:
and if the reference table refers to the main data to be deleted, prompting that the main data to be deleted cannot be deleted.
In one embodiment, the determining whether the reference table refers to the main data to be deleted includes:
and judging whether the data in the corresponding reference field name in the reference table has a main data identifier corresponding to the maximum reference count, if so, referring the main data to be deleted by the reference table, otherwise, if not, not referring the main data to be deleted by the reference table.
In one embodiment, the method further comprises:
and establishing a preset reference counting table, wherein the preset reference counting table records the corresponding relation among the main data identifier, the name of the reference table, the name of the reference field and the reference count.
In one embodiment, the establishing of the preset reference count table includes:
establishing attribute fields of a reference counting table, wherein the attribute fields comprise a main data identification field, a reference table name field, a reference field name field and a reference counting field;
acquiring service data and acquiring a main data identifier of the service data;
when the service data is written into a data table in the information system, acquiring a field in which the main data identifier is written in the data table;
and recording the reference count written in the field of the main data identifier, writing the main data identifier, the table name of the data table, the field name written in the main data identifier and the reference count of the record into the attribute field corresponding to the reference count table, and generating a preset reference count table.
In one embodiment, recording a reference count of a field written with the main data identifier, writing the main data identifier, a table name of the data table, the field name written with the main data identifier, and the reference count of the record into an attribute field corresponding to the reference count table, and generating a preset reference count table, includes:
establishing a reference counter for the field written with the main data identification, and after the service data is written into a data table in the information system, increasing the count of the reference counter to obtain a reference count;
and after the reference counter increases the count each time to obtain a reference count, writing the main data identifier, the table name of the data table, the field name written in the main data identifier and the reference count corresponding to the field written in the main data identifier into the attribute field corresponding to the reference count table to generate a preset reference count table.
In one embodiment, recording a reference count of a field written with the main data identifier, writing the main data identifier, a table name of the data table, the field name written with the main data identifier, and the reference count of the record into an attribute field corresponding to the reference count table, and generating a preset reference count table, includes:
establishing a reference counter for a field written with the main data identifier, after the service data is written into a data table in an information system, increasing the count of the reference counter to obtain a reference count, accumulating the reference counts corresponding to the service data to obtain a total reference count value, and storing the total reference count value into redis;
and writing the main data identifier, the table name of the data table, the field name written into the main data identifier and the total reference count value corresponding to the field written into the main data identifier and stored in the redis into the attribute field corresponding to the reference count table to generate a preset reference count table.
A master data deleting apparatus in an information system includes
The master data acquisition module is used for acquiring master data to be deleted and a corresponding master data identifier;
the searching module is used for searching the corresponding table name, reference field name and reference count of the reference table from the preset reference count table according to the main data identifier;
the reference information acquisition module is used for sequencing the reference counts and acquiring a reference table and a reference field name corresponding to the maximum reference count in the sequencing result;
the judging module is used for judging whether the reference table refers to the main data to be deleted;
and the deleting module is used for deleting the maximum reference count if the reference count is not the same as the reference count, returning to the step of sorting the reference count and acquiring the reference table and the reference field name corresponding to the maximum reference count in the sorting result, and deleting the main data to be deleted until the reference count is completely deleted.
A computer device comprises a memory, a processor and a computer program stored on the memory and capable of running on the processor, wherein the processor executes the computer program to realize the steps of the main data deleting method in any one of the information systems.
A computer storage medium having stored thereon a computer program which, when executed by a processor, implements the steps in the master data deletion method in any one of the above-mentioned information systems
According to the method, the device, the computer equipment and the storage medium for deleting the main data in the information system, the table name, the reference field name and the reference count of the reference table corresponding to the main data are searched from the preset reference count table according to the main data identification by acquiring the main data to be deleted and the corresponding main data identification. And sorting the reference counts, acquiring a reference table and a reference field name corresponding to the maximum reference count in the sorting result, and judging whether the reference table refers to the main data to be deleted. And if not, deleting the maximum reference count, returning to the step of sorting the reference count, and acquiring the reference table and the reference field name corresponding to the maximum reference count in the sorting result, and deleting the main data to be deleted until the reference count is completely deleted. Whether the main data is quoted by the reference table corresponding to the maximum reference count is judged in sequence according to the size of the reference count, the accidental detection is reduced, and the efficiency and the performance stability can be improved when the main data is deleted.
Drawings
FIG. 1 is a diagram of an application scenario of a method for deleting master data in an information system in one embodiment;
FIG. 2 is a flowchart illustrating a method for deleting master data in an information system according to an embodiment;
FIG. 3 is a flow diagram illustrating the establishment of a pre-reference count table in one embodiment;
FIG. 3-a is a diagram illustrating a comparison of a default reference count table and a reference table established in one embodiment;
FIG. 4 is a schematic diagram illustrating a process for generating a pre-set reference count table according to an embodiment;
FIG. 5 is a schematic diagram illustrating a process of generating a preset reference count table in another embodiment;
FIG. 6 is a block diagram showing a main data deletion apparatus in the information system according to the embodiment
FIG. 7 is a block diagram illustrating the structure of a count table setup module in one embodiment;
FIG. 8 is a diagram illustrating an internal structure of a computer device according to an embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
As shown in fig. 1, in one embodiment, a specific application scenario diagram of a master data deletion method in an information system is provided, which includes a server 102 and a terminal 104. The server 102 is network connected to the terminal 104. The terminal 104 is configured to receive a command to delete the main data, and then send the main data to be deleted to the server 102. The server 102 obtains the main data to be deleted and the corresponding main data identifier, and searches the table name, the reference field name and the reference count of the corresponding reference table from the preset reference count table according to the main data identifier. And sequencing the reference counts, and acquiring a reference table and a reference field name corresponding to the maximum reference count in the sequencing result. And judging whether the reference table refers to the main data to be deleted, if not, deleting the maximum reference count, returning to the step of sorting the reference counts and obtaining the reference table and the reference field name corresponding to the maximum reference count in the sorting result, and deleting the main data to be deleted until the reference counts are completely deleted.
As shown in fig. 2, in one embodiment, a flowchart of a master data deletion method in an information system is provided. The method is applied to the server 102 in fig. 1, and comprises the following steps:
s202, acquiring the main data to be deleted and the corresponding main data identification.
Each main data has a corresponding main data identifier, and when a user deletes the main data, the main data to be deleted and the corresponding main data identifier are obtained.
And S204, searching the corresponding table name, reference field name and reference count of the reference table from the preset reference count table according to the main data identifier.
And searching the table name of the reference table for referencing the main data, the reference field name for storing the main data identifier in the reference table and the reference count from the preset reference count table according to the main data identifier. The reference count table is a data table that records a reference relationship between the reference table and the main data. The reference count table records the identification of the main data, the table name of the reference table referencing the main data corresponding to the identification of the main data, the main data referenced by the specific field in the reference table, and the reference count. The reference table refers to a data table in which main data stored in the information system have a reference relationship. The reference count is the number of times the main data identified by the main data is referenced when the service data is saved in the information system data table.
S206, sorting the reference counts, and acquiring a reference table and a reference field name corresponding to the maximum reference count in the sorting result.
Since the main data is referred in different tables, a plurality of reference counts are found, and the found reference counts are sorted by using a sorting algorithm, which can use bubble sorting, selection sorting, insertion sorting, merge sorting, heap sorting, quick sorting, and the like.
And finding the reference table and the reference field name corresponding to the maximum reference count in the preset reference count table according to the sorting result. The main data of the main data identification corresponding to the maximum reference count is most probably actually referenced by the reference table, so that the reference table and the reference field name corresponding to the maximum reference count are directly obtained, subsequent processing is facilitated, and the processing efficiency of deleting the main data is improved.
And S208, judging whether the main data to be deleted is referenced by the reference table.
Specifically, it is determined whether the reference table refers to the main data to be deleted, and it is possible that data in the reference table that has a reference relationship with the main data has been deleted, that is, the number of references is recorded, but actually the main data is not referred to, and if the main data to be deleted is referred to, it is indicated that the main data is referred to by the reference table corresponding to the maximum reference count, then step S208A is directly performed. If the main data to be deleted is not referred to, it needs to be determined whether the reference table corresponding to the maximum reference count except the maximum reference count in the sorting result refers to the main data to be deleted, and then step S208a needs to be executed.
And S208A, prompting that the main data to be deleted cannot be deleted.
Specifically, in most cases, a master data is not deleted after being created and used for a certain period of time. And prompting a user that the main data is referenced and can not be deleted as long as the main data to be deleted is referenced by the reference table. Generally, after one judgment, it can be judged whether the reference table refers to the main data to be deleted, that is, whether the main data to be deleted can be deleted. Are generally referenced, i.e., cannot be deleted. The processing flow of deleting the main data is ended, whether the main data to be deleted is quoted or not is not judged in other reference tables, and the efficiency and the performance stability are improved.
S208a, delete the largest reference count.
And if the reference table does not reference the main data to be deleted, deleting the reference count, correcting the data, and not repeatedly judging when deleting the main data next time.
S208b, determine whether the reference count is deleted.
Specifically, each piece of main data is generally referred by a plurality of reference tables, when all the reference tables do not actually refer to the main data, the main data can be deleted, that is, whether the reference count is completely deleted is determined, if the reference count is completely deleted, step S208c is executed, otherwise, whether the reference table corresponding to the largest reference count in the remaining reference counts refers to the main data is continuously determined according to the sorting result. The process returns to step S206 to continue the execution.
S208c, the master data to be deleted is deleted.
The main data to be deleted can be deleted only if the main data is not actually referenced in all the reference tables. Generally, the main data cannot be deleted after being established and used in the information system for a period of time, and the main data to be deleted can be determined to be undeletable only by judging whether the main data to be deleted can be deleted or not by referring to the main data to be deleted by the reference table once.
In one embodiment, if a master data is just created, the user wants to delete the master data. At this time, the reference count of the main data does not exist in the preset reference count table, that is, the preset reference count table cannot find the main data identifier corresponding to the main data, the main data can be deleted immediately, the problem that when the main data is newly added or deleted, all reference relation tables need to be checked for judgment is solved, and the stability of efficiency and performance is improved.
In the above embodiment, by acquiring the main data to be deleted and the corresponding main data identifier, the table name, the reference field name, and the reference count of the reference table corresponding to the main data are searched from the preset reference count table according to the main data identifier. And sorting the reference counts, acquiring a reference table and a reference field name corresponding to the maximum reference count in the sorting result, and judging whether the reference table refers to the main data to be deleted. If not, deleting the maximum reference count, and returning to the step S206 until the reference count is completely deleted, and deleting the main data to be deleted. If so, prompting that the main data to be deleted cannot be deleted. Whether the main data is quoted by the reference table corresponding to the maximum reference count is judged in sequence according to the size of the reference count, the accidental detection is reduced, and the performance stability can be improved when the main data is deleted.
In one embodiment, the determining whether the reference table refers to the main data to be deleted includes: and judging whether the data in the corresponding reference field name in the reference table has a main data identifier corresponding to the maximum reference count, if so, referring the main data to be deleted by the reference table, otherwise, if not, not referring the main data to be deleted by the reference table.
If the main data is to be referred in the reference table, a field is provided for storing a main data identifier corresponding to the main data, namely, whether the main data identifier corresponding to the maximum reference count exists in the data in the corresponding reference field name in the reference table is judged, if so, the reference table refers to the main data to be deleted, otherwise, if not, the reference table does not refer to the main data to be deleted.
In one embodiment, the method for deleting master data in an information system further comprises: and establishing a preset reference counting table, wherein the preset reference counting table records the corresponding relation among the main data identifier, the name of the reference table, the name of the reference field and the reference count.
In the information system, a preset reference counting table is established, the corresponding relation of the main data identification, the reference table name, the reference field name and the reference count is recorded in the preset reference counting table, and when the business data are stored in the information system, the main data identification, the reference table name, the reference field name and the reference count corresponding to the business data are written in the preset reference counting table.
As shown in FIG. 3, in one embodiment, establishing a preset reference count table includes:
s302, establishing attribute fields of the reference counting table, wherein the attribute fields comprise a main data identification field, a reference table name field, a reference field name field and a reference counting field.
A reference count table is established in an information system, and attribute fields of the reference count table comprise a main data identification field, a reference table name field, a reference field name field and a reference count field. Wherein, the attribute field refers to the object required by the reference count table during the establishment
S304, acquiring the service data and acquiring the main data identifier of the service data.
Acquiring service data, wherein the service data refers to data in which a service specifically occurs, and the data volume is more and more along with time migration. And acquiring the main data identification of the service object according to the service data. Namely, by analyzing each attribute value in the business object, the reference relation with the main data is determined, and the main data identifier corresponding to the main data is obtained. For example, business data of purchased materials is acquired, and main data of the business data of the acquired materials is identified as ABC. The relevant attributes of the material, the size, specification, color, quantity, price of the material. . . . And the like are main data of the material ABC. Generating a business data, and when generating a purchase order, acquiring different main data, size, color, quantity and price of the purchase material; and the number of the supplier, the credit degree, the warehouse number stored after purchase and the like are the service data.
S306, when the service data is written into the data table in the information system, the field written with the main data identification in the data table is obtained.
When the service data is written into a data table in the information system, a field in which the main data identifier is written in the data table is obtained. For example, when business data for purchasing material is to be written into a purchase order table in the information system, the field in which material ABC is written is obtained as a material field.
And S308, recording the reference count of the field written with the main data identifier, writing the main data identifier, the table name of the data table, the field name written with the main data identifier and the reference count of the record into the attribute field corresponding to the reference count table, and generating a preset reference count table.
Recording the reference count of the field written with the main data identifier, writing the main data identifier of the service data, the table name of the data table to be written, the field name written with the main data identifier and the reference count of the record into the attribute field corresponding to the reference count table, and generating a preset reference count table. As shown in fig. 3-a, when the service data of the material ABC is to be written in the purchase order table, a field in which the main data identifier ABC is written in the purchase order table is obtained as a material field, then ABC is written in the main data identifier field of the reference count table, the purchase order table is written in the reference table name, the material is written in the reference field name, and then the reference count is written 1000 times, so that a preset reference count table is obtained.
In the above embodiment, the preset reference count table is generated by establishing an attribute field of the reference count table, acquiring the service data, acquiring the main data identifier of the service data, acquiring a field in which the main data identifier is written in the data table, finally recording the reference count of the field in which the main data identifier is written, and writing the main data identifier, the table name of the data table, the field name in which the main data identifier is written, and the reference count of the record into the attribute field corresponding to the reference count table. By establishing the preset reference counting table, whether the main data can be deleted or not is judged according to the reference counting in the preset reference counting table when the main data is deleted, and the efficiency and the performance stability when the main data is deleted are improved.
As shown in fig. 4, in an embodiment, recording a reference count written in a field of the main data identifier, writing the main data identifier, a table name of the data table, a field name written in the main data identifier, and the reference count of the record into an attribute field corresponding to the reference count table, and generating the preset reference count table includes:
s402, establishing a reference counter for the field written with the main data identification, and after the service data is written into a data table in the information system, increasing the count of the reference counter to obtain a reference count.
Specifically, each piece of main data has a plurality of reference counters, that is, in different tables, the fields written with the main data identifiers are different, and a reference counter is established for each corresponding field, and after the service data is written into the data table in the information system, the reference counters increase the count to obtain a reference count, that is, when the service data is written into the information system, the main data is referred, and each reference increases the counter by 1 to obtain a reference count.
S404, after the reference counter increases the count each time to obtain the reference count, writing the main data identifier, the table name of the data table, the field name written in the main data identifier and the reference count corresponding to the field written in the main data identifier into the attribute field corresponding to the reference count table to generate a preset reference count table.
And writing the reference count, the main data identifier, the table name of the data table and the field name written with the main data identifier, which are obtained after the business data are written into the data table in the information system each time, into the attribute field corresponding to the reference count table to generate a preset reference count table.
In the above embodiment, the reference counter is established for the field written with the main data identifier, the reference counter increases the count to obtain the reference count each time the service data is written into the data table, and finally the obtained reference count, the main data identifier, the table name of the data table, and the field name written with the main data identifier are written into the attribute field corresponding to the reference count table to generate the preset reference count table.
As shown in fig. 5, in an embodiment, recording a reference count written in a field of the main data identifier, writing the main data identifier, a table name of the data table, a field name written in the main data identifier, and the reference count of the record into an attribute field corresponding to the reference count table, and generating the preset reference count table includes:
s502, a reference counter is established for the field written with the main data identification, when the service data is written into a data table in the information system, the reference counter increases the count to obtain a reference count, the reference counts corresponding to the service data are accumulated to obtain a total reference count value, and the total reference count value is stored in redis.
Specifically, a reference counter is established for a field written with a main data identifier, when a plurality of users write service data into a data table in an information system and each user writes the service data into the data table in the information system, the reference counter increases the count to obtain a reference count corresponding to the service data to be written by each user, all the reference counts are accumulated to obtain a total reference count value of the service data, and the total reference count value is stored in redis, wherein redis is an open-source data structure server stored in a memory and can be used as a database, a cache and a message queue agent. It supports data types such as strings, hash tables, lists, collections, ordered collections, bitmaps, Hyperlogs, etc.
S504, writing the main data identification, the table name of the data table, the field name written in the main data identification and the total value of the reference count corresponding to the field written in the main data identification, which is stored in the redis, into the attribute field corresponding to the reference count table, and generating a preset reference count table.
Specifically, the main data identifier, the table name of the data table, the field name written in the main data identifier, and the total reference count value stored in the redis and corresponding to the field written in the main data identifier are written into the attribute field corresponding to the reference count table at regular time, so as to generate the preset reference count table.
In the above embodiment, the total value of the reference count is obtained by accumulating the reference counts corresponding to the service data, the total value of the reference count is stored in redis, and then the main data identifier, the table name of the data table, the field name written in the main data identifier, and the total value of the reference count corresponding to the field written in the main data identifier stored in redis are written in the attribute field corresponding to the reference count table, so as to generate the preset reference count table. The obtained reference count is stored in the redis, and then the total value of the reference count stored in the redis is written into the preset reference count table, so that the stability of performance is improved.
In one embodiment, after the preset reference count table is generated, when the service data is written into the data table of the information system, the identifier of the main data in the service data and the field written with the identifier of the main data in the data table are obtained, and a new reference count written into the field written with the identifier of the main data is recorded. And acquiring a reference count corresponding to the identification of the main data in the reference count table, accumulating the reference count in the reference count table and the recorded new reference count to obtain a total reference count, and writing the total reference count into a reference count field corresponding to the main data identification in the reference count table, so that the reference count is updated, and the reference count obtained when the main data is deleted can be more accurate.
As shown in fig. 6, in an embodiment, a master data deleting apparatus in an information system includes a master data obtaining module 602, a finding module 604, a reference information obtaining module 606, a determining module 608, and a deleting module 610, where:
a master data obtaining module 602, configured to obtain master data to be deleted and a corresponding master data identifier.
The searching module 604 is configured to search the table name, the reference field name, and the reference count of the corresponding reference table from the preset reference count table according to the main data identifier.
And a reference information obtaining module 606, configured to sort the reference counts, and obtain a reference table and a reference field name corresponding to the largest reference count in the sorted results.
The determining module 608 is configured to determine whether the reference table refers to the main data to be deleted.
And the deleting module 610 is used for deleting the maximum reference count if the reference count is not the same as the reference count, returning to the step of sorting the reference count, and acquiring the reference table and the reference field name corresponding to the maximum reference count in the sorting result until the reference count is completely deleted, and deleting the main data to be deleted.
In the above embodiment, the main data to be deleted and the corresponding main data identifier are obtained by the main data obtaining module 602, and the table name, the reference field name, and the reference count of the corresponding reference table are found from the preset reference count table according to the main data identifier in the searching module 604. The reference information obtaining module 606 obtains the reference table and the reference field corresponding to the maximum reference count, the determining module 608 determines whether the reference table references the main data to be deleted, and the deleting module 610 deletes the main data to be deleted, thereby ensuring the stability of improving the efficiency and performance during the main data deleting process.
In one embodiment, a master data deleting apparatus in an information system further includes:
and the non-deleting module is used for prompting that the main data to be deleted cannot be deleted if the main data to be deleted is referred by the reference table.
In one embodiment, the determining module 608 includes:
and the identification judging module is used for judging whether the main data identification corresponding to the maximum reference count exists in the data in the corresponding reference field name in the reference table, if so, the reference table refers to the main data to be deleted, otherwise, if not, the reference table does not refer to the main data to be deleted.
In one embodiment, a master data deleting apparatus in an information system further includes:
and the counting table establishing module is used for establishing a preset reference counting table, and the preset reference counting table records the corresponding relation among the main data identifier, the name of the reference table, the name of the reference field and the reference count.
As shown in fig. 7, in one embodiment, the count table establishing module includes:
a field establishing module 702, configured to establish an attribute field of the reference count table, where the attribute field includes a main data identification field, a reference table name field, a reference field name field, and a reference count field.
The identifier obtaining module 704 is configured to obtain the service data, and obtain a main data identifier of the service data.
A write field obtaining module 706, configured to obtain a field in the data table, where the main data identifier is written, when the service data is written in the data table in the information system.
The count table generating module 708 is configured to record a reference count of a field written with the main data identifier, write the main data identifier, the table name of the data table, the field name written with the main data identifier, and the reference count of the record into an attribute field corresponding to the reference count table, and generate a preset reference count table.
In one embodiment, the count table generation module includes:
and the counter establishing module is used for establishing a reference counter for the field written with the main data identifier, and after the service data is written into a data table in the information system, the reference counter increases the count to obtain a reference count.
And the writing module is used for writing the main data identifier, the table name of the data table, the field name written with the main data identifier and the reference count corresponding to the field written with the main data identifier into the attribute field corresponding to the reference count table after the reference counter increases the count to obtain the reference count each time, and generating a preset reference count table.
In one embodiment, the count table generation module includes:
and the count storage module is used for establishing a reference counter for the field written with the main data identifier, increasing the count of the reference counter after the service data is written into a data table in the information system to obtain a reference count, accumulating the reference counts corresponding to the service data to obtain a total reference count value, and storing the total reference count value into redis.
And the attribute field writing module is used for writing the main data identifier, the table name of the data table, the field name written into the main data identifier and the total reference count value which is stored in the redis and corresponds to the field written into the main data identifier into the attribute field corresponding to the reference count table, and generating a preset reference count table.
As shown in FIG. 8, in one embodiment, a computer device is provided comprising a processor, memory, storage medium, network interface connected by a system bus. The memory includes an internal memory and a nonvolatile storage medium, the nonvolatile storage medium of the computer apparatus stores therein an operating system and a computer program of a master data deleting device in an information system, the computer program of the master data deleting device in the information system is used to implement a master data deleting method in the information system. The processor of the computer device is for providing computing and control capabilities, and is configured to perform a master data deletion method in an information system. The internal memory in the computer device provides an environment for running the computer program in the nonvolatile storage medium. The network interface in the computer equipment is used for acquiring the main data to be deleted, the corresponding main data identification and the like. The computer device may be a desktop computer, or may be a mobile terminal such as a smart phone, a tablet computer, or a personal digital assistant. Those skilled in the art will appreciate that the architecture shown in fig. 8 is merely a block diagram of some of the structures associated with the inventive arrangements and is not intended to limit the computing devices to which the inventive arrangements may be applied, as a particular computing device may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
A computer-readable storage medium on which a computer program is stored, which when executed by a processor, implements the steps of the master data deletion method in the above-described information system: acquiring main data to be deleted and a corresponding main data identifier; searching the table name, the reference field name and the reference count of the corresponding reference table from a preset reference count table according to the main data identifier; sorting the reference counts to obtain a reference table and a reference field name corresponding to the maximum reference count in the sorting result; judging whether the reference table refers to the main data to be deleted or not; and if not, deleting the maximum reference count, returning to the step of sorting the reference count, and acquiring the reference table and the reference field name corresponding to the maximum reference count in the sorting result, and deleting the main data to be deleted until the reference count is completely deleted.
In one embodiment, after determining whether the reference table references the main data, the method further comprises: and if the reference table refers to the main data to be deleted, prompting that the main data to be deleted cannot be deleted.
In one embodiment, the determining whether the reference table refers to the main data to be deleted includes: and judging whether the data in the corresponding reference field name in the reference table has a main data identifier corresponding to the maximum reference count, if so, referring the main data to be deleted by the reference table, otherwise, if not, not referring the main data to be deleted by the reference table.
In one embodiment, the method further comprises: and establishing a preset reference counting table, wherein the preset reference counting table records the corresponding relation among the main data identifier, the name of the reference table, the name of the reference field and the reference count.
In one embodiment, establishing a preset reference count table includes: establishing attribute fields of a reference counting table, wherein the attribute fields comprise a main data identification field, a reference table name field, a reference field name field and a reference counting field; acquiring service data and acquiring a main data identifier of the service data; when the service data is written into a data table in the information system, acquiring a field in which the main data identifier is written in the data table; and recording the reference count written in the field of the main data identifier, writing the main data identifier, the table name of the data table, the field name written in the main data identifier and the reference count of the record into the attribute field corresponding to the reference count table, and generating a preset reference count table.
In one embodiment, recording a reference count of a field written with the main data identifier, writing the main data identifier, a table name of the data table, the field name written with the main data identifier, and the reference count of the record into an attribute field corresponding to the reference count table, and generating a preset reference count table, includes: establishing a reference counter for the field written with the main data identification, and after the service data is written into a data table in the information system, increasing the count of the reference counter to obtain a reference count; and after the reference counter increases the count each time to obtain a reference count, writing the main data identifier, the table name of the data table, the field name written in the main data identifier and the reference count corresponding to the field written in the main data identifier into the attribute field corresponding to the reference count table to generate a preset reference count table.
In one embodiment, recording a reference count of a field written with the main data identifier, writing the main data identifier, a table name of the data table, the field name written with the main data identifier, and the reference count of the record into an attribute field corresponding to the reference count table, and generating a preset reference count table, includes: establishing a reference counter for a field written with the main data identifier, after the service data is written into a data table in an information system, increasing the count of the reference counter to obtain a reference count, accumulating the reference counts corresponding to the service data to obtain a total reference count value, and storing the total reference count value into redis; and writing the main data identifier, the table name of the data table, the field name written into the main data identifier and the total reference count value corresponding to the field written into the main data identifier and stored in the redis into the attribute field corresponding to the reference count table to generate a preset reference count table.
It will be understood by those skilled in the art that all or part of the processes in the methods of the embodiments described above may be implemented by a computer program, which is stored in a non-volatile computer-readable storage medium, and executed by at least one processor in a computer system, so as to implement the processes of the embodiments including the methods described above. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), or the like.
The technical features of the embodiments described above may be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the embodiments described above are not described, but should be considered as being within the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present invention, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the inventive concept, which falls within the scope of the present invention. Therefore, the protection scope of the present patent shall be subject to the appended claims.
Claims (10)
1. A method for deleting master data in an information system, comprising:
acquiring main data to be deleted and a corresponding main data identifier;
according to the main data identification, searching a table name, a reference field name and a reference count of a corresponding reference table from a preset reference count table, wherein the reference count refers to the number of times that main data corresponding to the main data identification are referred;
sorting the reference counts to obtain a reference table and a reference field name corresponding to the maximum reference count in a sorting result;
judging whether the reference table refers to the main data to be deleted or not;
and if not, deleting the maximum reference count, returning to the step of sorting the reference count, and acquiring the reference table and the reference field name corresponding to the maximum reference count in the sorting result, and deleting the main data to be deleted until the reference count is completely deleted.
2. The method of claim 1, after determining whether the reference table references the primary data, further comprising:
and if the reference table refers to the main data to be deleted, prompting that the main data to be deleted cannot be deleted.
3. The method of claim 1, wherein determining whether the reference table references the master data to be deleted comprises:
and judging whether a main data identifier corresponding to the maximum reference count exists in the data corresponding to the reference field name in the reference table, if so, referring to the main data to be deleted by the reference table, otherwise, not referring to the main data to be deleted by the reference table.
4. The method of claim 1, further comprising:
and establishing the preset reference counting table, wherein the preset reference counting table records the corresponding relation among the main data identifier, the name of the reference table, the name of the reference field and the reference count.
5. The method of claim 4, wherein the establishing the preset reference count table comprises:
establishing attribute fields of a reference counting table, wherein the attribute fields comprise a main data identification field, a reference table name field, a reference field name field and a reference counting field;
acquiring service data and acquiring a main data identifier of the service data;
when the service data is written into a data table in an information system, acquiring a field in which the main data identifier is written in the data table;
and recording the reference count of the field written with the main data identifier, and writing the main data identifier, the table name of the data table, the field name written with the main data identifier and the reference count of the record into the attribute field corresponding to the reference count table to generate the preset reference count table.
6. The method of claim 5, wherein the recording the reference count of the field written with the main data identifier, writing the main data identifier, the table name of the data table, the field name written with the main data identifier, and the reference count of the record into the attribute field corresponding to the reference count table, and generating the preset reference count table comprises:
establishing a reference counter for the field written with the main data identification, and after the service data is written into a data table in an information system, increasing the count of the reference counter to obtain a reference count;
and writing the main data identifier, the table name of the data table, the field name written with the main data identifier and the reference count corresponding to the field written with the main data identifier into the attribute field corresponding to the reference count table after the reference counter increases the count each time to obtain the reference count, and generating the preset reference count table.
7. The method of claim 5, wherein the recording the reference count of the field written with the main data identifier, writing the main data identifier, the table name of the data table, the field name written with the main data identifier, and the reference count of the record into the attribute field corresponding to the reference count table, and generating the preset reference count table comprises:
establishing a reference counter for the field written with the main data identifier, after the service data is written into a data table in an information system, increasing the count of the reference counter to obtain a reference count, accumulating the reference counts corresponding to the service data to obtain a total reference count value, and storing the total reference count value into redis;
and writing the main data identifier, the table name of the data table, the field name of the written main data identifier and the total reference count value corresponding to the field written with the main data identifier and stored in the redis into the attribute field corresponding to the reference count table to generate the preset reference count table.
8. A master data deletion apparatus in an information system, comprising
The master data acquisition module is used for acquiring master data to be deleted and a corresponding master data identifier;
the searching module is used for searching the table name, the reference field name and the reference count of the corresponding reference table from a preset reference count table according to the main data identification, wherein the reference count refers to the number of times that the main data corresponding to the main data identification is referred;
the reference information acquisition module is used for sequencing the reference counts and acquiring a reference table and a reference field name corresponding to the maximum reference count in the sequencing result;
the judging module is used for judging whether the main data to be deleted is referred by the reference table;
and the deleting module is used for deleting the maximum reference count if the reference count is not the same as the reference count, returning to the step of sorting the reference count and acquiring the reference table and the reference field name corresponding to the maximum reference count in the sorting result, and deleting the main data to be deleted until the reference count is completely deleted.
9. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the steps in the master data deletion method in the information system according to any one of claims 1 to 7 when executing the program.
10. A computer storage medium having stored thereon a computer program, characterized in that the program, when being executed by a processor, carries out the steps in the master data deletion method in an information system according to any one of claims 1 to 7.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201711404896.XA CN108073712B (en) | 2017-12-22 | 2017-12-22 | Method and device for deleting main data in information system and computer equipment |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201711404896.XA CN108073712B (en) | 2017-12-22 | 2017-12-22 | Method and device for deleting main data in information system and computer equipment |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN108073712A CN108073712A (en) | 2018-05-25 |
| CN108073712B true CN108073712B (en) | 2020-08-18 |
Family
ID=62155420
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201711404896.XA Active CN108073712B (en) | 2017-12-22 | 2017-12-22 | Method and device for deleting main data in information system and computer equipment |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN108073712B (en) |
Families Citing this family (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN112667690B (en) * | 2021-01-29 | 2023-07-18 | 浪潮通用软件有限公司 | Data reference query method and device |
Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101430707A (en) * | 2008-11-03 | 2009-05-13 | 金蝶软件(中国)有限公司 | Verification method, system and equipment for record deletion operation |
| CN102710381A (en) * | 2012-06-07 | 2012-10-03 | 飞天诚信科技股份有限公司 | A method and device for processing transmission data |
| CN103379099A (en) * | 2012-04-19 | 2013-10-30 | 阿里巴巴集团控股有限公司 | Hostile attack identification method and system |
| CN104123318A (en) * | 2013-04-28 | 2014-10-29 | 百度在线网络技术(北京)有限公司 | Method and system for displaying interest points in map |
Family Cites Families (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US7003551B2 (en) * | 2000-11-30 | 2006-02-21 | Bellsouth Intellectual Property Corp. | Method and apparatus for minimizing storage of common attachment files in an e-mail communications server |
-
2017
- 2017-12-22 CN CN201711404896.XA patent/CN108073712B/en active Active
Patent Citations (4)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101430707A (en) * | 2008-11-03 | 2009-05-13 | 金蝶软件(中国)有限公司 | Verification method, system and equipment for record deletion operation |
| CN103379099A (en) * | 2012-04-19 | 2013-10-30 | 阿里巴巴集团控股有限公司 | Hostile attack identification method and system |
| CN102710381A (en) * | 2012-06-07 | 2012-10-03 | 飞天诚信科技股份有限公司 | A method and device for processing transmission data |
| CN104123318A (en) * | 2013-04-28 | 2014-10-29 | 百度在线网络技术(北京)有限公司 | Method and system for displaying interest points in map |
Also Published As
| Publication number | Publication date |
|---|---|
| CN108073712A (en) | 2018-05-25 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN112101994B (en) | Member rights management method, apparatus, computer device, and readable storage medium | |
| CN108089893B (en) | Method and device for determining redundant resources, terminal equipment and storage medium | |
| CN107451831B (en) | Task pushing method and device and storage medium | |
| CN112433712B (en) | Report display method, report display device, computer equipment and storage medium | |
| CN106371973A (en) | Data processing method, equipment and system | |
| CN110737604A (en) | method, device, electronic equipment and storage medium for automatically cleaning memory | |
| WO2016197814A1 (en) | Junk file identification and management method, identification device, management device and terminal | |
| CN115729687A (en) | Task scheduling method and device, computer equipment and storage medium | |
| CN111443899A (en) | Element processing method and device, electronic equipment and storage medium | |
| CN112948376B (en) | IP geographical position information query method, terminal equipment and storage medium | |
| CN115576947A (en) | Data management method and device, combined library, electronic equipment and storage medium | |
| CN106503186A (en) | A kind of data managing method, client and system | |
| US20140320498A1 (en) | Terminal device, information processing method, and computer program product | |
| CN106815232A (en) | Catalog management method, apparatus and system | |
| CN108073712B (en) | Method and device for deleting main data in information system and computer equipment | |
| CN109101191B (en) | Data storage method, data storage device, storage medium and electronic equipment | |
| WO2025139642A1 (en) | Target user identification method and apparatus, and electronic device | |
| CN117390011A (en) | Report data processing method, device, computer equipment and storage medium | |
| CN110929207B (en) | Data processing method, device and computer readable storage medium | |
| WO2018177414A1 (en) | Data processing method, data processing device, computing device, and storage medium | |
| CN112380440A (en) | Information searching method and device, electronic equipment and storage medium | |
| CN108989245B (en) | User data storage method and device | |
| CN113742335A (en) | Data compression management method and device | |
| CN105704007A (en) | Multimedia message sending method and system of terminal | |
| CN119648400B (en) | Method, device, electronic device and program product for determining currency transaction path |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |