CN107315764B - Method and system for updating non-relational database associated data - Google Patents

Method and system for updating non-relational database associated data Download PDF

Info

Publication number
CN107315764B
CN107315764B CN201710330586.1A CN201710330586A CN107315764B CN 107315764 B CN107315764 B CN 107315764B CN 201710330586 A CN201710330586 A CN 201710330586A CN 107315764 B CN107315764 B CN 107315764B
Authority
CN
China
Prior art keywords
attribute
update
relational database
updating
trigger
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201710330586.1A
Other languages
Chinese (zh)
Other versions
CN107315764A (en
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.)
Beijing QIYI Century Science and Technology Co Ltd
Original Assignee
Beijing QIYI Century Science and 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 Beijing QIYI Century Science and Technology Co Ltd filed Critical Beijing QIYI Century Science and Technology Co Ltd
Priority to CN201710330586.1A priority Critical patent/CN107315764B/en
Publication of CN107315764A publication Critical patent/CN107315764A/en
Application granted granted Critical
Publication of CN107315764B publication Critical patent/CN107315764B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/23Updating

Landscapes

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

Abstract

The embodiment of the invention provides a method and a system for updating non-relational database associated data, wherein the method comprises the following steps: receiving the updating information; the update message includes an update value of an update attribute of the target object; loading a pre-established configuration file corresponding to the target object; the configuration file comprises each associated attribute of each associated object of the target object and the assignment mode of each associated attribute; analyzing the configuration file, and judging whether the updating attribute triggers cascade updating; if cascade update is triggered, determining the assignment of each trigger associated attribute according to the assignment mode of the trigger associated attribute of each trigger associated object and the updated value; the non-relational database is updated. The technical scheme of the embodiment of the invention is simple and easy to use, has universality, can complete the update of the associated data of the non-relational database at low cost, and is not easy to make mistakes; the association relation is configured through the configuration file, and the method is simple, clear and easy to expand.

Description

