Summary of the invention
The purpose of this invention is to provide a kind of versions of data control method, in order to solve the inconsistent problem of database caused due to the concurrent Update Table of many people.
For achieving the above object, the solution of the present invention is: a kind of versions of data control method, and step is as follows:
(1) versions of data of setting up based on colored Petri network is controlled model, included versions of data storehouse, storehouse and the operator storehouse of this Petri net, described versions of data storehouse comprises the latest data version repository, the historical data version repository, versions of data storehouse and the pooled data version repository upgraded, and different versions of data storehouses are agree mean by the holder of different colours, described latest data version repository can only be deposited the Tuo Ken of a latest data version, described historical data version repository can be deposited the Tuo Ken of the versions of data of a plurality of renewals, described holder agree deposit in the storehouse institute of Petri net, for according to its dynamic change library representation the state of versions of data,
(2) model of setting up in step (1) is carried out to initialization, make latest data version repository and historical data version repository respectively obtain a Tuo Ken that color is identical, what this holder agree mean is the information of current latest data version, and other versions of data storehouses are empty;
(3), when having the operator to prepare more new data, the trigger source transition, make the operator storehouse obtain a Tuo Ken who means operator message;
(4) as the operator more during new data, trigger and upgrade the operation transition, and information is agree in the holder of agreeing in information and latest data version repository according to the holder in the operator storehouse, the Tuo Ken that produces the versions of data information after an expression is upgraded leaves in the versions of data storehouse of renewal, simultaneously, the holder in the operator storehouse is agree deleted;
(5) agree information according to the versions of data storehouse of upgrading and the holder in the historical data version repository, judge whether to need to merge the operation of removal redundant data version, if necessary, trigger the transition of redundant data versions merging, the versions of data storehouse of renewal and historical data version repository are merged, and leave the Tuo Ken of the expression pooled data version information that produces after merging in the pooled data version repository, if do not need, trigger and copy transition, Tuo Ken in the versions of data storehouse of the renewal that obtains in step (3) is copied in the pooled data version repository, simultaneously, holder in the versions of data storehouse of upgrading is agree deleted,
(6) trigger and submit the renewal transition to, the Tuo Ken in the pooled data version repository is copied as to two, be stored in respectively in described latest data version repository and historical data version repository, simultaneously, the holder in the pooled data version repository is agree deleted;
(7) if more new data of other operators is arranged, continue execution step (3) ~ (6), so circulation, until in described historical data version repository, holder is agree quantity while reaching the maximum quantity that it can deposit, stop the operation of Petri net.
In the process of carrying out in the arbitrary step in (4) ~ (6), if the more different pieces of information in new database of other operators is arranged, when last operator continues to carry out its data manipulation step, other operators start execution step (3) ~ (6), if the more identical data in new database of other operators is arranged, to execute to submit to after upgrading transition last operator and start again to perform step (3) ~ (6).
The information that in described versions of data storehouse, holder agree mean comprises: the content of version number, father version number, modification time, modification and modification people, the holder in described operator storehouse is agree information and is comprised: operator's numbering, operator's name and the content that will upgrade.
Produce the Tuo Ken of two different colours in step (4) after triggering renewal operation transition, the Tuo Ken of one of them color is willing the copying of former holder, deposit in described latest data version repository, the holder of another color is agree for Xin Tuoken, deposits in the versions of data storehouse of renewal.
When the versions of data based on the Petri net is controlled model initialization, the information version of display number meaned is agree in the holder in described versions of data storehouse, and all the other information fields are sky.
The beneficial effect that the present invention reaches: (1) the present invention has built a kind of colored Petri network (CPN) simulated data Version Control process, agree mean the different editions of data with the holder of different colours, in the Data Control process, when the operator being arranged more during new data, the trigger source transition, make the operator storehouse obtain operator's information, then upgrade the operation transition by triggering, produce new versions of data, and submit to and upgrade transition by triggering, the latest data version of formation is left in the latest data version repository, if judgement has redundant data, can trigger redundancy and merge transition, trigger again after redundant data is merged and submit to the renewal transition that data are stored, effectively solved the problem merged in the versions of data renewal process, guaranteed the integrality of data,
(2) asoperator 1 when database is operated, if also new database more of operator 2 is arranged, if operator 2 is different from the data thatoperator 1 revises, continue the trigger source transition, the operator storehouse regains operator 2 information, nowoperator 1 continues to carry out process afterwards, operator 2 is after the data in database are upgraded, what in the latest data version repository, finally deposit is exactly the versions of data that operator's 2 final updatings are crossed, if operator 2 is identical with the data thatoperator 1 will revise, the data that operator 2 will reviseoperator 1 so just can be carried out its data updating process after submitting to, the inconsistent problem of database with regard to having avoided causing due to the concurrent Update Table of many people like this.
Embodiment
Below in conjunction with accompanying drawing, the present invention will be further described in detail.
The colored Petri network ∑ that the present invention sets upcPN=(P, T, F, M, D, C, I, G, K) controls model for building versions of data, and it is defined as follows:
(1) P={p1, p2, p3, p4, p5}, P be storehouse finite set;
(2) T={t1, t2, t3, t4, t5}, T is the finite set of transition;
(3) F=(P * T) ∪ (T * P) is directed arc set in net;
(4) D is color set;
(5) C:P ∪ T → ψ (D), the power set that ψ (D) is color set D;
(6) M:P → DMS, be the sign of net, and the multiset on color set is agree in the holder in sign component Mi (p) the library representation P of institute under sign Mi, and M0 is initial marking;
(7) G: function is escorted in transition, G:T → expression formula;
(8) I is the weight function on F, and I:F → DMS determines the willing variation of transition generation butt;
(9) K is that P goes up to obtain capacity function, and K:P → { 1,2,3...}, if the p of storehouse institute does not define capacity function, gives tacit consent to K (p)=∞.
As Fig. 1, included operator storehouse, storehouse and versions of data storehouse in the present embodiment Petri pessimistic concurrency control, P1 in figure, P3, P4 and P5 are the versions of data storehouse, and different versions of data storehouses agree mean by the holder of different colours, the storehouse in versions of data storehouse in holder to agree color be C (P1)={ c1, c2cn, c1, c2cn∈ D, cithe different information that means version, a tuple by multiparameter forms, and attribute comprises version number, father version number, running time, the content of operation, mode of operation and operator, P1 means the latest data version repository, for depositing up-to-date versions of data, W in figure (p1)=1 mean this storehouse in holder to agree quantity be 1, P4 means historical data version repository, P4the willing information of middle holder is equivalent to set up a Version Control table in database, records the change information of a series of versions of data, is equivalent to a storage of versions storehouse, convenient consulting later.
P2 is the operator storehouse, and for store data operator's information, the storehouse that wherein means the operator storehouse holds in the palm that to agree color be C (P2)={ m1, m2mn, m1, m2mn∈ D, mimean operator message, comprise data manipulation person's numbering, name and the data content that will upgrade.
T1, t2, t3, t4 and t5 are transition, mean the operation of Update Table version repository or operator storehouse status information, t1for the source transition, the operating personnel's of change data information is provided, t2 is for upgrading the operation transition, and the generation color is ciand cjtwo holders agree, cibe willing the copying of former holder, be convenient to the next update operation, i.e. ci=ci, be stored in P1, cjtuo Ken for new color, be stored in P3.T5for copying of versions of data, t3for the merging of redundant data version, for avoiding conflict, t3right of priority higher than t5, the similar t of change color that the holder of generation is willing2, t4to submit to upgrade operation, G (t when submitting to successfully4)=true, by P5in Tuo Ken be copied into 2, one leaves P in1, one leaves P in4for storage, merge relatively simultaneously.
In figure directive camber line library representation and transition between relation.
Each versions of data storehouse and transition t1, t2, t3, t4and t5implication and the operation change procedure as shown in table 1, in table-direction that ID shows arc points to transition by versions of data storehouse or operator storehouse, versions of data storehouse or operator storehouse are the inputs as transition, mean through these transition, versions of data storehouse or operator storehouse lose the Tuo Ken of the color of corresponding transition, the direction of ID explanation arc is pointed to versions of data storehouse or operator storehouse by transition, versions of data storehouse or operator storehouse are the output as transition, mean through these transition, versions of data storehouse or operator storehouse obtain the Tuo Ken of the color of corresponding transition, F1 and F2 respectively mean a directed arc, but transition herein not necessarily trigger.
Table 1
As Fig. 2, after setting up the Petri pessimistic concurrency control, it is carried out to initialization operation, making in P1 and P4 has the Tuo Ken that color is C1, means initial basic version, and in P2, P3 and P5, holder is not willing, owing to being the primary data version, the holder in P1 and P4 is agree information other fields except version number and is sky.
As Fig. 3, when having the operator to be operated the data in database, trigger source transition t1, produce a holder and agree m in the P2 of operator storehouse1, the Petri net starts to move according to update rule.
As Fig. 4, when new data more, trigger and upgrade operation transition t2, produce the Tuo Ken of two colors, one is c1, be willing the copying of former holder, be stored in p1, another is Xin Tuoken c2, be stored in p3, while p2in holder agree m1deleted.
As Fig. 5, if data, in the continuous renewal process, have been stored a plurality of versions of data in P4, at first to, by relatively judging whether to need to merge to remove the redundant data version, if necessary, trigger transition t3, store the Tuo Ken of the versions of data after merging into p5in, and transition t5do not occur.In the present embodiment, p4in there is no unnecessary versions of data, do not need merge to remove the operation of redundant data version, therefore, transition t3transition t does not occur5p occurs3in holder agree c2the simple p that copies to5, now, p1and p4in Tuo Ken remain unchanged.
As Fig. 6, after Data Update, trigger to submit to and upgrade transition t4, by p5in holder agree c2copy as two, submit to respectively p1and p4, now, p1in original holder agree c1by Xin Tuoken c2replace p4in deposit two holders and agree c1and c2.
Triggering transition t3or transition t5carry out in the process that copies or merge of versions of data, if there are other operators to be upgraded database, and what revise is different data, last operator continues to carry out after, in operation, continues triggering t1transition, continued database is carried out and upgraded operation by a rear operator, and trigger successively by above-mentioned steps, like this, can to database, be modified by a plurality of operators simultaneously.If trigger transition t previous operator3or transition t5before, have other operators to carry out and to upgrade operation database, and that modification is different data, p2can wait until that previous operator executes renewal operation transition t2afterwards, then the information that receives other operators upgrade operation.Along with data are constantly revised, p4in holder agree more and more, M (p4) matrix is increasing, it is that a versions of data is upgraded operation that each holder is agree, until p4in holder agree quantity and reach p4maximum storage the time, this Petri net is out of service.If operator's new data is more again arranged, again the Petri net is carried out to initialization.
But, if other operators and last operator modify to data identical in database, after a rear operator will wait until that last operator submits renewal to, could trigger and upgrade operation transition t2, like this, a rear operator is when modifying to identical data, and a upper up-to-date versions of data has stored p into1in, the versions of data that this operator uses is exactly this up-to-date versions of data.
Above embodiment is the non-limiting technical scheme of the present invention in order to explanation only; although with reference to above-described embodiment, the present invention is had been described in detail; those of ordinary skill in the art is to be understood that; any modification that the present invention is carried out or be equal to replacement; and do not break away from the spirit and scope of the present invention, all should be within protection scope of the present invention.