CN103678396B - A kind of data back up method and device based on data model - Google Patents

A kind of data back up method and device based on data model Download PDF

Info

Publication number
CN103678396B
CN103678396B CN201210353330.XA CN201210353330A CN103678396B CN 103678396 B CN103678396 B CN 103678396B CN 201210353330 A CN201210353330 A CN 201210353330A CN 103678396 B CN103678396 B CN 103678396B
Authority
CN
China
Prior art keywords
data
current
data model
sql
model
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
CN201210353330.XA
Other languages
Chinese (zh)
Other versions
CN103678396A (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.)
Advanced New Technologies Co Ltd
Original Assignee
Alibaba Group Holding 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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201210353330.XA priority Critical patent/CN103678396B/en
Publication of CN103678396A publication Critical patent/CN103678396A/en
Application granted granted Critical
Publication of CN103678396B publication Critical patent/CN103678396B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1448Management of the data involved in backup or backup restore
    • 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/21Design, administration or maintenance of databases
    • G06F16/211Schema design and management
    • G06F16/212Schema design and management with details for data modelling support

Abstract

This application provides a kind of data back up method and device based on data model, methods described includes:According to the mark and corresponding current data model of data creation data model to be backed up in current database;Receive the mark of the current data model;According to the corresponding current data model of the identification (RNC-ID) analytic of the current data model, to obtain the current structure query language SQL of the current data model;The current SQL is triggered to be performed in the current database;The implementing result of the current SQL as backup data file corresponding with the data to be backed up will be performed.Using data back up method disclosed in the embodiment of the present application and device, the inaccurate and incomplete problem of data to be backed up present in the data backup procedure of prior art is can solve the problem that, it is ensured that the accuracy and integrality of data.

Description