Method and system for updating non-relational database associated data
Technical Field
The invention relates to the field of databases, in particular to a method and a system for updating associated data of a non-relational database.
Background
The non-relational database has great advantages in processing mass data, high availability and expandability, and can solve the challenges brought by large-scale data set multiple data types, especially the difficult problem of big data application. In a relational database, information required to be associated is usually written as a field value into an association table; when the associated table is updated, the associated fields of the associated table must be updated at the same time, otherwise, the missing or invalidation of the association relationship may be caused.
The non-relational database removes the relational characteristics of the relational database, particularly the incidence relation between tables; therefore, for a non-relational database with a complex data structure and association relations, all association relations need to be processed when updating association data, high learning cost and development cost are needed, and errors are easy to occur.
Disclosure of Invention
In view of the foregoing, embodiments of the present invention are provided to provide a method and system for updating non-relational database-related data, which overcome or at least partially solve the above-mentioned problems of high updating cost and high error susceptibility of non-relational database-related data.
In order to solve the above problem, an embodiment of the present invention discloses a method for updating non-relational database related data, including:
receiving update information of a non-relational database; the update information includes an update value of an update attribute of a target object corresponding to the update information;
loading a pre-established configuration file corresponding to the target object; the configuration file comprises each associated attribute of each associated object of the target object and the assignment mode of each associated attribute;
analyzing the configuration file and judging whether the updating attribute triggers cascade updating or not;
if the update attribute triggers cascade update, determining the assignment of each trigger associated attribute according to the assignment mode of the trigger associated attribute of each trigger associated object and the update value;
and updating the non-relational database according to the updated value of the updated attribute of the target object and the assignment of the trigger associated attribute of each trigger associated object.
Preferably, the configuration file is an extensible markup language XML configuration file, and the assignment mode of each associated attribute is described through a preset object diagram navigation language OGNL expression;
if the update attribute triggers the cascade update, the step of determining the assignment of each trigger associated attribute according to the assignment mode of the trigger associated attribute of each trigger associated object and the update value comprises:
if the updating attribute triggers cascade updating, determining the triggering association attribute of each triggering association object in the XML configuration file;
and determining the assignment of the trigger associated attribute according to the OGNL expression of the trigger associated attribute of each trigger associated object and the updated value.
Preferably, the step of updating the non-relational database according to the updated value of the update attribute of the target object and the assignment of the trigger associated attribute of each trigger associated object includes:
inquiring the non-relational database, acquiring and storing the attribute information of the target object and each trigger associated object;
updating the stored attribute information of the target object and each trigger associated object according to the updated value of the updated attribute of the target object and the assignment of the trigger associated attribute of each trigger associated object;
and performing integral writing operation on the non-relational database by taking the saved attribute information of the target object and the trigger associated objects as a whole.
Preferably, when the non-relational database is a non-key-value pair database, the step of updating the non-relational database according to the updated value of the update attribute of the target object and the assignment of the trigger associated attribute of each trigger associated object includes:
taking the updated value of the updated attribute of the target object and the assignment of the trigger associated attribute of each trigger associated object as a whole, and executing the whole write-in operation on the non-relational database;
receiving a response of the non-relational database to the overall write operation;
judging whether the integral write-in operation is successfully executed or not according to the response;
and if the integral write-in operation is not successfully executed, continuing to execute the integral write-in operation on the non-relational database.
Preferably, the method further comprises:
and if the updating attribute does not trigger cascade updating, updating the non-relational database according to the updating value of the updating attribute of the target object.
Preferably, the method further comprises:
and modifying or adding the association relation of each object in the non-relational database by modifying the configuration file of the target object or adding the configuration file of the object in the non-relational database.
On the other hand, the embodiment of the invention also discloses a system for updating the associated data of the non-relational database, which comprises the following steps:
the update message receiving module is used for receiving the update information of the non-relational database; the update information includes an update value of an update attribute of a target object corresponding to the update information;
the configuration file loading module is used for loading a pre-established configuration file corresponding to the target object; the configuration file comprises each associated attribute of each associated object of the target object and the assignment mode of each associated attribute;
the configuration file analysis module is used for analyzing the configuration file and judging whether the update attribute triggers cascade update;
a cascade update triggering module, configured to determine, if the update attribute triggers cascade update, an assignment of each trigger associated attribute according to an assignment manner of the trigger associated attribute of each trigger associated object and the update value;
and the first database updating module is used for updating the non-relational database according to the updated value of the updated attribute of the target object and the assignment of the trigger associated attribute of each trigger associated object.
Preferably, the configuration file is an extensible markup language XML configuration file, and the assignment mode of each associated attribute is described through a preset object diagram navigation language OGNL expression;
the cascade update triggering module comprises:
the XML trigger confirmation module is used for determining the trigger correlation attributes of all trigger correlation objects in the XML configuration file if the update attributes trigger cascade update;
and the OGNL assignment module is used for determining assignment of the trigger associated attribute according to the OGNL expression of the trigger associated attribute of each trigger associated object and the updated value.
Preferably, the first database update module includes:
the object data storage module is used for inquiring the non-relational database, acquiring and storing the attribute information of the target object and each trigger associated object;
the object data updating module is used for updating the stored attribute information of the target object and each trigger associated object according to the updated value of the updated attribute of the target object and the assignment of the trigger associated attribute of each trigger associated object;
and the object data writing module is used for performing integral writing operation on the non-relational database by taking the saved attribute information of the target object and each trigger associated object as a whole.
Preferably, when the non-relational database is a non-key-value-pair database, the first database updating module includes:
the integral writing module is used for taking the updated value of the updated attribute of the target object and the assignment of the trigger associated attribute of each trigger associated object as a whole to execute integral writing operation on the non-relational database;
a response receiving module, configured to receive a response of the non-relational database to the overall write operation;
the write-in judging module is used for judging whether the integral write-in operation is successfully executed or not according to the response;
and the continuous writing module is used for continuously executing the integral writing operation on the non-relational database if the integral writing operation is not executed successfully.
Preferably, the system further comprises:
and the second database updating module is used for updating the non-relational database according to the updating value of the updating attribute of the target object if the updating attribute does not trigger cascade updating.
Preferably, the system further comprises:
and the configuration file updating module is used for modifying or adding the association relation of each object in the non-relational database by modifying the configuration file of the target object or adding the configuration file of the object in the non-relational database.
The embodiment of the invention has the following advantages:
in the embodiment of the invention, aiming at the updated value of the updated attribute of a target object in a non-relational database, loading a pre-established configuration file aiming at the target object, determining the assignment of the triggered associated attribute of the triggered associated object triggering cascade update by analyzing the associated relationship between the target object attribute and the associated object attribute in the configuration file, and then updating the non-relational database; the weakness of the non-relational database in the aspect of the incidence relation is made up, the updating of the incidence data of the non-relational database can be completed at low cost, and errors are not easy to occur; the pre-established configuration file is configured by the incidence relation between data, is simple and clear, is easy to expand, and can be used for other work related to the incidence relation, such as off-line data verification and the like through simple code development; when the association relation needs to be changed, the code does not need to be modified, and only the configuration file needs to be modified, so that the development time is saved; the technical scheme of the embodiment of the invention is simple and easy to use, and has universality.
Drawings
FIG. 1 is a schematic illustration of a technical concept of an embodiment of the present invention;
FIG. 2 is a flowchart illustrating a method for updating non-relational database-related data according to a first embodiment of the present invention;
FIG. 3 is a flowchart illustrating steps of a method for updating non-relational database related data according to a second embodiment of the present invention;
FIG. 4 is a block diagram illustrating a system for updating non-relational database-related data according to a third embodiment of the present invention;
fig. 5 is a block diagram of a system for updating non-relational database related data according to a fourth embodiment of the present invention.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in further detail below.
Referring to fig. 1, one of the technical concepts of the embodiments of the present invention is proposed, and for an update value of an update attribute of a target object (source object) in a non-relational database, corresponding attributes in the target object and an associated object associated with the target object in the non-relational database need to be updated, that is, cascade update is triggered; therefore, a preconfigured XML (Extensible Markup Language) configuration file for the target Object is found, the XML configuration file includes each associated attribute of each associated Object of the target Object, and an OGNL (Object-Graph Navigation Language, an expression Language, which can access other objects associated with the Object and can access any attribute of the Object) expression describes the assignment manner of each associated attribute; therefore, after the configuration file is analyzed and the triggering cascade update is confirmed, the triggering correlation attribute of each triggering correlation object in the XML configuration file is confirmed; obtaining the assignment of the trigger associated attributes of each trigger associated object by sequentially processing the corresponding OGNL expressions; and updating the non-relational database according to the updated value of the updated attribute of the target object and the assignment of the trigger associated attribute of each trigger associated object (target relational object).
It should be understood that the non-relational database is at least divided into a key-value pair database, a column storage database, a document database, a graph database, and the like, and the technical solution of the embodiment of the present invention can be adopted as long as there is a correlation between stored objects and a user needs to explicitly maintain the correlation. In addition, the updating of the database in the embodiment of the present invention includes, but is not limited to, operations of adding, deleting, modifying, updating, and the like.
The first embodiment is as follows:
referring to fig. 2, an embodiment of the present invention provides a method for updating non-relational database related data, which may include steps 201 and 205:
step 201: receiving update information of a non-relational database; the update information includes an update value of an update attribute of a target object corresponding to the update information.
In the embodiment of the invention, the updating information of the non-relational database is received; the update information includes an update value of an update attribute of a target object corresponding to the update information. It can be understood that there may be one or more received update messages of the non-relational database, and the embodiment of the present invention is not limited to this.
For example, a key-pair type non-relational database referring to a record scheduling shown in table 1, or a column-storage type non-relational database referring to a record scheduling shown in table 2, includes at least the teacher object, which includes at least two attributes of name and coursername; and because teacher A (teacher A) is ill, course 1 of its professor pauses, change to teacher B professor course 2, and course time place does not change, then there are two update messages: the update attribute name update value of the target object teacher is B and the update attribute coursername update value of the target object teacher is 2.
Figure BDA0001292404850000071
TABLE 1
Figure BDA0001292404850000072
TABLE 2
Step 202: loading a pre-established configuration file corresponding to the target object; the configuration file comprises each associated attribute of each associated object of the target object and the assignment mode of each associated attribute.
In the embodiment of the invention, a pre-established configuration file corresponding to the target object is loaded; the configuration file comprises each associated attribute of each associated object of the target object and the assignment mode of each associated attribute.
It can be known that, in the embodiment of the present invention, a corresponding configuration file is established for each object in a non-relational database, where the configuration file includes each associated attribute of each associated object of the target object and an assignment manner of each associated attribute, and the configuration file may exist in any form, such as an XML configuration file; or in the form of a mapping table, such as a mapping relationship between each attribute of the target object and a corresponding associated attribute of another object associated with each attribute, or a mapping relationship between the corresponding associated attribute and a corresponding assignment manner.
For example, for the non-relational database shown in table 1 or table 2, a configuration file for the object, namely, the tenacher and the student, is established in advance. For an object, the corresponding configuration file at least comprises the mapping relation between the attribute name of the object and the attribute teachers name of the object, because the object and the attribute have an association relation; the assignment relationship between the attribute name of the object teacher and the attribute teacher name of the object student shall also be included, and may be schematically expressed as student. Similarly, there is an association relationship between the teacher.
Step 203: and analyzing the configuration file and judging whether the updating attribute triggers cascade updating.
In the embodiment of the invention, the configuration file is analyzed, and whether the update attribute triggers cascade update is judged. For example, for the non-relational database shown in table 1 or table 2, it is determined whether the update attribute name of the target object teacher triggers cascade update, and whether the associated attribute of the associated object of the attribute exists in the configuration file may be checked by analyzing the corresponding configuration file and traversing all the attributes. It can be understood that, through parsing, the update attribute name of the target object teacher triggers the cascade update, and the update attribute coursername of the target object teacher also triggers the cascade update.
Traversing the configuration file, and judging whether a trigger associated attribute of a trigger associated object associated with the update attribute exists or not; and if the trigger associated attribute of the trigger associated object associated with the update attribute exists, triggering the cascade update by the update attribute.
If the update attribute triggers a cascade update, go to step 204; if the update attribute does not trigger the cascade update, that is, there is no other related object in the non-relational data to be updated, only the target object needs to be updated.
Step 204: and if the update attribute triggers cascade update, determining the assignment of each trigger associated attribute according to the assignment mode of the trigger associated attribute of each trigger associated object and the update value.
In the embodiment of the present invention, if the update attribute triggers the cascade update, the assignment of each trigger associated attribute is determined according to the assignment mode of the trigger associated attribute of each trigger associated object and the update value. In an implementation manner of the embodiment of the present invention, referring to the non-relational database shown in table 1 or table 2, if the update attribute name of the tenacher of the target object triggers the cascade update, determining that the update value of the trigger associated attribute name of the trigger associated object is B according to the assignment mode of the trigger associated attribute tenacher name of the trigger associated object, namely tenacher name, and the update value B of the tenacher name; the update value of the trigger association attribute student of the trigger association object of the teacher.
Step 205: and updating the non-relational database according to the updated value of the updated attribute of the target object and the assignment of the trigger associated attribute of each trigger associated object.
In the embodiment of the present invention, the non-relational database is updated according to the update value of the update attribute of the target object and the assignment of the trigger associated attribute of each trigger associated object.
For example, for a non-relational database, an update attribute teacher.name update value B of a target object is already known, and triggers an update attribute student.teacher name update value B of an associated object; coursername update value 2, which triggers the trigger association attribute student name update value 2 of the associated object. The non-relational database can be updated by acquiring all attribute information of the object teacher and the object student, updating the updated values in all the attribute information, and writing all the attribute information of the updated object teacher and the updated object student into the non-relational database.
For a non-relational database of a non-key-value pair type, such as a column storage type database like table 2, only the update attribute of the target object, such as the target object, and the trigger association attribute of the trigger association object, such as the trigger association object, may be updated, and no other attribute needs to be updated.
In the embodiment of the invention, aiming at the updated value of the updated attribute of a target object in a non-relational database, loading a pre-established configuration file aiming at the target object, determining the assignment of the triggered associated attribute of the triggered associated object triggering cascade update by analyzing the associated relationship between the target object attribute and the associated object attribute in the configuration file, and then updating the non-relational database; the weakness of the non-relational database in the aspect of the incidence relation is made up, the updating of the incidence data of the non-relational database can be completed at low cost, and errors are not easy to occur; the pre-established configuration file is configured by the incidence relation between data, is simple and clear, is easy to expand, and can be used for other work related to the incidence relation, such as off-line data verification and the like through simple code development; when the association relation needs to be changed, the code does not need to be modified, and only the configuration file needs to be modified, so that the development time is saved; the technical scheme of the embodiment of the invention is simple and easy to use, and has universality.
Example two:
in the embodiment of the invention, an XML configuration file for each object is established in advance aiming at the objects in the non-relational database, and the assignment mode of each associated attribute is described through a preset OGNL expression.
Setting the association relationship between the objects in a self-defined XML file mode, and declaring the specific details of the association relationship in a configuration file: for example, the target object may trigger the target object attribute of the association relationship, the corresponding association object, and the association attribute assignment method of the association object, and the format is defined as follows:
Figure BDA0001292404850000101
the above XML file is explained as follows:
1) the entity tag: a declaration tag of an object type, the type attribute specifying the object type;
2) cascade label: the association relationship label, one cascade declares one association relationship, and one object may have multiple association relationships, so that one entity may contain multiple cascades. If the object A has a relationship with the attribute y of the object B through the attribute x, and meanwhile, the object A also has a relationship with the attribute z of the object C through the attribute a, the entry A comprises two cascades which respectively correspond to the relationship of A.x < -B.y and A.a < -C.z;
3) src-field tag: declaring an attribute which can trigger the association relationship, wherein the attribute belongs to an object, marking the type of the attribute by using complex, the attribute can be a simple type or a compound type, and if the attribute is the compound type, marking the complex as true; the type indicates the object type (class in object-oriented language) of the attribute, and the object can be generated according to the object type in a reflection mode; the value of src-field is the name of the attribute in the object;
4) target label: the type of the associated object is specified by the declaration tag of the type of the associated object, and the id indicates how to assign a value to the id of the associated object;
5) complete-value/single-value tag: the composite type/simple type data tag is characterized in that the composite type is composed of simple types, the name attribute designates the attribute name in the associated object, and the tag value is a designated attribute value; the type attribute designates the object type of the attribute, and an object is generated in a reflection mode; the from-db attribute is used to specify: if the tag value cannot be obtained from the object written this time, whether the tag value can be obtained from the object existing in the database or not is determined.
In the XML file, the attribute name, value, and the like are character strings conforming to the OGNL syntax, as follows:
<single-value name=”teacherInfo.name”>metadata.name</single>
the OGNL is an expression language, and can access any attribute of an object, call a method of the object, traverse a structure diagram of the whole object, and realize functions such as attribute type conversion and the like through simple and consistent expression syntax. In the present invention, with OGNL, reading of an attribute value of an object and setting of an attribute value of a target object can be realized as long as a value of an XML tag is written in the syntax of OGNL. That is, the attribute value (attribute assignment or update value) in the non-relational database is converted in the form of a character string, or in the form of a character string in an XML file;
the using method comprises the following steps:
1) storing the target object in the context of the OGNL with a specific key;
2) generating an associated object of the target object in a reflection mode according to the type attribute value of the target label, and storing the associated object into the OGNL context in a specific key mode;
3) and sequentially processing a complex-value/single-value tag, substituting a tag value (a character string expressed by OGNL syntax) into the OGNL expression of the target object key to obtain a value, namely the attribute value of the associated object of the target object, and substituting the value into the OGNL expression of the target associated object key according to the name attribute value (also the character string expressed by OGNL syntax) in the tag to realize the purpose of assigning the attribute value to the associated attribute of the associated object of the target object.
The OGNL expression in the XML configuration file is exemplified as follows: a single-value name "field 1" > field a. Field B represents the value of the simple data type field B in the composite data type field A in the target object; name attribute value field1 represents the attribute named field1 in the associated object of the target object; the whole row configuration means: the value of the property field a. field b of the target object is assigned to the association property field1 of the associated object of the target object.
Referring to fig. 3, an embodiment of the present invention provides a method for updating non-relational database related data, which may include steps 301-307:
step 301: receiving update information of a non-relational database; the update information includes an update value of an update attribute of a target object corresponding to the update information.
Step 302: loading a pre-established configuration file corresponding to the target object; the configuration file comprises each associated attribute of each associated object of the target object and the assignment mode of each associated attribute; the configuration file is an extensible markup language XML configuration file, and the assignment mode of each associated attribute is described through a preset object diagram navigation language OGNL expression.
In an implementation manner of the embodiment of the present invention, the configuration file may be an XML configuration file, and the properties of the object and the attributes of the object associated with the object can be accessed through the OGNL language, and the evaluation manner of each associated attribute is described in the XML configuration file by using an OGNL expression.
Step 303: and analyzing the configuration file and judging whether the updating attribute triggers cascade updating.
If the update attribute triggers a cascade update, go to step 305; if the update attribute does not trigger the cascade update, go to step 304. For example, the configuration file may be analyzed for the update attribute by means of character string filtering; the targeted analysis may be performed by a template for the configuration file, or by other means.
Step 304: and if the updating attribute does not trigger cascade updating, updating the non-relational database according to the updating value of the updating attribute of the target object.
And if the update attribute does not trigger cascade update, updating the non-relational database according to the update value of the update attribute of the target object. It should be noted that, because there are many different types of non-relational databases, the updating manner is different for different types of non-relational databases. For example, when updating a key value database, the object (key value) is used as a unit, that is, when an attribute of an object is to be updated, all the attributes of the object need to be written at the same time.
Step 305: and if the updating attribute triggers the cascade updating, determining the triggering association attribute of each triggering association object in the XML configuration file.
In the embodiment of the present invention, if the update attribute triggers the cascade update, the trigger association attribute of each trigger association object in the XML configuration file is determined. In the following examples, further details are given.
Step 306: and determining the assignment of the trigger associated attribute according to the OGNL expression of the trigger associated attribute of each trigger associated object and the updated value.
In the embodiment of the present invention, the assignment of the trigger associated attribute is determined according to the OGNL expression of the trigger associated attribute of each trigger associated object and the updated value, which can be further described in detail in the following examples.
Step 307: and updating the non-relational database according to the updated value of the updated attribute of the target object and the assignment of the trigger associated attribute of each trigger associated object.
Preferably, the step 307 may include:
inquiring the non-relational database, acquiring and storing the attribute information of the target object and each trigger associated object; updating the stored attribute information of the target object and each trigger associated object according to the updated value of the updated attribute of the target object and the assignment of the trigger associated attribute of each trigger associated object; and performing integral writing operation on the non-relational database by taking the saved attribute information of the target object and the trigger associated objects as a whole.
It should be understood that the step of acquiring and storing the attribute information of the target object and each trigger related object may be performed before updating the target object and each trigger related object; it is also possible to choose to execute before the step 306, so that after the step 306 is executed, that is, after the assignment of the trigger associated attribute is determined, the saved target object and the trigger associated objects can be directly updated.
Preferably, when the non-relational database is a non-key-value pair database, the step 307 may include:
taking the updated value of the updated attribute of the target object and the assignment of the trigger associated attribute of each trigger associated object as a whole, and executing the whole write-in operation on the non-relational database; receiving a response of the non-relational database to the overall write operation; judging whether the integral write-in operation is successfully executed or not according to the response; and if the integral write-in operation is not successfully executed, continuing to execute the integral write-in operation on the non-relational database.
Preferably, the association relationship of each object in the non-relational database is modified or added by modifying the configuration file of the target object or adding the configuration file of the object in the non-relational database. Therefore, the incidence relation of the target object can be conveniently updated, or a configuration file containing the incidence relation can be established for other objects.
The steps 301-307 will be described in further detail with reference to specific examples.
For example, a non-relational database has a Student table and a Teacher table, representing the two objects with Student and Teacher, respectively. The object Student will store some information associated with the Teacher, which will also store the Student's information it teaches, such as the entities defined below:
Figure BDA0001292404850000141
Figure BDA0001292404850000151
trying a case where the teacher's name or the lesson of his professor is modified when the teacher. Because the name of the teacher and the name of the lecture are also stored in the student teachnfo, synchronous modification is needed, and the technical scheme of the embodiment of the invention can be used.
Taking the column store database update as an example, because the column store database can update only the concerned column without updating the whole object, the basic steps are as follows:
1. receiving an update message1, updating the teacher. metadata, modifying the teacher's name and the lesson name of its professor;
2. querying the entity object message _ exists in the non-relational database according to the message1.id, because as in this example, the tandem relationship attribute studentInfo may not be in the message1 modified this time, but the metadata attribute may trigger the tandem relationship, so it is necessary to obtain the tandem information from the studentInfo in the message _ exists; message _ exists is used in step 5;
3. querying a defined XML configuration file according to the type teacher of the target object;
4. checking fields in the update message1 with an XML configuration file to check whether cascade update is triggered, in this example, modification of the attribute, teacher.
5. The configuration file indicates an assignment manner of the cascade relationship, which is, in this example, an assignment manner between the teacher. The id of the student to be modified can be obtained through the teacher. The assignment operation may be accomplished by traversing the configuration items of the XML.
6. If the teacher includes a plurality of student info, then through step 4, a plurality of pieces of updated information about the student's teacherinfo, namely, message2, message3 … … message, are generated and submitted to the database together with the message1 as a whole, and if a failure occurs, that is, a failure can be returned, rewriting is required to ensure consistency of the cascade relationship.
Taking the update of a key-value (key-value) non-relational database as an example, still regarding the above definition entity, since the value in the key-value database stores the whole message, the update needs to first obtain the original message in the database, and after some attributes are updated, the whole message is written back to the database again, and the basic steps are as follows:
1. receiving an update message1, updating the teacher. metadata, modifying the teacher's name and the lesson name of its professor;
2. querying a defined XML configuration file according to the type teacher of the update entity;
3. checking fields in the update message1 with an XML configuration file to check whether cascade update is triggered, in this example, modification of teacher.
4. Querying a database according to the student.id to obtain the stored student original message 2;
5. the configuration file indicates an assignment manner of the cascade relationship, which is, in this example, an assignment manner between the teacher. Through program code, traversing XML configuration items can complete assignment operation. The assignment operation is performed on the original data message2 obtained in step 4, that is, the partial field values in the message2 are updated.
6. If the teacher includes multiple student info, then multiple student update messages, namely message2, message3 … … message N, are generated through step 4, and are written to the database together with message1 as a whole.
For the above assignment method using the OGNL expression, the following is exemplified:
the// OGNL template method is as follows:
OgnlContext context=new OnglContext();
loading configuration files and assigning values; the cascadeObject and originAlObject are the// message2 and the message1 in the specification, and are put into OGNLContext as fixed names so as to be used by the template;
name assignment to student. teacherinfo. name can be achieved through the following Ognl syntax
Ognl.setValue(“cascadeObject.teacherInfo.name”,context,
Ognl.getValue(“orginalObject.metadata.name”));
After all the XML configuration items are executed, the message2 is generated by only fetching the cascadeObject in the OGNLContext.
In the embodiment of the invention, aiming at the updated value of the updated attribute of a target object in a non-relational database, loading a pre-established XML configuration file aiming at the target object, determining the assignment of the trigger associated attribute of the trigger associated object triggering cascade update through an OGNL expression by analyzing the associated relation between the target object attribute and the associated object attribute in the configuration file, and then updating the non-relational database; the weakness of the non-relational database in the aspect of the incidence relation is made up, the updating of the incidence data of the non-relational database can be completed at low cost, and errors are not easy to occur; the pre-established XML configuration file is combined with the OGNL expression, the incidence relation among the data is configured, so that the access mode of the object becomes extremely simple and uniform, the incidence relation is simple and clear, the expansion is easy, and the method can be used for other work related to the incidence relation, such as off-line data verification and the like, through simple code development; when the association relation needs to be changed, the code does not need to be modified, and only the configuration file needs to be modified, so that the development time is saved; the technical scheme of the embodiment of the invention is simple and easy to use, and has universality.
In a preferred embodiment of the present invention, the attribute information of the target object and the trigger-related objects is written into the non-relational database as a whole, which has universality and ensures consistency of related data update.
In a preferred embodiment of the present invention, for a non-key-value-pair non-relational database, only the update attribute of the target object and the trigger associated attribute of each trigger associated object are updated, so that processing load can be reduced, and update efficiency can be improved.
In a preferred mode of the embodiment of the present invention, the configuration file of the target object is modified, or the configuration file of the object in the non-relational database is added, so that the association relationship of the target object can be conveniently updated, or the configuration file containing the association relationship is established for other objects, thereby facilitating the expansion and maintenance of the association relationship.
It should be noted that, for simplicity of description, the method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the illustrated order of acts, as some steps may occur in other orders or concurrently in accordance with the embodiments of the present invention. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred and that no particular act is required to implement the invention.
Example three:
referring to fig. 4, an embodiment of the present invention provides a system for updating non-relational database association data, where the system may include:
an update message receiving module 401, configured to receive update information of a non-relational database; the update information includes an update value of an update attribute of a target object corresponding to the update information;
a configuration file loading module 402, configured to load a configuration file corresponding to the target object, which is established in advance; the configuration file comprises each associated attribute of each associated object of the target object and the assignment mode of each associated attribute;
a configuration file parsing module 403, configured to parse the configuration file and determine whether the update attribute triggers a cascade update;
a cascade update triggering module 404, configured to determine, if the update attribute triggers cascade update, an assignment of each trigger associated attribute according to an assignment manner of the trigger associated attribute of each trigger associated object and the update value;
a first database updating module 405, configured to update the non-relational database according to the updated value of the update attribute of the target object and the assignment of the trigger associated attribute of each trigger associated object.
In the embodiment of the invention, aiming at the updated value of the updated attribute of a target object in a non-relational database, loading a pre-established configuration file aiming at the target object, determining the assignment of the triggered associated attribute of the triggered associated object triggering cascade update by analyzing the associated relationship between the target object attribute and the associated object attribute in the configuration file, and then updating the non-relational database; the weakness of the non-relational database in the aspect of the incidence relation is made up, the updating of the incidence data of the non-relational database can be completed at low cost, and errors are not easy to occur; the pre-established configuration file is configured by the incidence relation between data, is simple and clear, is easy to expand, and can be used for other work related to the incidence relation, such as off-line data verification and the like through simple code development; when the association relation needs to be changed, the code does not need to be modified, and only the configuration file needs to be modified, so that the development time is saved; the technical scheme of the embodiment of the invention is simple and easy to use, and has universality.
Example four:
referring to fig. 5, an embodiment of the present invention provides a system for updating non-relational database association data, where the system may include:
an update message receiving module 401, configured to receive update information of a non-relational database; the update information includes an update value of an update attribute of a target object corresponding to the update information;
a configuration file loading module 402, configured to load a configuration file corresponding to the target object, which is established in advance; the configuration file comprises each associated attribute of each associated object of the target object and the assignment mode of each associated attribute;
the configuration file is an extensible markup language (XML) configuration file, and the assignment mode of each associated attribute is described through a preset object diagram navigation language (OGNL) expression;
a configuration file parsing module 403, configured to parse the configuration file and determine whether the update attribute triggers a cascade update;
a second database updating module 406, configured to update the non-relational database according to an update value of the update attribute of the target object if the update attribute does not trigger cascade update;
an XML trigger validation module 40401, configured to determine a trigger association attribute of each trigger association object in the XML configuration file if the update attribute triggers the cascade update;
an OGNL assignment module 40402, configured to determine, according to the OGNL expression of the trigger associated attribute of each trigger associated object and the updated value, an assignment of the trigger associated attribute;
a first database updating module 405, configured to update the non-relational database according to the updated value of the update attribute of the target object and the assignment of the trigger associated attribute of each trigger associated object.
Preferably, the first database updating module 405 may include:
the object data storage module is used for inquiring the non-relational database, acquiring and storing the attribute information of the target object and each trigger associated object;
the object data updating module is used for updating the stored attribute information of the target object and each trigger associated object according to the updated value of the updated attribute of the target object and the assignment of the trigger associated attribute of each trigger associated object;
and the object data writing module is used for performing integral writing operation on the non-relational database by taking the saved attribute information of the target object and each trigger associated object as a whole.
Preferably, when the non-relational database is a non-key-value-pair database, the first database updating module 405 may include:
the integral writing module is used for taking the updated value of the updated attribute of the target object and the assignment of the trigger associated attribute of each trigger associated object as a whole to execute integral writing operation on the non-relational database;
a response receiving module, configured to receive a response of the non-relational database to the overall write operation;
the write-in judging module is used for judging whether the integral write-in operation is successfully executed or not according to the response;
and the continuous writing module is used for continuously executing the integral writing operation on the non-relational database if the integral writing operation is not executed successfully.
Preferably, the system may further include:
and the configuration file updating module is used for modifying or adding the association relation of each object in the non-relational database by modifying the configuration file of the target object or adding the configuration file of the object in the non-relational database.
In the embodiment of the invention, aiming at the updated value of the updated attribute of a target object in a non-relational database, loading a pre-established XML configuration file aiming at the target object, determining the assignment of the trigger associated attribute of the trigger associated object triggering cascade update through an OGNL expression by analyzing the associated relation between the target object attribute and the associated object attribute in the configuration file, and then updating the non-relational database; the weakness of the non-relational database in the aspect of the incidence relation is made up, the updating of the incidence data of the non-relational database can be completed at low cost, and errors are not easy to occur; the pre-established XML configuration file is combined with the OGNL expression, the incidence relation among the data is configured, so that the access mode of the object becomes extremely simple and uniform, the incidence relation is simple and clear, the expansion is easy, and the method can be used for other work related to the incidence relation, such as off-line data verification and the like, through simple code development; when the association relation needs to be changed, the code does not need to be modified, and only the configuration file needs to be modified, so that the development time is saved; the technical scheme of the embodiment of the invention is simple and easy to use, and has universality.
In a preferred embodiment of the present invention, the attribute information of the target object and the trigger-related objects is written into the non-relational database as a whole, which has universality and ensures consistency of related data update.
In a preferred embodiment of the present invention, for a non-key-value-pair non-relational database, only the update attribute of the target object and the trigger associated attribute of each trigger associated object are updated, so that processing load can be reduced, and update efficiency can be improved.
In a preferred mode of the embodiment of the present invention, the configuration file of the target object is modified, or the configuration file of the object in the non-relational database is added, so that the association relationship of the target object can be conveniently updated, or the configuration file containing the association relationship is established for other objects, thereby facilitating the expansion and maintenance of the association relationship.
For the device embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, refer to the partial description of the method embodiment.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, apparatus, or computer program product. Accordingly, embodiments of the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
Embodiments of the present invention are described with reference to flowchart illustrations and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing terminal to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing terminal to cause a series of operational steps to be performed on the computer or other programmable terminal to produce a computer implemented process such that the instructions which execute on the computer or other programmable terminal provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications of these embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the embodiments of the invention.
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 terminal 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 terminal. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or terminal that comprises the element.
The method and the system for updating the non-relational database associated data provided by the invention are described in detail, a specific example is applied in the text to explain the principle and the implementation mode of the invention, and the description of the embodiment is only used for helping to understand the method and the core idea of the invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, 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 for updating non-relational database association data, the method comprising:
receiving update information of a non-relational database; the update information includes an update value of an update attribute of a target object corresponding to the update information;
loading a pre-established configuration file corresponding to the target object; the configuration file comprises each associated attribute of each associated object of the target object and the assignment mode of each associated attribute;
analyzing the configuration file and judging whether the updating attribute triggers cascade updating or not;
if the update attribute triggers cascade update, determining the assignment of each trigger associated attribute according to the assignment mode of the trigger associated attribute of each trigger associated object and the update value;
and updating the non-relational database according to the updated value of the updated attribute of the target object and the assignment of the trigger associated attribute of each trigger associated object.
2. The method according to claim 1, wherein the configuration file is an extensible markup language (XML) configuration file, and the assignment mode of each associated attribute is described through a preset Object Graph Navigation Language (OGNL) expression;
if the update attribute triggers the cascade update, the step of determining the assignment of each trigger associated attribute according to the assignment mode of the trigger associated attribute of each trigger associated object and the update value comprises:
if the updating attribute triggers cascade updating, determining the triggering association attribute of each triggering association object in the XML configuration file;
and determining the assignment of the trigger associated attribute according to the OGNL expression of the trigger associated attribute of each trigger associated object and the updated value.
3. The method of claim 1, wherein the step of updating the non-relational database based on the updated values of the update attributes of the target object and the assignments of the trigger association attributes of each of the trigger association objects comprises:
inquiring the non-relational database, acquiring and storing the attribute information of the target object and each trigger associated object;
updating the stored attribute information of the target object and each trigger associated object according to the updated value of the updated attribute of the target object and the assignment of the trigger associated attribute of each trigger associated object;
and performing integral writing operation on the non-relational database by taking the saved attribute information of the target object and the trigger associated objects as a whole.
4. The method of claim 1, wherein the step of updating the non-relational database according to the updated value of the update attribute of the target object and the assigned value of the trigger associated attribute of each trigger associated object when the non-relational database is a non-key-value pair database comprises:
taking the updated value of the updated attribute of the target object and the assignment of the trigger associated attribute of each trigger associated object as a whole, and executing the whole write-in operation on the non-relational database;
receiving a response of the non-relational database to the overall write operation;
judging whether the integral write-in operation is successfully executed or not according to the response;
and if the integral write-in operation is not successfully executed, continuing to execute the integral write-in operation on the non-relational database.
5. The method of claim 1, further comprising:
and if the updating attribute does not trigger cascade updating, updating the non-relational database according to the updating value of the updating attribute of the target object.
6. The method of claim 1, further comprising:
and modifying or adding the association relation of each object in the non-relational database by modifying the configuration file of the target object or adding the configuration file of the object in the non-relational database.
7. A system for updating non-relational database-related data, the system comprising:
the update message receiving module is used for receiving the update information of the non-relational database; the update information includes an update value of an update attribute of a target object corresponding to the update information;
the configuration file loading module is used for loading a pre-established configuration file corresponding to the target object; the configuration file comprises each associated attribute of each associated object of the target object and the assignment mode of each associated attribute;
the configuration file analysis module is used for analyzing the configuration file and judging whether the update attribute triggers cascade update;
a cascade update triggering module, configured to determine, if the update attribute triggers cascade update, an assignment of each trigger associated attribute according to an assignment manner of the trigger associated attribute of each trigger associated object and the update value;
and the first database updating module is used for updating the non-relational database according to the updated value of the updated attribute of the target object and the assignment of the trigger associated attribute of each trigger associated object.
8. The system according to claim 7, wherein the configuration file is an extensible markup language XML configuration file, and the assignment manner of each association attribute is described through a preset object graph navigation language OGNL expression;
the cascade update triggering module comprises:
the XML trigger confirmation module is used for determining the trigger correlation attributes of all trigger correlation objects in the XML configuration file if the update attributes trigger cascade update;
and the OGNL assignment module is used for determining assignment of the trigger associated attribute according to the OGNL expression of the trigger associated attribute of each trigger associated object and the updated value.
9. The system of claim 7, wherein the first database update module comprises:
the object data storage module is used for inquiring the non-relational database, acquiring and storing the attribute information of the target object and each trigger associated object;
the object data updating module is used for updating the stored attribute information of the target object and each trigger associated object according to the updated value of the updated attribute of the target object and the assignment of the trigger associated attribute of each trigger associated object;
and the object data writing module is used for performing integral writing operation on the non-relational database by taking the saved attribute information of the target object and each trigger associated object as a whole.
10. The system of claim 7, wherein the first database update module comprises, when the non-relational database is a non-key-value pair database:
the integral writing module is used for taking the updated value of the updated attribute of the target object and the assignment of the trigger associated attribute of each trigger associated object as a whole to execute integral writing operation on the non-relational database;
a response receiving module, configured to receive a response of the non-relational database to the overall write operation;
the write-in judging module is used for judging whether the integral write-in operation is successfully executed or not according to the response;
and the continuous writing module is used for continuously executing the integral writing operation on the non-relational database if the integral writing operation is not executed successfully.
CN201710330586.1A 2017-05-11 2017-05-11 Method and system for updating non-relational database associated data Active CN107315764B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710330586.1A CN107315764B (en) 2017-05-11 2017-05-11 Method and system for updating non-relational database associated data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710330586.1A CN107315764B (en) 2017-05-11 2017-05-11 Method and system for updating non-relational database associated data

