Data storage method and device and storage medium
By classifying and storing human resources data items in object form, traditional data storage solutions are solved, and efficient and flexible data storage and version management are achieved.
Patent Information
- Application Number
- CN202411240242.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-04
- Publication Date
- 2024-12-27
AI Technical Summary
Traditional data storage solutions are inefficient when processing human resource data, complex version control, difficult data redundancy and consistency maintenance, and difficult to adapt to data variability.
Classify multiple data items of target personnel into data sets of the same category and store them in the form of objects, generate an abstract representation of the data set, upload it to the database to store it in the form of objects, and support flexible data structures and version control.
Improve data storage efficiency, reduce storage space waste, realize flexible data storage and fast version control, adapting to the variability of human resource data.
Smart Images

Figure CN119201937A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a data storage method, device and storage medium. Background Art
[0002] With the continuous expansion of modern enterprise scale and the rapid development of information technology, human resource management has become an indispensable part of enterprise management. Human resource management usually needs to process a large amount of human resource data, including basic information of employees, employment information, performance information, etc. These data often have different formats and structures, such as text, numbers, images, videos, etc. Traditional data storage solutions usually use tables to store data, each table contains multiple rows and columns. When processing such a large amount of data, they often face problems such as inefficient data management, complex version control, data redundancy and difficulty in maintaining consistency.
[0003] Therefore, a more efficient and flexible storage solution is needed to meet the needs of the human resources system. Summary of the invention
[0004] The embodiments of the present invention provide a data storage method, device and storage medium for storing multiple data items corresponding to a target person in the form of an object, which can not only improve the data storage efficiency but also store data more flexibly to adapt to the variability of data.
[0005] In a first aspect, an embodiment of the present invention provides a data storage method, the method comprising:
[0006] Acquire the data to be processed corresponding to the target person, wherein the data to be processed includes multiple data items;
[0007] Classifying the multiple data items to obtain multiple data sets, where the data items in the same data set are data of the same category;
[0008] Generate first object data corresponding to each of the plurality of data sets, where the first object data is an abstract representation of the data set;
[0009] Creating first objects corresponding to each of the plurality of data sets according to first object data corresponding to each of the plurality of data sets;
[0010] The first objects corresponding to the plurality of data sets are uploaded to a preset database, so that the plurality of data sets are stored in the preset database in the form of objects.
[0011] In a second aspect, an embodiment of the present invention provides a data storage device, the device comprising:
[0012] An acquisition module, used to acquire the to-be-processed data corresponding to the target person, wherein the to-be-processed data includes a plurality of data items;
[0013] A classification module, used to classify the multiple data items to obtain multiple data sets, where the data items in the same data set are data of the same category;
[0014] A generating module, configured to generate first object data corresponding to each of the plurality of data sets, wherein the first object data is an abstract representation of the data set;
[0015] A creation module, configured to create first objects corresponding to each of the plurality of data sets according to first object data corresponding to each of the plurality of data sets;
[0016] The storage module is used to upload the first objects corresponding to the multiple data sets to a preset database, so as to store the multiple data sets in the preset database in the form of objects.
[0017] In a third aspect, an embodiment of the present invention provides an electronic device, comprising: a memory, a processor, and a communication interface; wherein the memory stores executable code, and when the executable code is executed by the processor, the processor executes the data storage method as described in the first aspect.
[0018] In a fourth aspect, an embodiment of the present invention provides a non-temporary machine-readable storage medium having executable code stored thereon. When the executable code is executed by a processor of an electronic device, the processor can at least implement the data storage method described in the first aspect.
[0019] In the data storage solution provided in the embodiment of the present invention, it can be applied to human resource management. The human resource data corresponding to each person is stored in a preset database in the form of object storage, which can process the human resource data more efficiently and flexibly. In the specific implementation, firstly, the data to be processed corresponding to the target person is obtained, and the data to be processed includes multiple data items. The multiple data items are classified to obtain multiple data sets, and the data items in the same data set are data of the same category. Then, the first object data corresponding to each of the multiple data sets is generated, and the first object data is an abstract representation of the data set. Then, the first object corresponding to each of the multiple data sets is uploaded to the preset database, so that the multiple data sets are stored in the preset database in the form of one object.
[0020] In the above scheme, multiple data items corresponding to the target personnel are classified, and multiple data items belonging to the same category are aggregated in a data set. The data set is used as a processing unit to store the data corresponding to the target personnel. Multiple data items can be stored in a preset database at one time, which improves the data storage efficiency. In addition, when storing multiple data items in a data set, objects are used as storage units, and multiple data items of the same category are integrated into one object, which is stored in the preset database in the form of an object. This can not only improve the data storage efficiency and reduce the waste of storage space, but also store data more flexibly to adapt to the variability of human resource data. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0022] Figure 1 A schematic diagram of an application scenario of a data storage method provided by an embodiment of the present invention;
[0023] Figure 2 A flowchart of a data storage method provided by an embodiment of the present invention;
[0024] Figure 3 A flowchart of generating first object data corresponding to a target data set provided by an embodiment of the present invention;
[0025] Figure 4 A flowchart of another data storage method provided by an embodiment of the present invention;
[0026] Figure 5 A schematic diagram of an application scenario for storing a first object provided by an embodiment of the present invention;
[0027] Figure 6 A schematic diagram of an application scenario for storing a second object provided by an embodiment of the present invention;
[0028] Figure 7 A schematic diagram of the structure of a data storage device provided by an embodiment of the present invention;
[0029] Figure 8 A schematic diagram of the structure of an electronic device provided in this embodiment. DETAILED DESCRIPTION
[0030] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention. In addition, the step timing in the following method embodiments is only an example, not a strict limitation.
[0031] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in the embodiments of the present invention are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data need to comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0032] Definition of terms:
[0033] JSON (JavaScript Object Notation) is a lightweight text data exchange format that flexibly represents complex data structures by using key-value pairs and square brackets, as well as object and array structures.
[0034] In order to facilitate those skilled in the art to understand the technical solutions provided by the embodiments of the present invention, the relevant technologies are briefly described below:
[0035] When conducting human resource management for corporate employees, it is usually necessary to store a large amount of human resource data, such as basic employee information, employment information, performance information, and other data. Traditional human resource management solutions usually use relational databases to store this data. Before storing the data, the corresponding data table structure is designed according to the needs of human resource management. These data table structures contain multiple tables, each of which corresponds to a type of data, such as employee tables, department tables, performance tables, etc., and each table defines fixed fields for storing specific data items. Then create the corresponding tables in the relational database, and these tables will store data according to the defined field structure. When there is new human resource data that needs to be stored, insert the data into the corresponding table to generate a row of data.
[0036] However, as the scale of enterprises continues to expand, the amount of human resources data is growing rapidly, and human resources data is often changeable. When dealing with such a large amount of data, traditional data storage solutions cannot adapt to the variability of data in a timely manner and expand to accommodate such a large amount of data, resulting in inefficient data management. In addition, when employee information changes, it needs to be updated and synchronized to various relevant departments in a timely manner. Traditional data storage solutions may lack efficient data update and synchronization mechanisms, resulting in data inconsistency.
[0037] In addition, in human resource management, it is usually necessary to retain employees' historical data for trend analysis, performance appraisal, etc. Traditional data storage solutions make it difficult to effectively manage these historical data versions, resulting in data confusion or loss. In some cases, it is necessary to roll back to a historical version of the data to recover from erroneous operations or conduct audits. Traditional data storage solutions do not support version rollback functions or are complex to operate, which increases the difficulty of data management.
[0038] In order to solve the above technical problems, the embodiment of the present invention provides a new data storage scheme. When storing multiple data corresponding to a target person, the multiple data corresponding to the target person are split into multiple data sets, and multiple data items in each data set are integrated into an object data, and the small objects corresponding to the multiple data items are stored in a field of the database. The object is used as a storage unit, and the data structure is flexible, which can adapt to the variability of human resource data, and can also reduce the waste of storage space and improve data storage efficiency. In addition, the multiple data corresponding to the target person are split into multiple small objects for storage, so that when a certain data needs to be changed, only the small object data needs to be modified, avoiding the space waste caused by repeated storage of all data (large object data) corresponding to the target person. In addition, when generating each object data, the version information corresponding to the data can be generated at the same time. When the object data is modified each time, a new version data will be generated and the corresponding version information will be recorded. Through the version information corresponding to each data, each historical data is managed, so that it can be rolled back to a certain historical version corresponding to the data as needed, and rapid version control and undo operations can be achieved.
[0039] In the following, some embodiments of the present invention are described in detail in conjunction with the accompanying drawings. In the case where there is no conflict between the embodiments, the following embodiments and features in the embodiments can be combined with each other.
[0040] Figure 1 A schematic diagram of an application scenario of a data storage method provided by an embodiment of the present invention, such as Figure 1 As shown, the execution subject of the method may be a data storage device, which is communicatively connected with a requester / client.
[0041] The requester / client may be any computing device with certain data transmission capabilities. In specific implementation, the requester / client may be a mobile phone, a personal computer PC, a tablet computer, a setting application, etc.
[0042] A data storage device refers to a device that can provide data storage services. In terms of physical implementation, a data storage device can be any device that can provide computing services, respond to service requests for data storage, and perform data storage services based on service requests. For example, it can be a cluster server, conventional server, cloud server, cloud host, virtual center, etc.
[0043] In an embodiment of the present invention, the requesting end / client may initiate a data storage request to the data storage device, and the data storage request may include an employee identifier corresponding to the target employee and the to-be-processed data corresponding to the target employee. Specifically, the specific implementation method for initiating the data storage request by the requesting end is not limited. In some embodiments, an interactive interface is configured on the requesting end, and an execution operation input by the user in the interactive interface is obtained, and a data storage request is initiated to the data storage device based on the execution operation.
[0044] The data storage device is used to receive the data storage request sent by the request end, and then obtain the to-be-processed data corresponding to the target person based on the data storage request. The to-be-processed data includes multiple data items. For example, the to-be-processed data corresponding to the target employee A includes the name, gender, ethnicity, address, time of employment, position information, department information, technical level, training records, etc. of the target employee A.
[0045] After obtaining the data to be processed corresponding to the target person, multiple data items in the data to be processed can be classified to obtain multiple data sets, and the data items in the same data set are data of the same category. And generate first object data corresponding to each of the multiple data sets, and the first object data is an abstract representation of the data set. Then, according to the first object data corresponding to each of the multiple data sets, create first objects corresponding to each of the multiple data sets. Finally, upload the first objects corresponding to each of the multiple data sets to a preset database, so that the multiple data sets are stored in the preset database in the form of objects.
[0046] The technical solution provided in this embodiment, by classifying multiple data items corresponding to the target personnel, aggregates multiple data items belonging to the same category into a data set, takes the data set as a processing unit, stores the data corresponding to the target personnel, and can store multiple data items in a preset database at one time, thereby improving the data storage efficiency. In addition, when storing multiple data items in the data set, taking the object as the storage unit, multiple data items of the same category are integrated into one object, and stored in the preset database in the form of an object, which can not only improve the data storage efficiency and reduce the waste of storage space, but also store data more flexibly to adapt to the variability of human resource data.
[0047] The above-mentioned embodiment introduces the implementation process of the data storage method in a specific application scenario. In order to more clearly understand the specific implementation process of the data storage device storing the processed data after obtaining the processed data corresponding to the target person, an exemplary explanation is given below in combination with the following embodiments.
[0048] Figure 2 A flowchart of a data storage method provided by an embodiment of the present invention is as follows Figure 2 As shown, the execution subject of the method can be a data storage device. It can be understood that the device can be implemented as software, or a combination of software and hardware. Specifically, the method includes the following steps:
[0049] 201. Obtain the data to be processed corresponding to the target person, where the data to be processed includes multiple data items.
[0050] 202. Classify multiple data items to obtain multiple data sets, where data items in the same data set are data of the same category.
[0051] 203. Generate first object data corresponding to each of the plurality of data sets, where the first object data is an abstract representation of the data set.
[0052] 204. Create first objects corresponding to each of the multiple data sets according to the first object data corresponding to each of the multiple data sets.
[0053] 205. Upload the first objects corresponding to the multiple data sets to a preset database, so as to store the multiple data sets in the preset database in the form of objects.
[0054] The data storage solution provided in the embodiment of the present invention can be applied to human resource management. When storing human resource data for each employee, each target person can be taken as a processing object, and multiple data items corresponding to the target person can be encapsulated into an object and stored in a preset database. That is, multiple data items are stored in the preset database in the form of objects, so that the data structure is relatively simple and each data item can be stored flexibly.
[0055] In practical applications, usually one target person corresponds to multiple data items, that is, there are many data items. If all the data items corresponding to the target person are directly integrated into one object, when a certain data item of the target person is modified, a new object corresponding to all the data items needs to be generated and stored again in the preset database, which will increase the repeated storage of data and waste a lot of storage space. Therefore, in an embodiment of the present invention, when storing data for multiple data items corresponding to the target person, the multiple data items corresponding to the target person can be first split into multiple data sets, and each data set can be stored in the preset database in the form of a small object.
[0056] In the specific implementation, first, the data to be processed corresponding to the target person is obtained. Among them, the data to be processed includes multiple data items. In practical applications, a target person usually includes many data items. In order to store the multiple data items corresponding to the target person more efficiently, and to be able to change the multiple data items more conveniently and quickly in the future, in an embodiment of the present invention, before storing the multiple data items, the multiple data items can be classified to obtain multiple data sets, and the data sets are used as processing units to store the data items corresponding to the target person. In this way, multiple data items can be stored in a preset database at one time, thereby improving the data storage efficiency.
[0057] The data items in the same data set are data of the same category. That is to say, in practical applications, multiple data items can be classified according to actual needs, multiple data items of the same category can be integrated into one data set, and then the first object (small object) corresponding to the data set can be created.
[0058] For example, the acquired data to be processed corresponding to the target person A includes the name, gender, ethnicity, address, time of joining, job information, department information, completion of work tasks, work quality, work efficiency, work attitude, and training records of the target employee A. Multiple data items can be classified according to the data type to obtain a basic information data set, an on-the-job information data set, and a performance information data set. Among them, the basic information data set includes name, gender, ethnicity, and address. The on-the-job information data set includes time of joining, job information, and department information. The performance information data set includes completion of work tasks, work quality, work efficiency, work attitude, and training records. In addition, during the specific implementation, the multiple data items corresponding to the target person can also be classified according to the actual needs of the requesting end.
[0059] After obtaining multiple data sets, first object data corresponding to each of the multiple data sets are generated respectively, wherein the first object data is an abstract representation of the data set, and the first object data can be data in multiple formats, including unstructured data, structured or semi-structured data, and arbitrary binary data.
[0060] When generating the first object data, the first object data corresponding to the target data set can be obtained by format conversion of the data items in the target data set, where the target data set is any one of the multiple data sets. That is, the multiple data items in each data set can be format converted according to the format corresponding to the predefined object data, so as to integrate the multiple data items into the first object data of the corresponding format.
[0061] In specific implementation, it is assumed that the first object data can be JSON data. Then, after obtaining each data set, the field name corresponding to each data item is determined, the field name of the data is determined as a JSON key, each data item is determined as the value corresponding to the JSON key, and each data item is serialized to obtain multiple JSON strings, and the multiple JSON strings are encapsulated in one JSON data. For example, the multiple JSON strings obtained are {"name":"John","age":"30","Student":"false"}.
[0062] After generating the first object data corresponding to each of the plurality of data sets, first objects corresponding to each of the plurality of data sets are created according to the first object data corresponding to each of the plurality of data sets. The first object may include the first object data, an object identifier, object attribute information, and the like.
[0063] In an optional embodiment, in order to facilitate the management of object data corresponding to each data set, when creating the first object corresponding to the data set, the version information, data type and other information corresponding to the data can be encapsulated in the first object.
[0064] Specifically, the implementation process of creating first objects corresponding to multiple data sets respectively according to the first object data corresponding to each of the multiple data sets may include: determining the object type of the first object data corresponding to each of the multiple data sets according to the data types corresponding to the multiple data sets, determining the version information corresponding to each of the multiple first object data, and encapsulating the first object data corresponding to each of the multiple data sets, the object type corresponding to each of the multiple first object data, and the version information corresponding to each of the multiple first objects into first objects corresponding to each of the multiple data sets.
[0065] Next, the first objects corresponding to the multiple data sets are uploaded to the preset database, so that the multiple data sets are stored in the preset database in the form of objects. That is to say, when storing data for each data set, the object can be used as a storage unit, and multiple data items in each data set can be encapsulated in a small object for storage, so that multiple data items of the same category can be encapsulated in a small object and stored in the preset database with the object as the storage unit, which can not only reduce the waste of storage space, but also improve storage efficiency.
[0066] The preset database may be a relational database, a document database, etc., and the embodiment of the present invention does not limit the type of database. In the embodiment of the present invention, the data structure in the database is no longer used to store the first object corresponding to each data set, but the data is stored in an object manner, that is, the first object corresponding to each data set can be stored in a field of the database.
[0067] From the above description, it can be known that when storing data for multiple data items corresponding to the target person, the multiple data items can be split and processed first to split them into multiple data sets, and then the data set is used as the processing unit to generate the first object corresponding to the data set, and the first object corresponding to each data set is stored in a preset database, so as to split the to-be-processed data corresponding to the target person into multiple small objects and store them in the preset database. Then, when a data item needs to be changed, only the small object data containing the data item can be modified, avoiding modification of all data corresponding to the target person, and avoiding space waste caused by repeated storage of all data corresponding to the target person.
[0068] In order to quickly retrieve each object and perform operations such as changing the object data in each object, before uploading the first object corresponding to multiple data sets, the object identifiers of the first objects corresponding to each of the multiple data sets can be determined first; the object identifiers and the first objects corresponding to each of the multiple data sets are uploaded to a preset database, so as to store the first objects corresponding to each of the multiple data sets and the object identifiers in the database. In this way, the first object stored in the preset database can be quickly retrieved through the object identifiers corresponding to each data set.
[0069] Each first object has a unique object identifier. In practical applications, an object identifier generator can be used to randomly generate corresponding object identifiers for the first objects corresponding to each data set. The object identifier can be a random number or a random binary number.
[0070] In addition, in another optional embodiment, the object identifier of the first object corresponding to each of the multiple data sets can also be determined, and the object identifier, first object data, object type and version information corresponding to each of the multiple data sets can be encapsulated into the first object corresponding to each of the multiple data sets. It can be set according to actual needs, and the embodiment of the present invention does not limit this. In this way, the first object corresponding to each of the multiple data sets can be directly uploaded to a preset database to store the first objects corresponding to the multiple data sets in the database, and the object identifier, first object data, object type and version information corresponding to each data set can be obtained by accessing the first object.
[0071] In an embodiment of the present invention, when storing multiple data corresponding to a target person, the multiple data corresponding to the target person are split into multiple data sets, and multiple data items in each data set are integrated into one object data, and the small objects corresponding to the multiple data items are stored in one field of the database. With the object as the storage unit, the data structure is flexible, which can adapt to the variability of human resource data, and can also reduce the waste of storage space and improve data storage efficiency. In addition, the multiple data corresponding to the target person are split into multiple small objects for storage, so that when a certain data needs to be changed, only the small object data needs to be modified, avoiding the modification of all the data corresponding to the target person, and avoiding the waste of space caused by repeated storage of all the data corresponding to the target person.
[0072] The above embodiment illustrates the implementation process of obtaining the first object data corresponding to each data set by format conversion of the data items in each data set, and then creating the first object corresponding to each data set according to the first object data corresponding to each data set. In order to more clearly understand the specific implementation process of generating the first object data corresponding to each data set, the process is described in detail in conjunction with the following embodiment. Among them, the processing process corresponding to each data set is the same. For the sake of convenience, the following embodiment only exemplifies the processing process of the target data set.
[0073] Figure 3 A flowchart of generating first object data corresponding to a target data set is provided in an embodiment of the present invention; Figure 3 As shown, an embodiment of the present invention provides a specific implementation method for converting the format of data items in a target data set to obtain first object data corresponding to the target data set, which may include the following steps:
[0074] 301. Obtain a preset object structure, where the object structure is used to specify the data format corresponding to each data item in the target data set.
[0075] 302. Create an object instance corresponding to the target data set according to a preset object structure and data items in the target data set to obtain first object data corresponding to the target data set.
[0076] When generating the first object data corresponding to the target data set, a preset object structure may be obtained first. The object structure is used to specify the data format corresponding to each data item in the target data set. In specific implementation, the preset object structure may be predefined according to the characteristics of the data and actual needs.
[0077] The object structure may include the attributes of the object (i.e., data fields). Furthermore, the preset object structure may be an object structure common to multiple data sets. In practical applications, the preset object structure may be represented by a class. Specifically, in an optional embodiment, the implementation method for obtaining the preset object structure may be: determining constructors corresponding to multiple data sets, wherein the parameters passed into the constructor are specified as variable strings in the constructor; and creating abstract classes corresponding to multiple data sets based on the constructor.
[0078] In addition, the preset object structure can also be an object structure corresponding to a single data set, that is, corresponding classes are defined for each data set. For example, if the target data set is a basic information data set, a class can be defined to store basic information of personnel, including attributes such as name, gender, ethnicity, address, etc., and corresponding constructors to initialize these attributes.
[0079] It should be noted that the preset object structure can be adjusted dynamically according to demand. For example, if a new target data item is added to the target data set, a data field corresponding to the target data item can be directly added to the preset object structure. This allows the object structure to be adjusted flexibly, and the variability of data can be adapted more quickly. The corresponding data fields can be expanded or deleted based on the original object structure.
[0080] After the object structure is determined, an object instance corresponding to the target data set may be created according to the preset object structure and the data items in the target data set to obtain the first object data corresponding to the target data set. In an optional embodiment, an object instance corresponding to the target data set may be created according to a defined abstract class, and each data item in the target data set may be filled into the object's attributes to obtain the first object data corresponding to the target data set.
[0081] In specific implementation, the data items of the target dataset can be passed into the constructor in the abstract class to create an object instance corresponding to the target dataset to obtain a JSON string corresponding to the target dataset, and the JSON string corresponding to the target dataset can be determined as the first object data corresponding to the target dataset.
[0082] In an embodiment of the present invention, an object instance corresponding to the target data set is created according to a preset object structure and data items in the target data set to obtain first object data corresponding to the target data set, that is, the first object data corresponding to the target data set is determined using a predefined object structure. In this way, the first object data corresponding to the target data set can be obtained more quickly, thereby improving data storage efficiency.
[0083] After obtaining the first object data corresponding to the target data set, the first object data corresponding to the target data set and the object identifier of the first object are encapsulated as the first object corresponding to the target data set. Since each first object only encapsulates the data items in each data set, the first object corresponding to each data set can be regarded as a small object. In other words, after obtaining the to-be-processed data corresponding to the target person, the to-be-processed data corresponding to the target person can be split into multiple data sets, and small objects corresponding to each of the multiple data sets are generated, and the multiple small objects are respectively stored in a preset database, so that for a target person, the target person may correspond to multiple small objects. Then, in order to facilitate data management of the small objects corresponding to each target person, the multiple small objects corresponding to each target person can be associated in a large object, so that the object identifiers corresponding to each small object can be obtained through the large object, and then the specific corresponding data items can be obtained according to the object identifiers corresponding to each small object. In conjunction with the following embodiments, the specific implementation process of associating multiple small objects and generating the large object corresponding to the target person is exemplarily described.
[0084] Figure 4 A flowchart of another data storage method provided by an embodiment of the present invention; Figure 4 As shown, based on the above embodiment, the method may further include the following steps:
[0085] 401. Acquire multiple first objects corresponding to a target person.
[0086] 402. Determine object identifiers corresponding to each of the plurality of first objects.
[0087] 403. Generate a second object corresponding to the target person according to the object identifiers corresponding to the multiple first objects, where the second object is associated with the multiple first objects.
[0088] 404. Store the second object in a preset database.
[0089] In the embodiment of the present invention, a corresponding second object can be established for each target person, and the second object can be associated with multiple first objects corresponding to the target person. The second object can be regarded as a large object, and the first object is a small object. The large object is split into multiple small objects, and the object identifiers corresponding to each small object are stored in the large object, so that each small object is associated with each other through the object identifiers corresponding to each small object.
[0090] Specifically, when establishing the second object corresponding to the target person, multiple first objects corresponding to the target person can be obtained first, and the object identifiers corresponding to the multiple first objects can be determined. Then, based on the object identifiers corresponding to the multiple first objects, the second object corresponding to the target person is generated, and the second object is associated with multiple first objects.
[0091] Since each object has a unique object identifier, when creating a second object corresponding to the target person, the second object can be determined by associating the object identifiers corresponding to multiple first objects. In this way, multiple first objects can be accurately read through the object identifiers associated in the second object.
[0092] Specifically, in an optional embodiment, the implementation process of generating the second object corresponding to the target object according to the object identifiers corresponding to the multiple first objects may include: obtaining the abstract class corresponding to the multiple data sets; passing the object identifiers corresponding to the multiple first objects to the constructor in the abstract class, creating the object instance corresponding to the target object, so as to obtain the JSON string corresponding to the target object; determining the JSON string corresponding to the target object as the second object data corresponding to the target object; generating the second object corresponding to the target object according to the second object data corresponding to the target object. In another optional embodiment, it can be determined that the data type corresponding to each first object is determined as a JSON key, the object identifier corresponding to each first object is determined as the value corresponding to the JSON key, and each data item is serialized to obtain multiple JSON strings, for example: the multiple JSON strings obtained are {"basic information":"object ID1","employment information":"object ID2","performance information":"object ID3"}. And the multiple JSON strings are encapsulated in a JSON data to obtain the second object data corresponding to the target person, and the second object is created according to the second object data.
[0093] After generating the second object corresponding to the target person, the second object can be stored in a preset database. That is to say, for the target person, the preset database not only stores multiple first objects corresponding to the target person, but also stores the second object corresponding to the target person, and each object is stored in a field in the preset database, that is, each object corresponds to a storage record. In the embodiment of the present invention, by acquiring multiple first objects corresponding to the target person, and generating the second object corresponding to the target person according to the object identifiers corresponding to each of the multiple first objects, the second object is associated with multiple first objects, so that the second object only includes the object identifiers corresponding to the multiple first objects, so that the second object is stored in the preset database, which can not only improve the storage efficiency of the object, but also reduce the waste of storage space.
[0094] From the above description, it can be seen that: what is stored in the second object is not each data entity, but the object identifier of the first object corresponding to each data set, which can improve the storage efficiency of the object and reduce the storage space occupied. In addition, through this design, when the data in the first object is changed, only the first object needs to be changed, and there is no need to change the corresponding second object, because the second object is associated with the object identifiers of multiple first objects. When reading a first object associated with the second object, the object identifier encapsulated in the second object can be used to obtain the storage records corresponding to the object identifier from the preset database, and the latest version of the first object can be obtained from the storage record, and the changed first object can be obtained, avoiding the space waste caused by repeated storage of all data (large object data) corresponding to the target person.
[0095] Specifically, if it is necessary to modify a certain target data, the first object corresponding to the target data can be determined first, and multiple storage records corresponding to the first object can be read from the preset database, and the first object data in the latest storage record can be modified. After the modification, a new data corresponding to the first object is generated, and the generated new data is stored in the preset database. In other words, each time an object is changed, a new data is generated, and the new data is stored in the preset database with a new storage record. In this way, for the same data set (object), there may be multiple storage records corresponding to the preset database. Therefore, when modifying a data item in a certain object, it is necessary to obtain the latest version corresponding to the object and modify the first object data in the latest version.
[0096] In a specific implementation, a data modification request is first received, wherein the request includes the target data to be modified. Then, based on the target data to be modified, a first object storing the target data and an object identifier of the first object are determined. Next, a storage record corresponding to the object identifier of the first object is searched from a database to obtain the corresponding latest storage record. Finally, according to the target data to be modified, the first object data in the latest storage record is modified to obtain the modified target data.
[0097] In addition, when each object data is generated, the version information corresponding to the data can be generated at the same time. Each time the object data is modified, a new data will be generated and the corresponding version information will be recorded. The various historical data can be managed through the version information corresponding to each data. In this way, you can roll back to a historical version corresponding to the data as needed, thereby realizing fast version control and undo operations.
[0098] For example, for a target data set A, the target data set A includes three data items. When the target data set A is stored for the first time, the first object data A can be generated based on the three data items, the first object 1 corresponding to the target data set A can be created based on the first object data A, and the object identifier A corresponding to the first object 1 can be determined to generate the version number 1 corresponding to the first object 1. If the first data item in the target data set A is changed, the first object data A can be obtained, and after the first data item in the first object data A is changed, a new first object data B can be generated, and the first object 1 corresponding to the target data set A can be created based on the first object data B, and the object identifier A corresponding to the first object 1 can be determined to generate the version number 2 corresponding to the first object 1. The newly generated object is stored in a preset database, and a new storage record is added to the database. This does not affect the original data stored in the database, and the historical data of each target employee can be retained for trend analysis, performance appraisal, etc.
[0099] Among them, the object identifiers corresponding to the first object 1 and the second object 2 are the same, that is, the first object and the second object represent object data corresponding to the same data set corresponding to the same target person. In this way, the first object 1 corresponding to version number 1 and version number 2 can be obtained through object identifier A.
[0100] Furthermore, since the multiple first objects and second objects stored in the preset database include version information corresponding to each object data, when it is necessary to obtain the historical data of a certain employee, multiple historical versions corresponding to the data can be obtained, and roll back to a historical version of the data as needed to restore erroneous operations or perform audits.
[0101] In addition, in practical applications, many human resources data have certain sensitivity. However, the first object is usually encapsulated by the first object data corresponding to each data set and the corresponding object attribute information. Then, the preset database stores the first object data corresponding to each data set and the object identifier of the first object. If the user knows the data structure corresponding to the first object data, then the first object data can be parsed according to the data structure corresponding to the first object data to obtain the various data items in the target data set, so that the user can know the various human resources data corresponding to the target person.
[0102] Therefore, in order to protect the privacy of the data, before storing the first object data in the preset database, the first object data can be encrypted to obtain encrypted data, the encrypted data and the object identifier of the first object can be encapsulated into a first object, and then the first object can be stored in the preset database.
[0103] However, if the first object is generated by encapsulating the encrypted data corresponding to the first object data, then when reading the first object data from the preset database, the encrypted data can be first decrypted to obtain the decrypted first object data. If you want to obtain the original multiple data items corresponding to the first object data, then you can parse the first object data to obtain multiple data items corresponding to the first object data. Among them, the first object data can be parsed according to the data structure corresponding to the first object data, or by instantiating the implementation class corresponding to the first object data to obtain multiple key-value pairs, and according to the pre-defined field name, multiple data items corresponding to the first object data can be obtained. Among them, the specific implementation process involved in the embodiment of the present invention can refer to the content in the above embodiment, and will not be repeated here.
[0104] In order to facilitate understanding of the data storage solution provided by the embodiment of the present invention, Figure 5-6 An example is given to illustrate the data storage in a specific application scenario. In a specific application, the human resources manager needs to store the pending data corresponding to the target person A in a relational database so as to read the pending data corresponding to the target person A from the relational database later. Then the human resources manager can initiate a data storage request to the data storage device as a request end. After receiving the data storage request, the data storage device can obtain the pending data corresponding to the target person A, process the pending data, and store it in the relational database in the form of an object. Specifically, the method may include the following steps:
[0105] Step 1: Obtain the data to be processed corresponding to the target person A, where the data to be processed includes multiple data items.
[0106] For example, the data to be processed includes the name, gender, ethnicity, address, employment date, position information, and department information of target employee A.
[0107] Step 2: Classify multiple data items to obtain multiple data sets, where the data items in the same data set are data of the same category.
[0108] Specifically, multiple data items can be classified according to data types to obtain basic information data sets and employment information data sets. The basic information data sets include name, gender, ethnicity, and address. The employment information data sets include employment date, position information, and department information.
[0109] Step 3: Generate first object data corresponding to each of the multiple data sets, wherein the first object data is JSON data.
[0110] Step 4: Encrypt the first object data corresponding to each of the multiple data sets to obtain encrypted data corresponding to each of the multiple data sets.
[0111] Step 5: Determine the object type of the first object data corresponding to each of the multiple data sets according to the data types corresponding to the multiple data sets.
[0112] Step 6: Determine the version information corresponding to each of the plurality of first object data.
[0113] Step 7: Determine the object identifier of the first object corresponding to each of the multiple data sets.
[0114] Step 8: Encapsulate the object identifier, encrypted data, object type, and version information of the first objects corresponding to each of the multiple data sets into the first objects corresponding to each of the multiple data sets.
[0115] Among them, the first object obtained after encapsulation can be as follows Figure 5 As shown, the basic data set corresponding to the target person A includes name, gender, nationality, and address data items. The format of these four data items is converted to obtain JSON data corresponding to the basic information data set, and the JSON data is encrypted to obtain encrypted data, and the encrypted data is determined as the object data corresponding to the basic information data set. The data type corresponding to the object data is determined to be basic information of the person, and the version information corresponding to the object data is generated as version1, and the object identifier corresponding to the first object is determined to be 2. The object identifier, the object data corresponding to the basic information data set, the data type corresponding to the object data, and the version information are encapsulated as the first object and uploaded to the relational database. In other words, each first object includes an object identifier, object data, object type, and version information.
[0116] Step 9: Upload the multiple first objects to a preset database to store the first objects corresponding to the multiple data sets in the database.
[0117] Step 10: Acquire multiple first objects corresponding to the target person A, and determine the object identifiers corresponding to each of the multiple first objects.
[0118] Step 11: Generate a second object corresponding to the target person A according to the object identifiers corresponding to each of the multiple first objects, where the second object is associated with the multiple first objects.
[0119] The second object obtained after encapsulation can be Figure 6As shown. Obtain the object ID corresponding to the basic data set corresponding to the target person A and the object ID corresponding to the employment information data set, convert the format of the object IDs corresponding to the two data sets, obtain the JSON data corresponding to the target person, encrypt the JSON data to obtain encrypted data, and determine the encrypted data as the object data corresponding to the target person. And determine that the data type corresponding to the object data is employee information, generate the version information corresponding to the object data as version1, and determine that the object identifier corresponding to the second object is 1. Encapsulate the object identifier, the object identifier corresponding to the target person, the data type corresponding to the object data, and the version information into a second object, and upload it to the relational database. In other words, each second object includes an object identifier, multiple associated object IDs, an object type, and version information.
[0120] Step 12: Store the second object in a preset database.
[0121] The specific execution process and technical effects of the above steps in this embodiment are similar to the specific execution process and technical effects in the above embodiments. Please refer to the above statements for details, and no further details will be given here.
[0122] In addition, the data storage method provided by the embodiment of the present invention can be executed in the cloud or on the server side of the target application. In the cloud, several computing nodes (cloud servers) can be deployed, and each computing node has computing, storage and other processing resources. In the cloud, multiple computing nodes can be organized to provide the data storage service.
[0123] The data storage device of one or more embodiments of the present invention will be described in detail below. Those skilled in the art will appreciate that these devices can be configured using commercially available hardware components through the steps taught in this solution.
[0124] Figure 7 A schematic diagram of a data storage device according to an embodiment of the present invention is shown in FIG. Figure 7 As shown, the device includes: an acquisition module 11, a classification module 12, a generation module 13, a creation module 14, and a storage module 15.
[0125] The acquisition module 11 is used to acquire the to-be-processed data corresponding to the target person, and the to-be-processed data includes multiple data items.
[0126] The classification module 12 is used to classify the multiple data items to obtain multiple data sets, where the data items in the same data set are data of the same category.
[0127] The generating module 13 is configured to generate first object data corresponding to each of the plurality of data sets, wherein the first object data is an abstract representation of the data set.
[0128] The creation module 14 is configured to create first objects corresponding to each of the plurality of data sets according to the first object data corresponding to each of the plurality of data sets.
[0129] The storage module 15 is used to upload the first objects corresponding to the multiple data sets to a preset database, so as to store the multiple data sets in the preset database in the form of objects.
[0130] In an optional embodiment, the generating module 13 may be specifically used to: perform format conversion on data items in a target data set to obtain first object data corresponding to the target data set, where the target data set is any one of the multiple data sets.
[0131] In an optional embodiment, the generation module 13 can be specifically used to: obtain a preset object structure, which is used to specify the data format corresponding to each data item in the target data set; create an object instance corresponding to the target data set according to the preset object structure and the data items in the target data set to obtain the first object data corresponding to the target data set.
[0132] In an optional embodiment, the generation module 13 can also be used to: determine the constructors corresponding to the multiple data sets, wherein the parameters passed into the constructor are variable strings; based on the constructor, create abstract classes corresponding to the multiple data sets. Pass the data items of the target data set into the constructor in the abstract class, create an object instance corresponding to the target data set, and obtain a JSON string corresponding to the target data set; determine the JSON string corresponding to the target data set as the first object data corresponding to the target data set.
[0133] In an optional embodiment, the device may also include an association module, which is specifically used to: obtain multiple first objects corresponding to the target person; determine the object identifiers corresponding to each of the multiple first objects; generate a second object corresponding to the target person based on the object identifiers corresponding to each of the multiple first objects, the second object being associated with the multiple first objects; and store the second object in a preset database.
[0134] In an optional embodiment, the association module is specifically used to: obtain an abstract class corresponding to the multiple data sets; pass the object identifiers corresponding to each of the multiple first objects into the constructor in the abstract class, create an object instance corresponding to the target object, and obtain a JSON string corresponding to the target object; determine the JSON string corresponding to the target object as the second object data corresponding to the target object; and generate a second object corresponding to the target object based on the second object data corresponding to the target object.
[0135] In an optional embodiment, the creation module 14 is specifically used to: determine the object type of the first object data corresponding to each of the multiple data sets according to the data type corresponding to the multiple data sets; determine the version information corresponding to each of the multiple first object data; encapsulate the first object data corresponding to each of the multiple data sets, the object type corresponding to each of the multiple first object data, and the version information corresponding to each of the multiple first objects into a first object corresponding to each of the multiple data sets; determine the object identifier of the first object corresponding to each of the multiple data sets; upload the object identifier and the first object corresponding to each of the multiple data sets to the preset database to store the first objects corresponding to each of the multiple data sets and the object identifier in the database.
[0136] In an optional embodiment, the storage module 15 is also used to: receive a data modification request, the request including target data to be modified; based on the target data to be modified, determine a first object storing the target data and an object identifier of the first object; search a database for a storage record corresponding to the object identifier of the first object to obtain a corresponding latest storage record; and modify the first object data in the latest storage record according to the target data to be modified to obtain the modified target data.
[0137] Figure 7 The device shown can execute the steps in the data storage method in the aforementioned embodiment. The detailed execution process and technical effects can be found in the description of the aforementioned embodiment, which will not be repeated here.
[0138] The embodiment of the present invention also provides an electronic device, such as Figure 8 As shown, the electronic device may include: a processor 21, a memory 22, and a communication interface 23. The memory 22 stores executable codes, and when the executable codes are executed by the processor 21, the processor 21 implements the data storage method in the above-mentioned embodiment.
[0139] In addition, an embodiment of the present invention provides a non-temporary machine-readable storage medium, on which executable code is stored. When the executable code is executed by a processor of an electronic device, the processor can at least implement the data storage method provided in the aforementioned embodiment.
[0140] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment. Those of ordinary skill in the art may understand and implement the present invention without creative effort.
[0141] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by adding a necessary general hardware platform, and of course can also be implemented by combining hardware and software. Based on such an understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a computer product, and the present invention can be in the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0142] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A data storage method, characterized in that: include: Acquire the data to be processed corresponding to the target person, wherein the data to be processed includes multiple data items; Classifying the multiple data items to obtain multiple data sets, where the data items in the same data set are data of the same category; Generate first object data corresponding to each of the plurality of data sets, where the first object data is an abstract representation of the data set; Creating first objects corresponding to each of the plurality of data sets according to first object data corresponding to each of the plurality of data sets; The first objects corresponding to the plurality of data sets are uploaded to a preset database, so that the plurality of data sets are stored in the preset database in the form of objects.
2. The method according to claim 1, characterized in that The generating first object data corresponding to each of the plurality of data sets comprises: Format conversion is performed on data items in a target data set to obtain first object data corresponding to the target data set, where the target data set is any one of the multiple data sets.
3. The method according to claim 2, characterized in that The step of converting the format of the data items in the target data set to obtain the first object data corresponding to the target data set includes: Obtaining a preset object structure, wherein the object structure is used to specify a data format corresponding to each data item in the target data set; According to the preset object structure and the data items in the target data set, an object instance corresponding to the target data set is created to obtain first object data corresponding to the target data set.
4. The method according to claim 3, characterized in that The obtaining of the preset object structure includes: Determine a constructor corresponding to the plurality of data sets, wherein the constructor specifies that a parameter passed into the constructor is a variable string; Based on the construction method, create abstract classes corresponding to the multiple data sets; The step of creating an object instance corresponding to the target data set according to the preset object structure and the data items in the target data set to obtain first object data corresponding to the target data set includes: Passing the data items of the target data set into the constructor in the abstract class, creating an object instance corresponding to the target data set, so as to obtain a JSON string corresponding to the target data set; The JSON string corresponding to the target data set is determined as the first object data corresponding to the target data set.
5. The method according to claim 1, characterized in that The method further comprises: Acquire multiple first objects corresponding to the target person; Determine an object identifier corresponding to each of the plurality of first objects; generating a second object corresponding to the target person according to the object identifiers corresponding to the multiple first objects, wherein the second object is associated with the multiple first objects; The second object is stored in a preset database.
6. The method according to claim 5, characterized in that The step of generating a second object corresponding to the target object according to the object identifiers corresponding to the plurality of first objects respectively includes: Obtaining abstract classes corresponding to the multiple data sets; Passing the object identifiers corresponding to each of the multiple first objects into the constructor in the abstract class, creating an object instance corresponding to the target object, so as to obtain a JSON string corresponding to the target object; Determine the JSON string corresponding to the target object as the second object data corresponding to the target object; A second object corresponding to the target object is generated according to the second object data corresponding to the target object.
7. The method according to claim 1, characterized in that The step of creating first objects corresponding to each of the plurality of data sets according to the first object data corresponding to each of the plurality of data sets comprises: Determine, according to the data types corresponding to the multiple data sets, the object type of the first object data corresponding to each of the multiple data sets; Determine the version information corresponding to each of the plurality of first object data; Encapsulate the first object data corresponding to each of the plurality of data sets, the object type corresponding to each of the plurality of first object data, and the version information corresponding to each of the plurality of first objects into the first objects corresponding to each of the plurality of data sets; The storing the first objects corresponding to the plurality of data sets respectively into a preset database comprises: Determine an object identifier of a first object corresponding to each of the plurality of data sets; The object identifier and the first object corresponding to each of the plurality of data sets are uploaded to the preset database, so as to store the first object corresponding to each of the plurality of data sets and the object identifier in the database.
8. The method according to claim 1, characterized in that The method further comprises: receiving a data modification request, wherein the request includes target data to be modified; Based on the target data to be modified, determining a first object storing the target data and an object identifier of the first object; Searching a database for a storage record corresponding to the object identifier of the first object to obtain a corresponding latest storage record; According to the target data to be modified, the first object data in the latest storage record is modified to obtain the modified target data.
9. An electronic device, characterized in that: include: A memory, a processor, and a communication interface; wherein the memory stores executable code, and when the executable code is executed by the processor, the processor executes the data storage method as described in any one of claims 1 to 8.
10. A non-transitory machine-readable storage medium, characterized in that: The non-transitory machine-readable storage medium stores executable code, and when the executable code is executed by a processor of an electronic device, the processor is caused to execute the data storage method according to any one of claims 1 to 8.