A kind of data back up method and device based on data model
Technical field
The application is related to database field, more particularly to a kind of data back up method and device based on data model.
Background technology
Database (Database) is the warehouse that data are organized, store and managed according to data structure, and database has very Polytype, from the form of the simplest various data that are stored with to the large database system that can carry out mass data storage System, is all widely used in all fields.Development with data bank service and the system complexity using database Raising, the backup of database is just increasingly common.In complication system, in order to system maintainability and efficiency, often The data for belonging to an entity (such as user profile, user's order, subscriber's account, users' personal allocation) are respectively stored in In the different tables of database.Data in these tables corresponding to independent community are known as data model.
In currently available technology, the backup of data is mainly by DBA (DBA) related data in database Data in the table of storehouse are derived, and are then all imported into another database again.Specifically, current database common at present Data backup and the mode of another database is subsequently imported into, the complex situations according to application scenarios are divided into the following two kinds:The A kind of scene for being to be done for data complicated conversion process, now by data guide to be backed up from current database Go out into SQL (Structured Query Language, SQL) file, then performed in target database table SQL is importing the data of backup;Another kind is the scene for needing to do data complicated conversion, now first will from current database Data export to SQL files, are changed on data service platform, after obtaining new SQL files, then by new SQL texts Part performs to import the data of backup in importeding into target database.
But inventor has found in research process, this traditional backup and the follow-up process for importing can run into various asking Topic:The scheme of above two DB Backup, can all cause that data to be backed up are easily misused and distort, because in backup And data conversion may be carried out during follow-up importing, and if the operating method or third party's group that are provided with database Part realizes there is a problem of data maloperation unavoidably, causes the corrupt data of backup;Also, data backup operation is very complicated, The mass data storehouse table that generally deposited to data to be backed up does inquiry operation respectively, and also needs to operating personnel according to number According to the definition of model, different query SQLs are write, this process is not only complicated, and many data or a small number of evidences easily occur Situation, influence the correctness of data to be backed up;Further, the process of data conversion of the prior art is also relatively more multiple It is miscellaneous, and if data are carried out with the operation of complexity, some correlation logics inside data model are especially related to, database Do not process, it is necessary to carried out by third-party data processing platform (DPP), such words data backup and subsequently imported Journey has not only involved multiple operation sides, it is easier to introduce the inaccurate and imperfect of data.
In a word, need at present those skilled in the art urgently solve a technical problem be exactly:How to innovate A kind of data back up method based on data model is proposed, it is to be backed up present in the data backup procedure of prior art to solve The inaccurate and incomplete problem of data.
The content of the invention
Technical problems to be solved in this application are to provide a kind of data back up method based on data model, are used to solve The inaccurate and incomplete problem of data to be backed up present in the data backup procedure of prior art.
Present invention also provides a kind of data backup device based on data model, it is used to ensure the above method in practice Realization and application.
In order to solve the above problems, this application discloses a kind of data back up method based on data model, including:
According to the mark and corresponding current data model of data creation data model to be backed up in current database;Should Method includes:
Receive the mark of the current data model;
According to the corresponding current data model of the identification (RNC-ID) analytic of the current data model, to obtain the current data mould The current structure query language SQL of type;
The current SQL is triggered to be performed in the current database;
The implementing result of the current SQL as backup data file corresponding with the data to be backed up will be performed.
Optionally, the mark according to data creation data model to be backed up in current database and corresponding current Data model, specifically includes:
Receive the keyword of the data to be backed up of user input;
The all associated data tables being associated with the keyword are searched in the current database;
The associated data table is judged with the presence or absence of outer table reference, if it is, appearance is directed into initial data model In;
The associated data table is directed into the initial data model, to set up the current data model.
Optionally, the corresponding current data model of the identification (RNC-ID) analytic according to the current data model, specifically includes:
Corresponding current data model is obtained according to the mark of the current data model;
Judge whether the current data model quotes other data models, if it is, obtaining described other data moulds All associated data tables in type and current data model are used as target matrix;If it is not, then obtaining the current data mould All associated data tables in type are used as target matrix;
The target matrix is generated into a SQL corresponding with the target matrix;
Judge whether the target matrix quotes appearance, if it is, the appearance is generated corresponding with the appearance The 2nd SQL;
By the 2nd SQL, or a SQL and the 2nd SQL is used as the current SQL of the current data model.
Optionally, the implementing result that will perform the current SQL is used as number corresponding with the data to be backed up After according to backup file, also include:
The data in the backup data file are entered with row format conversion according to the different business scenario of current application.
Optionally, the implementing result that will perform the current SQL is used as number corresponding with the data to be backed up After according to backup file, also include:
The backup data file is directed into the target database according to the data form of target database.
Optionally, it is described that the backup data file is directed into the number of targets according to the data form of target database According to storehouse, specially:
The backup data file is directed into the mesh according to the data form of target database in same affairs Mark database.
This application discloses a kind of data backup device based on data model, including:
Creation module, for the mark according to data creation data model to be backed up in current database and corresponding works as Preceding data model;
Receiver module, the mark for receiving the current data model;
Parsing module, for the corresponding current data model of identification (RNC-ID) analytic according to the current data model, to obtain The current structure query language SQL of the current data model;
SQL modules are performed, is performed in the current database for triggering the current SQL;
Backup module, for the implementing result of the current SQL will to be performed as corresponding with the data to be backed up Backup data file.
Optionally, the creation module is specifically included:
Receiving submodule, the keyword of the data to be backed up for receiving user input;
Submodule is searched, for searching all associated datas being associated with the keyword in the current database Table;
First judging submodule, for judging that the associated data table whether there is outer table reference;
First imports submodule, for being in the case of being, appearance to be directed into just in the result of the judging submodule In beginning data model;
Second imports submodule, for the associated data table to be directed into the initial data model, to set up State current data model.
Optionally, the parsing module is specifically included:
First acquisition submodule, corresponding current data model is obtained for the mark according to the current data model;
Second judging submodule, for judging whether the current data model quotes other data models;
Second acquisition submodule, for the result of second judging submodule in the case of being, obtain it is described its All associated data tables in his data model and current data model are used as target matrix;
3rd acquisition submodule, in the case of being in the result of second judging submodule, obtains described current All associated data tables in data model are used as target matrix;
First generation submodule, for the target matrix to be generated into a SQL corresponding with the target matrix;
3rd judging submodule, for judging whether the target matrix quotes appearance;
Second generation submodule, for being in the case of being, by the appearance in the result of the 3rd judging submodule Generation twoth SQL corresponding with the appearance;
Determination sub-module, for by the 2nd SQL, or a SQL and the 2nd SQL is used as the current data The current SQL of model.
Optionally, also include:
Format converting module, for the different business scenario according to current application to the number in the backup data file Changed according to row format is entered.
Optionally, also include:
Import modul, for the backup data file to be directed into the target according to the data form of target database Database.
Optionally, the import modul specifically for:By the backup data file according to target in same affairs The data form of database is directed into the target database.
Compared with prior art, the application includes advantages below:
In the embodiment of the present application, because the multiple tables being related to for data to be backed up only create a data mould Type, also, subsequently parse the process of the data model and all carried out according to unique mark of the data model, so will not cause There is mistake in data backup procedure, therefore ensures that the accurate parsing of data model in data backup procedure, also just improves The correctness and integrality of data in data backup procedure.Further, moreover it is possible to so that subsequently importing backup data file arrives it When his database, it is also possible to ensure the correctness and integrality of data.Further, the data mould in the embodiment of the present application Type is isolated in data plane to data, therefore the backup of data model and follow-up importing process can be by multithreadings Perform, so as to improve backup and follow-up importing efficiency.
Further, the implementation of the embodiment of the present application writes SQL also without to data to be backed up, as long as providing basis The mark of data model, will generate SQL according to data model, greatly reduce the complexity of data backup operation.
Further, during data are imported, the data guiding flow of same entity is completed in an affairs, Ensure that the integrality of data.Also, data are imported also without SQL is write, as long as can be automatic by backup data file It imported into target database.
Certainly, any product for implementing the application it is not absolutely required to while reaching all the above advantage.
Brief description of the drawings
In order to illustrate more clearly of the technical scheme in the embodiment of the present application, below will be to make needed for embodiment description Accompanying drawing is briefly described, it should be apparent that, drawings in the following description are only some embodiments of the present application, for For those of ordinary skill in the art, without having to pay creative labor, it can also be obtained according to these accompanying drawings His accompanying drawing.
Fig. 1 is a kind of flow chart of data back up method embodiment 1 based on data model of the application;
Fig. 2 is the flow chart of step 101 in the application embodiment of the method 1;
Fig. 3 is the flow chart of step 103 in the application embodiment of the method 1;
Fig. 4 is a kind of flow chart of data back up method embodiment 2 based on data model of the application;
Fig. 5 is a kind of structured flowchart of data backup device embodiment 1 based on data model of the application;
Fig. 6 is the structured flowchart of creation module 501 in the application device embodiment 1;
Fig. 7 is the structured flowchart of parsing module 503 in the application device embodiment 1;
Fig. 8 is a kind of structured flowchart of data backup device embodiment 2 based on data model of the application.
Specific embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present application, the technical scheme in the embodiment of the present application is carried out clear, complete Site preparation is described, it is clear that described embodiment is only some embodiments of the present application, rather than whole embodiments.It is based on Embodiment in the application, it is every other that those of ordinary skill in the art are obtained under the premise of creative work is not made Embodiment, belongs to the scope of the application protection.
The application is mainly used in software or the general computing device environment of internet development or configuration.For example:It is individual People's computer, server computer multi-processor device, the DCE including any of the above device or equipment etc..
The application can be described in the general context of computer executable instructions, such as program Module.Usually, program module includes performing particular task or realizes routine, program, object, the group of particular abstract data type Part, data structure etc..The application can also be in a distributed computing environment put into practice, in these DCEs, by Remote processing devices connected by communication network perform task.In a distributed computing environment, program module can be with In local and remote computer-readable storage medium including including storage device.
With reference to Fig. 1, a kind of flow chart of the data back up method embodiment 1 based on data model of the application is shown, can To comprise the following steps:
Step 101:According to the mark and corresponding current number of data creation data model to be backed up in current database According to model.
In the embodiment of the present application, it is necessary to first according to the mark of data creation data model to be backed up in current database And corresponding current data model, specifically, according to the database table structure that business demand and data to be backed up are preserved come Configuration data model, and be its mark of the data model definitions of configuration.It should be noted that in the present embodiment, the number of definition The database table structure preserved according to model and data to be backed up should be corresponding.
With reference to shown in Fig. 2, step 101 may include steps of in the specific implementation:
Step 201:Receive the keyword of the data to be backed up of user input.
Firstly, it is necessary to get data to be backed up in current database, then can first obtain user input treats standby The keyword of the data of part, the keyword of such as user input is " i Phone ", then the data in current data model All can be the number to be backed up in the embodiment of the present application with all data on the Keywords matching according to model ID in table According to.
Step 202:The all associated data tables being associated with the keyword are searched in the current database.
This step be in current database search can with all database tables on Keywords matching, and will matching On tables of data all as associated data table, be data to be backed up.
Step 203:The associated data table is judged with the presence or absence of outer table reference according to data model, if it is, into Step 204, if it is not, then into step 205.
The associated data table that judgement finds if outer table reference, is then needed first according to outer with the presence or absence of outer table reference Table creates data model.Wherein, when there is foreign key reference in database, the table where external key is defined as appearance, if not There is outer table reference, be then directly entered step 205.
Step 204:Appearance is directed into initial data model.
In the present embodiment, the process for creating data model is all to be associated all of associated data table to be formed One data model, rather than in the prior art when being backed up to data, tables of data needs correspondence one independent SQL scripts.
Step 205:The associated data table is directed into the initial data model, to set up the current data mould Type.
Appearance is imported after initial data model, then all associated data tables that will be obtained in step 202 imported into Through being associated with the initial data model of appearance, the current data mould for being associated with all associated data tables and appearance is finally given Type.
It should be noted that during the establishment that step 201~step 205 carries out data model, carrying out database Before the importing of table (including appearance or associated data table), it is also possible to check in data model whether there is identical number According to storehouse table, the data model that can be quoted with it in itself with ergodic data model is iterated.And for quoting the table of external key, also need Check whether the external key appearance corresponding with the external key of reference has existed in data model.Therefore, implement in the application It is first to import quilt when database table is imported in toward data model, it is necessary to first import appearance imports associated data table again in example The table of reference.Meanwhile, in the embodiment of the present application, model ID is arranged on each table, during model analyzing, can be by each ID in table pulls out the ID for being used as whole model.Each ID has a style number (such as USER_ID), and such model is just known Which the ID of road and model interaction is, as long as the data for going to inquire about one by one in database according to this ID.ID is arranged on On each table, also allowing for processing in a model has the situation of multiple ID.
Those skilled in the art are better understood upon the implication of data model in a particular application for convenience, below logarithm Critical field according to model during establishment is introduced, but those skilled in the art know, following critical field also only It is that citing is illustrated, other can realize that the mode of the application falls within the protection domain of the application.
Critical field of the data model when realizing can at least include:" tables " refers to the table in data model, And use " refs " to represent another data model that current data model is quoted.In the embodiment of the present application, for the ease of number According to the maintenance of model, a data model can quote other data models." uniqKeys, sequence " field can be used Uniqueness to realize the table structure in data model is controlled, unique when data model carries out data convert to be backed up parsing It is reduced into a database table;" foreignTable " represents appearance, is when there is foreign key reference in database, where external key Table be defined as " foreignTable ".The mark (ID) of data model is represented using " ids ", in usually whole data model Main several tables all include and for describing the ID that data belong to same data model, it is auxiliary in a data model The table for helping can describe data model additionally by external key, that is, be defined in the adduction relationship of " foreignTable ".
Fig. 1 is then returned to, in a step 102:Receive the mark of the current data model.
After data model has been pre-created, the current data model of establishment can be saved, if used next time Family carries out the backup of the database table of same keyword again, then can thus be saved using the last data model for preserving The process that must create data model every time is saved, has been more beneficial for economizing on resources.Therefore, although step 102 step 101 it Afterwards, but in actual applications, certain execution step 102 after step 101 is not necessarily performed, it is also possible to needing to carry out Step 102 is performed when data backup again.
It is when getting data to be backed up to be backed up in this step, working as data creation to be backed up The mark of preceding data model.
Step 103:According to the corresponding current data model of the identification (RNC-ID) analytic of the current data model, to obtain described working as The current SQL of preceding data model.
After the mark for obtaining current data model, then the corresponding current data model of the mark is parsed, from And current SQL corresponding with current data model is obtained, the process for being parsing eventually generates executable SQL.Wherein, may be used To describe the object set of (Description) class including SQL, for example, SQL, the major key of tables of data of inquiry database (DB) With Sequence, the attribute (whether allowing to be sky) of table etc..
Specifically, with reference to shown in Fig. 3, parsing corresponding current data model can specifically include:
Step 301:Corresponding current data model is obtained according to the mark of the current data model.
The mark for being first depending on current data model obtains the current data model being pre-created.
Step 302:Judge whether the current data model quotes other data models, if it is, into step 303;If it is not, then into step 304.
Judge whether current data model quotes other data models again, if quoting other data models, in parsing During, it is also desirable to other data models are parsed together.
Step 303:The all associated data tables in described other data models and current data model are obtained as target Tables of data, into step 305.
In this step, it is to obtain all associated datas in current data model and its other data model quoted Table, and all associated data tables that will be obtained are used as the target matrix for generating current SQL.
Step 304:The all associated data tables in the current data model are obtained as target matrix.
And if current data model does not quote other data models, then now in direct access current data model All associated data tables just can be with.
Step 305:The target matrix is generated into a SQL corresponding with the target matrix.
In this step, target matrix will be acquired in step 303 or step 304 and generates a corresponding SQL, Specifically, can also be realized according to the process prior art that tables of data generates SQL, do not limited in the embodiment of the present application.
Step 306:Judge whether the target matrix quotes appearance, if it is, into step 307, if it is not, then Into step 308.
After the corresponding SQL of target matrix is obtained, then judge whether target matrix quotes appearance, if mesh Mark data table reference appearance, then the appearance of reference should also generate corresponding SQL.
Step 307:The appearance is generated into twoth SQL corresponding with the appearance.
Step 308:By a SQL, or a SQL and the 2nd SQL is used as the current data model Current SQL.
Finally, in the case where target matrix is in the absence of appearance is quoted, directly by the corresponding SQL of target matrix As the current SQL of current data model, and in the case where target matrix has outer table reference, by target matrix correspondence A SQL and corresponding 2nd SQL of the appearance current SQL that all make all as current data model.
After having introduced parsing data model and having obtained SQL, Fig. 1, step 104 are returned:The current SQL is triggered described Performed in current database.
After the current SQL for obtaining current data model, the current SQL that will be obtained is carried out in being passed to current database Perform, the implementation procedure in the embodiment of the present application also no longer to current SQL is described in detail, and prior art can be realized, by Bar performs SQL.
But from unlike data backup procedure of the prior art, implementation procedure is according to data to the embodiment of the present application The current SQL of model is performed one by one come what is performed one by one rather than by the SQL of database table.Therefore, the application is for number When being backed up according to model, it is possible to according to the attribute of SQL, the data obtained to performing SQL make certain verification and control (such as table Whether be sky, bar number of data etc. if allowing), so as to whether there is dirty data in checking the database table for obtaining.
Step 105:The implementing result for performing the current SQL is standby as data corresponding with the data to be backed up Part file.
Finally, then the implementing result of current SQL as data backup corresponding with the data to be backed up text will be performed Part, wherein, backup data file can be XML (extensible markup language, Extensible Markup Language) file Form.Specifically, after the implementing result for obtaining SQL, adding the attribute of each database table, complete data are just constituted Backup file.
It is understood that in different running environment, can read and write scheme with different XML to realize data model Establishment and parsing.The DOM of such as PHP (English hypertext pre-processes language, Hypertext Preprocessor), C++ languages Xerces-C++ of speech etc., in different running environment, it is possible to use different template contral classes.
In the embodiment of the present application, because the multiple tables being related to for data to be backed up only create a data mould Type, also, subsequently parse the process of the data model and all carried out according to unique mark of the data model, so will not cause There is mistake in data backup procedure, therefore ensures that the accurate parsing of data model in data backup procedure, also just improves The correctness and integrality of data in data backup procedure.Further, moreover it is possible to so that subsequently importing backup data file arrives it When his database, it is also possible to ensure the correctness and integrality of data.Further, the data mould in the embodiment of the present application Type is isolated in data plane to data, therefore the backup of data model and follow-up importing process can be by multithreadings Perform, so as to improve backup and follow-up importing efficiency.
With reference to Fig. 4, a kind of flow chart of the data back up method embodiment 2 based on data model of the application is shown, removed Outside step 101~105, after backup data file is obtained, the present embodiment can also be comprised the following steps:
Step 401:Lattice are carried out to the data in the backup data file according to the different business scenario of current application Formula is changed.
Because according to different business scenarios, the form of backup data file may be with the business scenario being actually needed not Match somebody with somebody, for instance it can be possible that because the upgrading of database is, it is necessary to increase newer field;It could also be possible that data are done with unified form turning Change., the definition of form conversion logic is interface, can be carried according to the application according to the different business scenario of current application The interface description of confession, carries out the definition of the data switching logic of different-format, is to carry out backup data file to be adapted to currently The form conversion of business scenario.Conversion logic therein is the self-defined realization of business scenario according to interface and reality.Then, The execution of form conversion is Templated, and the application provides unified execution template, and configured form conversion logic is carried out Perform one by one.In different applied environments, described template and interface description can be realized by different methods, in such as C Function pointer, C++ in abstract function, interface in Java etc..
Step 402:The backup data file is directed into the target data according to the data form of target database Storehouse.
In the embodiment of the present application, because backup data file can persistence, for example by backup data file with XML or its His document format data is preserved to server, and repeatedly data importing is carried out to a backup data file for follow-up, is Backup data file is directed into after target database, as the data in target database.
It should be noted that should be imported simultaneously in batches for the data of same data model, wherein any one SQL Going wrong will produce the phenomenon of rollback.In the prior art, when being imported one by one according to the SQL of backup data file without Method is realized doing clerical control according to data model, therefore once goes wrong in data importing process, must just pass through Strict rollback mode is solved, and can not simply be re-executed, and this will greatly increase the risk of data importing process And complexity.
It is understood that when the application is actually implemented, if data conversion need not be carried out, can be directly in step Step 402 is performed after rapid 105, is that step 402 must could be necessarily performed after step 401.
And this embodiment of the present application perform step 402 when, can be in same affairs by the backup data file Data form according to target database is directed into the target database, this ensures that the integrality of data and correct Property, it is to avoid there is the situation that a data division for data model is imported and produces dirty data.
In addition, from the point of view of whole importing process, the data of each entity are relatively independent (because in an affairs), And there are various expansible customized patterns to carry out the problem of resolving data conflicts, so if there are some not in importing process It is anticipated that problem (such as database corruption, data form are incompatible), as long as being re-executed after doing certain amendment.
The present embodiment can not only ensure the correctness and integrality of data backup, additionally it is possible to follow-up to data backup text When part is imported, it is also possible to avoid the appearance of dirty data, it is ensured that import the integrality and correctness of the data of database, also carry The performance of database high.
For foregoing each method embodiment, in order to be briefly described, therefore it is all expressed as a series of combination of actions, but It is that those skilled in the art should know, the application is not limited by described sequence of movement, because according to the application, certain A little steps can sequentially or simultaneously be carried out using other.Secondly, those skilled in the art should also know, be retouched in specification The embodiment stated belongs to preferred embodiment, necessary to involved action and module not necessarily the application.
The method that the data back up method embodiment 1 based on data model a kind of with above-mentioned the application is provided is corresponding, Referring to Fig. 5, present invention also provides a kind of data backup device embodiment 1 based on data model, in the present embodiment, the dress Putting to include:
Creation module 501, for mark and correspondence according to data creation data model to be backed up in current database Current data model.
With reference to shown in Fig. 6, the creation module 501 can specifically include:
Receiving submodule 601, the keyword of the data to be backed up for receiving user input;
Search submodule 602, for searched in the current database be associated with the keyword it is relevant Tables of data;
First judging submodule 603, for judging that the associated data table whether there is outer table reference;
First imports submodule 604, for being in the case of being, appearance to be directed into the result of the judging submodule In initial data model;
Second imports submodule 605, for the associated data table to be directed into the initial data model, to set up The current data model.
Receiver module 502, the mark for receiving the current data model.
Parsing module 503, for the corresponding current data model of identification (RNC-ID) analytic according to the current data model, to obtain To the current structure query language SQL of the current data model.
With reference to shown in Fig. 7, the parsing module 503 can specifically include:
First acquisition submodule 701, corresponding current data mould is obtained for the mark according to the current data model Type;
Second judging submodule 702, for judging whether the current data model quotes other data models;
Second acquisition submodule 703, for described in the case of being, to obtain in the result of second judging submodule All associated data tables in other data models and current data model are used as target matrix;
3rd acquisition submodule 704, in the case of being no in the result of second judging submodule, obtains described All associated data tables in current data model are used as target matrix;
First generation submodule 705, for the target matrix to be generated into corresponding with the target matrix first SQL;
3rd judging submodule 706, for judging whether the target matrix quotes appearance;
Second generation submodule 707, in the result of the 3rd judging submodule in the case of being, will it is described outward Table generates twoth SQL corresponding with the appearance;
Determination sub-module 708, for by the 2nd SQL, or a SQL and the 2nd SQL is used as described current The current SQL of data model.
SQL modules 504 are performed, is performed in the current database for triggering the current SQL.
Backup module 505, for the implementing result of the current SQL will to be performed as corresponding with the data to be backed up Backup data file.
In the embodiment of the present application, because the multiple tables being related to for data to be backed up only create a data mould Type, also, subsequently parse the process of the data model and all carried out according to unique mark of the data model, so will not cause There is mistake in data backup procedure, therefore ensures that the accurate parsing of data model in data backup procedure, also just improves The correctness and integrality of data in data backup procedure.Further, moreover it is possible to so that subsequently importing backup data file arrives it When his database, it is also possible to ensure the correctness and integrality of data.Further, the data mould in the embodiment of the present application Type is isolated in data plane to data, therefore the backup of data model and follow-up importing process can be by multithreadings Perform, so as to improve backup and follow-up importing efficiency.
The method that the data back up method embodiment 2 based on data model a kind of with above-mentioned the application is provided is corresponding, Referring to Fig. 8, present invention also provides a kind of data backup device embodiment 2 based on data model, in the present embodiment, the dress Putting to include:
Format converting module 801, for the different business scenario according to current application in the backup data file Data enter row format conversion.
Import modul 802, it is described for the backup data file to be directed into according to the data form of target database Target database.
The import modul 802 specifically can be used for:By the backup data file according to target in same affairs The data form of database is directed into the target database.
The present embodiment can not only ensure the correctness and integrality of data backup, additionally it is possible to follow-up to data backup text When part is imported, it is also possible to avoid the appearance of dirty data, it is ensured that import the integrality and correctness of the data of database, also carry The performance of database high.
It should be noted that each embodiment in this specification is described by the way of progressive, each embodiment weight Point explanation is all difference with other embodiment, between each embodiment identical similar part mutually referring to. For device class embodiment, because it is substantially similar to embodiment of the method, so description is fairly simple, related part ginseng See the part explanation of embodiment of the method.
Finally, in addition it is also necessary to explanation, herein, such as first and second or the like relational terms be used merely to by One entity or operation make a distinction with another entity or operation, and not necessarily require or imply these entities or operation Between there is any this actual relation or order.And, term " including ", "comprising" or its any other variant meaning Covering including for nonexcludability, so that process, method, article or equipment including a series of key elements not only include that A little key elements, but also other key elements including being not expressly set out, or also include for this process, method, article or The intrinsic key element of equipment.In the absence of more restrictions, the key element limited by sentence " including ... ", not Also there is other identical element in the process including the key element, method, article or equipment in exclusion.
Detailed Jie has been carried out to a kind of data back up method and device based on data model provided herein above Continue, specific case used herein is set forth to the principle and implementation method of the application, the explanation of above example is only It is to be used to help understand the present processes and its core concept;Simultaneously for those of ordinary skill in the art, according to this Shen Thought please, be will change in specific embodiments and applications, and in sum, this specification content should not be managed Solution is the limitation to the application.

Claims (10)

1. a kind of data back up method based on data model, it is characterised in that according to data to be backed up in current database The mark and corresponding current data model of data model are created, including:Receive the key of the data to be backed up of user input Word;The all associated data tables being associated with the keyword are searched in the current database;Judge the associated data Table whether there is outer table reference, if it is, appearance is directed into initial data model, and the associated data table be imported Into the initial data model, to set up the current data model;If it is not, then the associated data table is directed into institute State in initial data model to set up current data model;The method includes:
Receive the mark of the current data model;
According to the corresponding current data model of the identification (RNC-ID) analytic of the current data model, to obtain the current data model Current structure query language SQL;
The current SQL is triggered to be performed in the current database;
The implementing result of the current SQL as backup data file corresponding with the data to be backed up will be performed.
2. method according to claim 1, it is characterised in that the identification (RNC-ID) analytic pair according to the current data model The current data model answered, specifically includes:
Corresponding current data model is obtained according to the mark of the current data model;
Judge whether the current data model quotes other data models, if it is, obtain described other data models and All associated data tables in current data model are used as target matrix;If it is not, then in obtaining the current data model All associated data tables as target matrix;
The target matrix is generated into a SQL corresponding with the target matrix;
Judge whether the target matrix quotes appearance, if it is, by the generation of the appearance of the target data table reference with Corresponding 2nd SQL of appearance of the target data table reference, and using a SQL and the 2nd SQL as the current number According to the current SQL of model;If it is not, then using a SQL as the current data model current SQL.
3. method according to claim 1, it is characterised in that the implementing result that the current SQL will be performed as After backup data file corresponding with the data to be backed up, also include:
The data in the backup data file are entered with row format conversion according to the different business scenario of current application.
4. method according to claim 1, it is characterised in that the implementing result that the current SQL will be performed as After backup data file corresponding with the data to be backed up, also include:
The backup data file is directed into the target database according to the data form of target database.
5. method according to claim 4, it is characterised in that it is described by the backup data file according to target database Data form be directed into the target database, specially:
The backup data file is directed into the number of targets according to the data form of target database in same affairs According to storehouse.
6. a kind of data backup device based on data model, it is characterised in that the device includes:
Creation module, for mark and corresponding current number according to data creation data model to be backed up in current database According to model;The creation module is specifically included:Receiving submodule, the key of the data to be backed up for receiving user input Word;Submodule is searched, for searching all associated data tables being associated with the keyword in the current database;The One judging submodule, for judging that the associated data table whether there is outer table reference;First imports submodule, for described The result of the first judging submodule in the case of being, appearance to be directed into initial data model, and by the associated data Table is directed into the initial data model, to set up the current data model;Second imports submodule, for described the In the case that the result of one judging submodule is no, the associated data table is directed into the initial data model, to build Found the current data model;
Receiver module, the mark for receiving the current data model;
Parsing module, it is described to obtain for the corresponding current data model of identification (RNC-ID) analytic according to the current data model The current structure query language SQL of current data model;
SQL modules are performed, is performed in the current database for triggering the current SQL;
Backup module, for the implementing result of the current SQL as data corresponding with the data to be backed up will to be performed Backup file.
7. device according to claim 6, it is characterised in that the parsing module is specifically included:
First acquisition submodule, corresponding current data model is obtained for the mark according to the current data model;
Second judging submodule, for judging whether the current data model quotes other data models;
Second acquisition submodule, for being counted in the case of being, to obtain described other in the result of second judging submodule According to all associated data tables in model and current data model as target matrix;
3rd acquisition submodule, in the case of being no in the result of second judging submodule, obtains the current number According to all associated data tables in model as target matrix;
First generation submodule, for the target matrix to be generated into a SQL corresponding with the target matrix;
3rd judging submodule, for judging whether the target matrix quotes appearance;
Second generation submodule, for being in the case of being, by the target data in the result of the 3rd judging submodule The appearance of table reference generates twoth SQL corresponding with the appearance of the target data table reference, and by a SQL and second SQL as the current data model current SQL;
Determination sub-module, in the case of being no in the result of the 3rd judging submodule, using a SQL as institute State the current SQL of current data model.
8. device according to claim 6, it is characterised in that also include:
Data in the backup data file are entered by format converting module for the different business scenario according to current application Row format is changed.
9. device according to claim 6, it is characterised in that also include:
Import modul, for the backup data file to be directed into the target data according to the data form of target database Storehouse.
10. device according to claim 9, it is characterised in that the import modul specifically for:In same affairs The backup data file is directed into the target database according to the data form of target database.
CN201210353330.XA 2012-09-20 2012-09-20 A kind of data back up method and device based on data model Active CN103678396B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201210353330.XA CN103678396B (en) 2012-09-20 2012-09-20 A kind of data back up method and device based on data model

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201210353330.XA CN103678396B (en) 2012-09-20 2012-09-20 A kind of data back up method and device based on data model

Publications (2)

Publication Number Publication Date
CN103678396A CN103678396A (en) 2014-03-26
CN103678396B true CN103678396B (en) 2017-06-13

Family

ID=50315977

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201210353330.XA Active CN103678396B (en) 2012-09-20 2012-09-20 A kind of data back up method and device based on data model

Country Status (1)

Country Link
CN (1) CN103678396B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106055427B (en) * 2016-05-23 2019-07-30 平安科技(深圳)有限公司 Data back up method and device based on SAS
CN106294776A (en) * 2016-08-12 2017-01-04 北京东方车云信息技术有限公司 A kind of data processing method and device
CN106713032B (en) * 2016-12-21 2019-09-17 瑞斯康达科技发展股份有限公司 A kind of method and device for realizing network management service management
CN109257404B (en) * 2017-07-14 2022-04-05 迈普通信技术股份有限公司 Data backup method, device and system
CN111459907B (en) * 2020-03-04 2023-07-18 石化盈科信息技术有限责任公司 Method, system and storage medium for configuring main data through model
CN113204376A (en) * 2021-04-27 2021-08-03 网银在线(北京)科技有限公司 File analysis method and device, computer equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1549128A (en) * 2003-05-15 2004-11-24 深圳市中兴通讯股份有限公司南京分公 Databank back-up method
CN101989305A (en) * 2010-11-09 2011-03-23 福州星网视易信息系统有限公司 Data incremental backup method and system
CN102096669A (en) * 2009-12-14 2011-06-15 深圳速浪数字技术有限公司 Data backup method and data backup device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8635187B2 (en) * 2011-01-07 2014-01-21 Symantec Corporation Method and system of performing incremental SQL server database backups

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1549128A (en) * 2003-05-15 2004-11-24 深圳市中兴通讯股份有限公司南京分公 Databank back-up method
CN102096669A (en) * 2009-12-14 2011-06-15 深圳速浪数字技术有限公司 Data backup method and data backup device
CN101989305A (en) * 2010-11-09 2011-03-23 福州星网视易信息系统有限公司 Data incremental backup method and system

Also Published As

Publication number Publication date
CN103678396A (en) 2014-03-26

Similar Documents

Publication Publication Date Title
CN110908997B (en) Data blood relationship construction method and device, server and readable storage medium
CN103678396B (en) A kind of data back up method and device based on data model
CN106934062A (en) A kind of realization method and system of inquiry elasticsearch
KR20170021227A (en) Ontology mapping method and apparatus
CN105550206B (en) The edition control method and device of structured query sentence
CN106648587A (en) Annotation-based Web application code generation method
US11042467B2 (en) Automated searching and identification of software patches
CN103729463A (en) Method for implementing full-text retrieval based on Lucene and Solr
CN109101607B (en) Method, apparatus and storage medium for searching blockchain data
CN114328574A (en) Data query method and device, electronic equipment and computer-readable storage medium
CN111125064B (en) Method and device for generating database schema definition statement
CN108228762B (en) Method and system for configuring master database universal templates
CN112507089A (en) Intelligent question-answering engine based on knowledge graph and implementation method thereof
CN113297251A (en) Multi-source data retrieval method, device, equipment and storage medium
CN103020311B (en) A kind of processing method of user search word and system
CN113760961A (en) Data query method and device
CN112069267A (en) Data processing method and device
CN115543428A (en) Simulated data generation method and device based on strategy template
CN115390936A (en) Unified verification method, device, equipment and storage medium
CN113868138A (en) Method, system, equipment and storage medium for acquiring test data
CN113392202A (en) Knowledge graph-based question-answering system and method
CN109857390B (en) Annotation transmission method of Git warehouse file annotation system
US11100286B2 (en) Methods and systems for implied graph patterns in property chains
CN109828775B (en) WEB management system and method for multilingual translation text content
CN117331926B (en) Data auditing method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20191217

Address after: P.O. Box 31119, grand exhibition hall, hibiscus street, 802 West Bay Road, Grand Cayman, British Cayman Islands

Patentee after: Innovative advanced technology Co., Ltd

Address before: Cayman Islands Grand Cayman capital building, a four storey No. 847 mailbox

Patentee before: Alibaba Group Holding Co., Ltd.