Publications (2)

Publication Number Publication Date
CN107315764A CN107315764A (en) 2017-11-03
CN107315764B true CN107315764B (en) 2020-04-21

Family

ID=60181417

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710330586.1A Active CN107315764B (en) 2017-05-11 2017-05-11 Method and system for updating non-relational database associated data

Country Status (1)

Country Link
CN (1) CN107315764B (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108170815B (en) * 2017-12-29 2022-07-05 中国银联股份有限公司 Data processing method, device and storage medium
CN111949670B (en) * 2019-05-15 2024-05-07 上海汽车集团股份有限公司 Data processing method and device
CN111461933A (en) * 2020-04-13 2020-07-28 向英 Text data processing method, software, storage medium and equipment
CN111488405B (en) * 2020-04-16 2022-02-18 北京字节跳动网络技术有限公司 Information updating method and device
CN112612786A (en) * 2020-11-24 2021-04-06 北京思特奇信息技术股份有限公司 Large-data-volume row-column conversion method and system
CN114327668B (en) * 2021-11-25 2024-06-18 中国电子科技集团公司第十五研究所 Intelligent parameter configuration method and device based on association mining
CN116303458B (en) * 2023-03-17 2023-10-13 北京信源电子信息技术有限公司 Management method for data objects in handle system

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101000619A (en) * 2006-12-25 2007-07-18 华为技术有限公司 Data synchronous method and device based on SQL
CN101344894A (en) * 2008-08-21 2009-01-14 峰峰集团邯郸鼎峰物流有限公司 Method and device for synchronizing data between application systems
CN103473239A (en) * 2012-06-08 2013-12-25 腾讯科技(深圳)有限公司 Method and device for updating data of non relational database
CN104572644A (en) * 2013-10-10 2015-04-29 北京大学 Database updating device and database updating method

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101000619A (en) * 2006-12-25 2007-07-18 华为技术有限公司 Data synchronous method and device based on SQL
CN101344894A (en) * 2008-08-21 2009-01-14 峰峰集团邯郸鼎峰物流有限公司 Method and device for synchronizing data between application systems
CN103473239A (en) * 2012-06-08 2013-12-25 腾讯科技(深圳)有限公司 Method and device for updating data of non relational database
CN104572644A (en) * 2013-10-10 2015-04-29 北京大学 Database updating device and database updating method

Also Published As

Publication number Publication date
CN107315764A (en) 2017-11-03

Similar Documents

Publication Publication Date Title
CN107315764B (en) Method and system for updating non-relational database associated data
US9830341B2 (en) Resource name generation and derivation utilizing attribute space monikers and their associated context
CN111177176B (en) Data detection method, device and storage medium
US8291387B2 (en) Method and system for testing a software application interfacing with multiple external software applications in a simulated test environment
CN105808437B (en) Automatic test method and system based on test case data sheet
CN106951231B (en) Computer software development method and device
US11334549B2 (en) Semantic, single-column identifiers for data entries
US10296505B2 (en) Framework for joining datasets
US10157361B2 (en) High performance map editor for business analysts
US9110935B2 (en) Generate in-memory views from universe schema
US9483508B1 (en) Omega names: name generation and derivation
CN108540351B (en) Automatic testing method for distributed big data service
US20220398186A1 (en) Lineage-driven source code generation for building, testing, deploying, and maintaining data marts and data pipelines
US20080250052A1 (en) Repopulating a database with document content
US9208195B2 (en) Retrieving information from a relational database using user defined facets in a faceted query
CN112799718A (en) Enumerated document generation method and device, electronic equipment and storage medium
US10776351B2 (en) Automatic core data service view generator
Gómez et al. An approach to the co-creation of models and metamodels in Enterprise Architecture Projects.
US20140130008A1 (en) Generating information models
CN116150236A (en) Data synchronization method and device, electronic equipment and computer readable storage medium
CN112463896B (en) Archive catalogue data processing method, archive catalogue data processing device, computing equipment and storage medium
EP3086244B1 (en) Database system and method of operation thereof
US11176022B2 (en) Health diagnostics and analytics for object repositories
CN109739835B (en) Data version preservation method and device
CN115455035B (en) Data query model construction method and computer-readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant