CN115544169A - Data synchronization method, device, equipment and storage medium - Google Patents

Data synchronization method, device, equipment and storage medium Download PDF

Info

Publication number
CN115544169A
CN115544169A CN202211370894.4A CN202211370894A CN115544169A CN 115544169 A CN115544169 A CN 115544169A CN 202211370894 A CN202211370894 A CN 202211370894A CN 115544169 A CN115544169 A CN 115544169A
Authority
CN
China
Prior art keywords
target
data
field
entity
graph database
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.)
Pending
Application number
CN202211370894.4A
Other languages
Chinese (zh)
Inventor
戴頔
马骁
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Krypton Information Technology Co ltd
Original Assignee
Shanghai Krypton Information Technology Co ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Shanghai Krypton Information Technology Co ltd filed Critical Shanghai Krypton Information Technology Co ltd
Priority to CN202211370894.4A priority Critical patent/CN115544169A/en
Publication of CN115544169A publication Critical patent/CN115544169A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational databases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational databases
    • G06F16/288Entity relationship models

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application discloses a data synchronization method, a device, equipment and a storage medium, which relate to the technical field of computers and are used for solving the defect that a table must be split for table data import at present due to large data volume, and comprise the following steps: identifying fields in the relational database to obtain target fields; establishing a corresponding data model in a graph database based on the target field to obtain a target data model; and synchronizing table data in the relational database to the target data model in the graph database according to the target field. According to the data synchronization method and device, the corresponding target data model is created in the graph database through the fields in the relational database, so that the data and the data relation in the relational database are synchronized to the graph database, the integrity of data synchronization is guaranteed, and the efficiency of data synchronization is improved.

Description

Data synchronization method, device, equipment and storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a data synchronization method, apparatus, device, and storage medium.
Background
The relational database is organized by adopting a relational model, the graph database is a non-relational database, points and edges are used as storage units, the graph database is efficiently stored, query graph data is used as a design principle, and the data storage format and the relation of the relational database are different from those of the graph database. The data of the relational database is now synchronized with the graph data in a manner that the content of the relational database is converted into RDF (Resource Description Framework) data, and then imported into the graph database through RDF. This conversion method has a disadvantage that in a relational database, the relationship between data exists in a plurality of tables, and it is necessary to import the associated tables into RDF format data at the same time to store the relationship. However, a table-by-table synchronization is required in the following cases: the data volume is large, the storage space of the computer is insufficient, and a table needs to be split for data synchronization; when the method of monitoring the relational database change for synchronizing data is adopted, the association relationship may be lost due to inconsistency of the write time of each table.
Disclosure of Invention
In view of the above, an object of the present invention is to provide a data synchronization method, apparatus, device and storage medium, which can ensure the integrity of data synchronization and improve the efficiency of data synchronization. The specific scheme is as follows:
in a first aspect, the present application discloses a data synchronization method, including:
identifying fields in the relational database to obtain target fields;
establishing a corresponding data model in a graph database based on the target field to obtain a target data model;
synchronizing table data in the relational database to the target data model in the graph database according to the target field.
Optionally, the identifying fields in the relational database to obtain the target field includes:
fields in the relational database are identified to obtain a primary key field, a foreign key field, and a common field.
Optionally, the establishing a corresponding data model in a graph database based on the target field to obtain a target data model includes:
mapping operation is carried out according to the primary key field so as to obtain a corresponding point in the graph database;
determining a set of points with the same characteristics or attributes as a target type;
creating a corresponding edge in the graph database according to the common field;
determining the type of association according to the foreign key field, and creating a corresponding association edge in the graph database based on the type of association;
determining the target data model based on the target type, the edge, and the associated edge.
Optionally, the synchronizing table data in the relational database to the target data model in the graph database according to the target field includes:
acquiring a target table in the relational database, and acquiring the table data contained in the target table;
adding the table data to a target entity in the graph database corresponding to the target table based on the target field of the target table to obtain the target data model.
Optionally, before adding the table data to the target entity corresponding to the target table in the graph database based on the target field of the target table, the method further includes:
determining data corresponding to the primary key field in the target table as a unique identifier, and creating a corresponding entity in the graph database according to the unique identifier to obtain a target entity;
correspondingly, the adding the table data to the target entity corresponding to the target table in the graph database based on the target field of the target table includes:
adding corresponding attributes to the target entity based on the data corresponding to the common fields in the target table;
and setting a corresponding association relation for the target entity based on the data corresponding to the foreign key field in the target table.
Optionally, before setting a corresponding association relationship for the target entity based on the data corresponding to the foreign key field in the target table, the method further includes:
judging whether an associated entity corresponding to the foreign key field exists in the graph database or not;
if the associated entity corresponding to the foreign key field does not exist, a target empty entity is created, and the foreign key field is determined as a main key field of the target empty entity;
correspondingly, the setting of the corresponding association relationship for the target entity based on the data corresponding to the foreign key field in the target table includes:
when the association entity corresponding to the foreign key field does not exist, determining the target empty entity as the target entity so as to set the association relation for the target empty entity based on the data corresponding to the foreign key field in the target table;
when the associated entity corresponding to the foreign key field exists, determining the associated entity as the target entity so as to set the association relationship for the associated entity based on the data corresponding to the foreign key field in the target table.
Optionally, before identifying the field in the relational database to obtain the target field, the method further includes:
and monitoring the relational database in real time, and executing the step of identifying the fields in the relational database to obtain target fields when monitoring that the data in the relational database changes.
In a second aspect, the present application discloses a data synchronization apparatus, comprising:
the field identification module is used for identifying fields in the relational database to obtain target fields;
the data model establishing module is used for establishing a corresponding data model in a graph database based on the target field so as to obtain a target data model;
and the data synchronization module is used for synchronizing the table data in the relational database to the target data model in the graph database according to the target field.
In a third aspect, the present application discloses an electronic device, comprising:
a memory for storing a computer program;
a processor for executing said computer program for implementing the steps of the data synchronization method as disclosed in the foregoing.
In a fourth aspect, the present application discloses a computer readable storage medium for storing a computer program; wherein the computer program realizes the data synchronization method as disclosed in the foregoing when executed by a processor.
As can be seen, the present application provides a data synchronization method, including: identifying fields in the relational database to obtain target fields; establishing a corresponding data model in a graph database based on the target field to obtain a target data model; and synchronizing table data in the relational database to the target data model in the graph database according to the target field. Therefore, the corresponding target data model is established in the graph database through the fields in the relational database, so that the data and the data relation in the relational database are synchronized to the graph database, the data in the relational database do not need to be split, the data relation and the data are not split when the data are synchronized, the integrity of data synchronization is ensured, and the efficiency of data synchronization is improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the embodiments or the prior art descriptions will be briefly described below, it is obvious that the drawings in the following description are only embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
FIG. 1 is a flow chart of a data synchronization method disclosed herein;
FIG. 2 is a flow chart of a particular data synchronization method disclosed herein;
FIG. 3 is a flow chart of a particular data synchronization method disclosed herein;
FIG. 4 is a flow chart of a particular data synchronization method disclosed herein;
FIG. 5 is a schematic diagram of a data synchronization apparatus provided in the present application;
fig. 6 is a block diagram of an electronic device provided in the present application.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Currently, the method of synchronizing the data of the relational database to the graph data is to convert the content of the relational database into RDF data and import the RDF data into the graph database. This conversion method has a disadvantage that the relationship between data exists in a plurality of tables in the relational database, and it is necessary to import the associated tables into RDF format data at the same time to store the relationship. However, a table-by-table synchronization is required in the following cases: the data volume is large, the storage space of the computer is insufficient, and a table needs to be split for data synchronization; when the method of monitoring the relational database change for synchronizing data is adopted, the association relationship may be lost due to inconsistency of the write time of each table. Therefore, the data synchronization method is provided, and can ensure the integrity of data synchronization and improve the efficiency of data synchronization.
The embodiment of the invention discloses a data synchronization method, which is shown in figure 1 and comprises the following steps:
step S11: fields in the relational database are identified to obtain a target field.
In this embodiment, the fields in the relational database are identified to obtain the target fields. It can be understood that the field attributes in the relational database are divided into three types, namely a primary key field, an external key field and a common field, wherein the primary key field, namely primary key constraint, is a unique identifier of a row of data in a data table and can be regarded as a unique identifier of a data entity; the foreign key field contains the primary key value of another table, and defines the relationship between the two tables; the normal field only records data and does not contain an association relationship. And in order to synchronize the changed data in the relational database into the graph database in time, the graph database monitors the relational database in real time, and when the data in the relational database is monitored to be changed, the step of identifying the fields in the relational database is executed to obtain the target fields, namely, the fields in the relational database are identified to obtain the primary key fields, the foreign key fields and the common fields.
Step S12: and establishing a corresponding data model in a graph database based on the target field to obtain a target data model.
In this embodiment, after a target field of a certain table in the relational database is identified, a data model corresponding to the table is established in the graph database based on the target field to obtain a target data model. Specifically, a corresponding structural part is respectively established in a graph database according to each target field of a certain table in the identified relational database, and a data model corresponding to the table is established based on all the structural parts. It will be appreciated that each table in a relational database corresponds to a data model in the graph database.
Step S13: synchronizing table data in the relational database to the target data model in the graph database according to the target field.
In this embodiment, after a corresponding data model is established in a graph database based on the target field to obtain a target data model, table data in the relational database is synchronized to the target data model in the graph database according to the target field. It can be understood that when table data in the relational database is synchronized to a target data model, a primary key field is used as a unique identifier, corresponding attributes are added based on a common field, and a corresponding association relationship is created according to a foreign key field, so that the integrity of the data is ensured. The scheme is applied to information system application, so that data in the relational database is synchronized into the graph database, not only can various data in the relational database be synchronized, but also the data relation in the relational database can be synchronized into the graph database; one data table can be synchronized into the graph database firstly, and then the data of the other data table is synchronized into the graph database, so that all the data of the database are not required to be synchronized at one time; and synchronizing the data in real time by monitoring whether the data content of the relational database is changed.
As can be seen, the present application provides a data synchronization method, including: identifying fields in the relational database to obtain target fields; establishing a corresponding data model in a graph database based on the target field to obtain a target data model; synchronizing table data in the relational database to the target data model in the graph database according to the target field. Therefore, the corresponding target data model is established in the graph database through the fields in the relational database, so that the data and the data relation in the relational database are synchronized to the graph database, the data in the relational database do not need to be split, the data relation and the data are not split when the data are synchronized, the integrity of data synchronization is ensured, and the efficiency of data synchronization is improved.
Referring to fig. 2, the embodiment of the present invention discloses a data synchronization method, and the present embodiment further describes and optimizes the technical solution with respect to the previous embodiment.
Step S21: fields in the relational database are identified to obtain a target field.
Step S22: and mapping operation is carried out according to the primary key field to obtain corresponding points in the graph database, and a set of points with the same characteristics or attributes is determined as a target type.
In this embodiment, after the fields in the relational database are identified to obtain the target fields, mapping operation is performed according to the primary key fields to obtain corresponding points in the graph database, and a set of points having the same characteristics or attributes is determined as the target type. It can be understood that, when the data model is established in the graph database, mapping is firstly carried out according to the primary key field in the relational database to obtain corresponding points in the graph database, and all the points are taken as one type, namely the target type is obtained. Where a type is an abstraction of a collection of entities having the same characteristics or attributes, and one primary key field corresponds to one data model.
Step S23: and creating a corresponding edge in the graph database according to the common field.
In this embodiment, after the mapping operation is performed according to the primary key field to obtain the corresponding point in the graph database, a corresponding edge is created in the graph database according to the common field. It will be appreciated that edges are created in the graph database from the common fields, the edges representing certain attributes, characteristics, values of objects.
Step S24: determining a type of association according to the foreign key field, and creating a corresponding association edge in the graph database based on the type of association.
In this embodiment, after creating the corresponding edge in the graph database according to the common field, determining the type of association according to the foreign key field, and creating the corresponding associated edge in the graph database based on the type of association. It will be appreciated that the type of association created from the foreign key field creates an associated edge in the graph database that represents a relationship between one type and another.
Step S25: determining the target data model based on the target type, the edge, and the associated edge.
In this embodiment, after the corresponding associated edge is created in the graph database based on the type of association, the object data model is determined based on the object type, the edge, and the associated edge. It is understood that a data model is constructed in the graph database based on the primary key field, foreign key field and common field of a table to be synchronized in the relational database.
Step S26: synchronizing table data in the relational database to the target data model in the graph database according to the target field.
For the specific content of the above steps S21 and S26, reference may be made to the corresponding content disclosed in the foregoing embodiments, and details are not repeated here.
Therefore, the embodiment of the application identifies the fields in the relational database to obtain the target fields; mapping operation is carried out according to the primary key field to obtain corresponding points in the graph database, and a set of points with the same characteristics or attributes is determined as a target type; creating a corresponding edge in the graph database according to the common field; determining the type of association according to the foreign key field, and creating a corresponding association edge in the graph database based on the type of association; determining the target data model based on the target type, the edge, and the associated edge; and synchronizing the table data in the relational database to the target data model in the graph database according to the target field, so that the integrity of data synchronization is ensured, and the efficiency of data synchronization is improved.
Referring to fig. 3, an embodiment of the present invention discloses a data synchronization method, and this embodiment further describes and optimizes the technical solution with respect to the previous embodiment.
Step S31: fields in the relational database are identified to obtain a target field.
Step S32: and establishing a corresponding data model in the graph database based on the target field to obtain a target data model.
Step S33: and acquiring a target table in the relational database, and acquiring the table data contained in the target table.
In this embodiment, after a corresponding data model is established in a graph database based on the target field to obtain a target data model, a target table in the relational database is obtained, and the table data included in the target table is obtained. It is understood that, as shown in fig. 4, after the data model is built in the graph database, a table to be synchronized is first determined as a target table from the tables in the relational database, and then the table data included in the target table is obtained for subsequent data synchronization operation. After the data synchronization in the target table is finished, judging whether a table which needs synchronization and does not start synchronization still exists in the relational database, if so, selecting a table which needs synchronization and does not start synchronization as a target table of next data synchronization and executing data synchronization operation again; if not, the synchronization is completed.
Step S34: and determining data corresponding to the primary key field in the target table as a unique identifier, and creating a corresponding entity in the graph database according to the unique identifier to obtain a target entity.
In this embodiment, after the table data included in the target table is acquired, the data corresponding to the primary key field in the target table is determined as a unique identifier, and a corresponding entity is created in the map database according to the unique identifier, so as to obtain a target entity. It is understood that in synchronizing data in the target table to the data model, the data of the primary key field of the target table is first used as a unique identifier of an entity, and a corresponding entity is created in the graph database. An entity can be regarded as an abstraction of an individual, and a person, a movie, and a sentence can be regarded as one entity.
Step S35: adding the table data to a target entity in the graph database corresponding to the target table based on the target field of the target table to obtain the target data model.
In this embodiment, after a corresponding entity is created in the graph database according to the unique identifier to obtain a target entity, the table data is added to the target entity corresponding to the target table in the graph database based on the target field of the target table to obtain the target data model. As shown in fig. 4, if it is determined that there is no corresponding entity currently in synchronizing table data, a null entity is created and an edge relationship is bound. Specifically, adding a corresponding attribute to the target entity based on the data corresponding to the common field in the target table; and setting a corresponding association relation (also called an association edge) for the target entity based on the data corresponding to the foreign key field in the target table. It should be noted that before setting a corresponding association relationship for the target entity based on the data corresponding to the foreign key field in the target table, it is necessary to determine whether an associated entity corresponding to the foreign key field exists in the graph database; if the associated entity corresponding to the foreign key field does not exist, special processing for the foreign key without the corresponding entity needs to be executed, namely, a target empty entity is created, and the foreign key field is determined as the primary key field of the target empty entity. When the association entity corresponding to the foreign key field does not exist, determining the target empty entity as the target entity so as to set the association relation for the target empty entity based on the data corresponding to the foreign key field in the target table; when the associated entity corresponding to the foreign key field exists, the associated entity is determined to be the target entity, so that the association relation is set for the associated entity based on the data corresponding to the foreign key field in the target table. It can be understood that, when data is synchronized, due to different sequences of the synchronization table, a corresponding associated entity is absent when the foreign key field is synchronized, a null entity is created at this time, the primary key field of this entity is the synchronized foreign key field, and the null entity created according to the foreign key does not contain other attributes, and can be regarded as a null entity containing only a unique identifier (i.e., the foreign key field).
Furthermore, when other tables are synchronized, the attributes in each table in the relational database are synchronized in sequence, and other foreign key fields and common fields are supplemented to the created empty entities in the subsequent importing process, so that the integrity of the data is ensured.
For example, if SQL (Structured Query Language) has the following three tables:
watch 1
id name
1 Zhang San
2 Li Si
Wherein, the first table is a user table.
Watch two
id name
1 Item one
2 Item two
Wherein, the second table is the project table.
Watch III
Figure BDA0003924697790000091
Figure BDA0003924697790000101
Wherein, the third table is a user-project (user-project) table.
When synchronizing these three tables, first, a user model and an item model corresponding to the user table and the item table, respectively, are created in a graph database.
The user model building code is as follows:
Figure BDA0003924697790000102
the project model build code is as follows:
Project{
name:String
}
if the table data in the User table is synchronized to the User model first, a User entity is created in the graph data according to a User (User) table first (if the project table is synchronized first, the process of creating the project entity is the same as the process of creating the User entity), and the specific codes are as follows:
Figure BDA0003924697790000103
after the user entity is created, the user project table is synchronized to the user model and the project model. Specifically, according to the association relationship in the User Project User-Project table, the relationship data of the Project is added in the User entity, and the specific codes are as follows:
Figure BDA0003924697790000104
Figure BDA0003924697790000111
it should be noted that, by adding created Project entities in the graph database, since only the primary key is protected in the User Project User-Project table, the created data only contains Id, so as to avoid data duplication, and the codes are as follows:
Figure BDA0003924697790000112
and after the operation is finished, synchronizing the project table to the project model. According to the project (Proejct) table, adding project related data in the project entity, wherein the specific codes are as follows:
Figure BDA0003924697790000113
so far, the table data and corresponding incidence relation of the three tables in the relational database are all imported into the database. It is understood that the execution order of the tables can be arbitrarily set during the import process.
For the specific content of the above steps S31 and S32, reference may be made to the corresponding content disclosed in the foregoing embodiments, and details are not repeated here.
Therefore, the embodiment of the application identifies the fields in the relational database to obtain the target fields; establishing a corresponding data model in a graph database based on the target field to obtain a target data model; acquiring a target table in the relational database, and acquiring the table data contained in the target table; determining data corresponding to the primary key field in the target table as a unique identifier, and creating a corresponding entity in the graph database according to the unique identifier to obtain a target entity; and adding the table data to a target entity corresponding to the target table in the graph database based on the target field of the target table to obtain the target data model, so that the integrity of data synchronization is ensured, and the efficiency of data synchronization is improved.
Referring to fig. 5, the embodiment of the present application further discloses a data synchronization apparatus, which includes:
a field identification module 11, configured to identify a field in a relational database to obtain a target field;
a data model establishing module 12, configured to establish a corresponding data model in a graph database based on the target field to obtain a target data model;
and the data synchronization module 13 is configured to synchronize table data in the relational database to the target data model in the graph database according to the target field.
As can be seen, the present application includes: identifying fields in the relational database to obtain target fields; establishing a corresponding data model in a graph database based on the target field to obtain a target data model; and synchronizing table data in the relational database to the target data model in the graph database according to the target field. Therefore, the corresponding target data model is established in the graph database through the fields in the relational database, so that the data and the data relation in the relational database are synchronized to the graph database, the data in the relational database do not need to be split, the data relation and the data are not split when the data are synchronized, the integrity of data synchronization is ensured, and the efficiency of data synchronization is improved.
In some specific embodiments, the field identification module 11 specifically includes:
the monitoring unit is used for monitoring the relational database in real time;
and the field identification unit is used for identifying the fields in the relational database to obtain a primary key field, a foreign key field and a common field when monitoring that the data in the relational database changes.
In some embodiments, the data model building module 12 specifically includes:
the mapping unit is used for carrying out mapping operation according to the primary key field so as to obtain a corresponding point in the graph database;
a target type determining unit for determining a set of points having the same characteristics or attributes as a target type;
an edge creating unit, configured to create a corresponding edge in the graph database according to the common field;
the association edge creating unit is used for determining the type of association according to the foreign key field and creating a corresponding association edge in the graph database based on the type of association;
a target data model determination unit to determine the target data model based on the target type, the edge, and the associated edge.
In some specific embodiments, the data synchronization module 13 specifically includes:
a table data acquiring unit, configured to acquire a target table in the relational database, and acquire the table data included in the target table;
an entity creating unit, configured to determine data corresponding to the primary key field in the target table as a unique identifier, and create a corresponding entity in the graph database according to the unique identifier, so as to obtain a target entity;
the attribute adding unit is used for adding corresponding attributes to the target entity based on the data corresponding to the common fields in the target table;
a correlation entity judging unit, configured to judge whether a correlation entity corresponding to the foreign key field exists in the graph database;
a target empty entity creating unit, configured to create a target empty entity if the associated entity corresponding to the foreign key field does not exist, and determine the foreign key field as a primary key field of the target empty entity;
a first association relationship setting unit, configured to determine the target empty entity as the target entity when the association entity corresponding to the foreign key field does not exist, so as to set the association relationship for the target empty entity based on the data corresponding to the foreign key field in the target table, so as to obtain the target data model;
a second association relationship setting unit, configured to, when the association entity corresponding to the foreign key field exists, determine the association entity as the target entity, so as to set the association relationship for the association entity based on the data corresponding to the foreign key field in the target table.
Furthermore, the embodiment of the application also provides electronic equipment. FIG. 6 is a block diagram illustrating an electronic device 20 according to an exemplary embodiment, and the contents of the diagram should not be construed as limiting the scope of use of the present application in any way.
Fig. 6 is a schematic structural diagram of an electronic device 20 according to an embodiment of the present disclosure. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input output interface 25, and a communication bus 26. Wherein the memory 22 is used for storing a computer program, and the computer program is loaded and executed by the processor 21 to implement the relevant steps in the data synchronization method disclosed in any of the foregoing embodiments. In addition, the electronic device 20 in the present embodiment may be specifically an electronic computer.
In this embodiment, the power supply 23 is configured to provide a working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and an external device, and a communication protocol followed by the communication interface is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited herein; the input/output interface 25 is configured to obtain external input data or output data to the outside, and a specific interface type thereof may be selected according to specific application requirements, which is not specifically limited herein.
In addition, the storage 22 is used as a carrier for resource storage, and may be a read-only memory, a random access memory, a magnetic disk or an optical disk, etc., and the resources stored thereon may include an operating system 221, a computer program 222, etc., and the storage manner may be a transient storage or a permanent storage.
The operating system 221 is used for managing and controlling each hardware device on the electronic device 20 and the computer program 222, and may be Windows Server, netware, unix, linux, or the like. The computer program 222 may further include a computer program that can be used to perform other specific tasks in addition to the computer program that can be used to perform the data synchronization method disclosed by any of the foregoing embodiments and executed by the electronic device 20.
Further, an embodiment of the present application further discloses a storage medium, in which a computer program is stored, and when the computer program is loaded and executed by a processor, the steps of the data synchronization method disclosed in any of the foregoing embodiments are implemented.
The embodiments are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same or similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrases "comprising one of 8230; \8230;" 8230; "does not exclude the presence of additional like elements in a process, method, article, or apparatus that comprises the element.
The data synchronization method, apparatus, device and storage medium provided by the present invention are described in detail above, and the principle and implementation of the present invention are explained herein by applying specific examples, and the description of the above examples is only used to help understanding the method and core idea of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, the specific embodiments and the application range may be changed, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

Claims (10)

1. A method of data synchronization, comprising:
identifying fields in the relational database to obtain target fields;
establishing a corresponding data model in a graph database based on the target field to obtain a target data model;
and synchronizing table data in the relational database to the target data model in the graph database according to the target field.
2. The data synchronization method of claim 1, wherein identifying a field in a relational database to obtain a target field comprises:
fields in the relational database are identified to obtain a primary key field, a foreign key field, and a common field.
3. The data synchronization method according to claim 2, wherein the establishing a corresponding data model in a graph database based on the target field to obtain a target data model comprises:
mapping operation is carried out according to the primary key field so as to obtain a corresponding point in the graph database;
determining a set of points with the same characteristics or attributes as a target type;
creating a corresponding edge in the graph database according to the common field;
determining the type of association according to the foreign key field, and creating a corresponding association edge in the graph database based on the type of association;
determining the target data model based on the target type, the edge, and the associated edge.
4. The data synchronization method according to claim 3, wherein the synchronizing table data in the relational database to the target data model in the graph database according to the target field comprises:
acquiring a target table in the relational database, and acquiring the table data contained in the target table;
adding the table data to a target entity in the graph database corresponding to the target table based on the target field of the target table to obtain the target data model.
5. The data synchronization method of claim 4, wherein before adding the table data to a target entity in the graph database corresponding to the target table based on the target field of the target table, further comprising:
determining data corresponding to the primary key fields in the target table as unique identifiers, and creating corresponding entities in the graph database according to the unique identifiers to obtain target entities;
correspondingly, the adding the table data to the target entity corresponding to the target table in the graph database based on the target field of the target table includes:
adding corresponding attributes to the target entity based on the data corresponding to the common fields in the target table;
and setting a corresponding association relation for the target entity based on the data corresponding to the foreign key field in the target table.
6. The data synchronization method according to claim 5, before setting a corresponding association relationship for the target entity based on the data corresponding to the foreign key field in the target table, further comprising:
judging whether an associated entity corresponding to the foreign key field exists in the graph database or not;
if the associated entity corresponding to the foreign key field does not exist, a target empty entity is created, and the foreign key field is determined as a main key field of the target empty entity;
correspondingly, the setting of the corresponding association relationship for the target entity based on the data corresponding to the foreign key field in the target table includes:
when the associated entity corresponding to the foreign key field does not exist, determining the target empty entity as the target entity so as to set the association relationship for the target empty entity based on the data corresponding to the foreign key field in the target table;
when the associated entity corresponding to the foreign key field exists, determining the associated entity as the target entity so as to set the association relationship for the associated entity based on the data corresponding to the foreign key field in the target table.
7. The data synchronization method according to any one of claims 1 to 6, further comprising:
and monitoring the relational database in real time, and executing the step of identifying the fields in the relational database to obtain target fields when monitoring that the data in the relational database changes.
8. A data synchronization apparatus, comprising:
the field identification module is used for identifying fields in the relational database to obtain target fields;
the data model establishing module is used for establishing a corresponding data model in a graph database based on the target field so as to obtain a target data model;
and the data synchronization module is used for synchronizing the table data in the relational database to the target data model in the graph database according to the target field.
9. An electronic device, comprising:
a memory for storing a computer program;
a processor for executing the computer program to carry out the steps of the data synchronization method according to any one of claims 1 to 7.
10. A computer-readable storage medium for storing a computer program; wherein the computer program when executed by a processor implements the data synchronization method of any one of claims 1 to 7.
CN202211370894.4A 2022-11-03 2022-11-03 Data synchronization method, device, equipment and storage medium Pending CN115544169A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211370894.4A CN115544169A (en) 2022-11-03 2022-11-03 Data synchronization method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211370894.4A CN115544169A (en) 2022-11-03 2022-11-03 Data synchronization method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115544169A true CN115544169A (en) 2022-12-30

Family

ID=84720100

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211370894.4A Pending CN115544169A (en) 2022-11-03 2022-11-03 Data synchronization method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115544169A (en)

Similar Documents

Publication Publication Date Title
US9026901B2 (en) Viewing annotations across multiple applications
CN106599104B (en) Massive data association method based on redis cluster
CN106874281B (en) Method and device for realizing database read-write separation
CN111008521B (en) Method, device and computer storage medium for generating wide table
US8489547B2 (en) System and method for transforming configuration data items in a configuration management database
US7020659B2 (en) System and method for managing bi-directional relationships between objects
CN111666344A (en) Heterogeneous data synchronization method and device
CN113672692B (en) Data processing method, data processing device, computer equipment and storage medium
CN115098062A (en) Code generation method and device
CN107239568B (en) Distributed index implementation method and device
CN104063377A (en) Information processing method and electronic equipment using same
CN107968798B (en) Network management resource label obtaining method, cache synchronization method, device and system
CN102799423A (en) Method and device for implementing dynamic method in JSF (java service face)
CN110597827A (en) Storage method and system of interface control file data
CN107463618B (en) Index creating method and device
CN115544169A (en) Data synchronization method, device, equipment and storage medium
CN115905371A (en) Data trend analysis method, device and equipment and computer readable storage medium
CN114819631A (en) Multitask visualization method and device, computer equipment and storage medium
EP3046307B1 (en) Processing method, device and system for data of distributed storage system
CN112685379B (en) Data organization method, system and equipment and storage medium
CN113760907A (en) Data uniqueness identification method in database
CN112685557A (en) Visualized information resource management method and device
CN115310415B (en) Data export method, device, equipment and storage medium
CN116739397B (en) Dynamic management method for new energy indexes
CN114185907A (en) Method and device for synchronizing database to data warehouse and electronic device

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