Multilayer database system and the method for setting up this multilayer database system
Technical field
The present invention relates to a kind of database system structure, particularly relate to a kind of multilayer database system structure that is applicable to database upgrade.
Background technology
In recent years, fast development along with multimedia technology, spatial database technology and computer network, the development of Database Systems is very rapid, application is more and more wide, and the administration of business unit, government department, office automation, enterprise's production planning management, bank finance management, hospital ward medical record management, library management, weather forecast, Geographic Information System (GIS), ecommerce or the like all be unable to do without Database Systems.On the one hand, some are than proven technique, are put to application as various large, medium and small and microcomputer data base management system (DBMS)s and some traditional database design methods; On the other hand, still there are the many theories and the practical problems utmost point to wait to develop and explore, as spatial database, multimedia database, network data base, intelligence database etc.Particularly the theory and technology problem of network data base is just becoming a popular research field of database research, and in comparison, it is unable to do what one wishes that traditional database technology and system just seem, this has also proposed challenge to traditional technology and research and development.
Since latter stage in the 1970's, the development of nearly all Database Systems is a main shaft with system R (relational database system) all.In fact, the practice of relationship type is the main flow of today, and most important development also is unquestionable in the database field and the relationship type model becomes.Briefly, system R is exactly:
1. the data that the user saw all are forms.
2. the spendable computing of user (for example acquisition of data) all is to produce new form from old form.For example, some line that some operator (operator) is used for capturing in the form becomes a subclass, the craspedodrome that other some operator then is used for choosing in the form becomes subclass, and certainly, the subclass of the subclass of line and craspedodrome can constitute a new form altogether in the form.
So relevant database is so welcome, main cause is that it is based upon on the strict mathematical concept basis (based on " relational calculus "), all represent between entity (entity) in the database or the entity with relation, result for retrieval to data also is a kind of relation (being form), therefore the notion of relevant database is single, and it is quite simple, clear that its data structure also seems.The access path of related table is disclosed for the user in the relevant database in addition, and it has possessed higher data independence, level security more, has also simplified the work that database development is set up.In summary, the advantage of relational data table is the definition and the control of structural data connection very detailed.
Yet the shortcoming of relevant database then lacks flexibility, in case the association generation unusual fluctuation of data is pulled one hair and move the whole body, the modification of corresponding program is quite to waste time and energy.Usually relevant database independently also needs to set up a related table (relationaltable) outside the data form (data table) at two, with the relevance at database table intermediate settings major key (primary key) and other attached key (foreignkey).See also Fig. 1.Fig. 1 is an existing relevant database B1 synoptic diagram.Relevant database B1 comprises two data forms 10 and form 20, wherein contains data K1 in the form 10, contains data K2 in the form 20.In addition, setting up a form 30 in addition according to the relation of data K1 and data K2 represents.
If the benefit of opening relationships form is to search the foundation of relational expression, all relevant ancillary datas can be found out very fast; But comparatively speaking, use a very large shortcoming of related table to be exactly: when needs increase, delete, revise data newly, even need newly-increased, deletion, when revising database, the relevance between the data can make these tasks of execution become very complicated, consuming time and make mistakes easily.For example, when the needs deleted data, just can delete the data that originally will delete after must earlier the attached relation data that is associated being deleted one by one.As shown in Figure 1, if we will delete the data K2 in the form 20, must earlier the data deletion of all relevant data K2 in the form 30 just can be deleted the data K2 in the form 20.
From programmer's viewpoint, the change relation of front and back data can make program design become difficult unusually; Also often in the process of Data Update, because the mistake of revision program, and make system produce wrong message, even cause the paralysis of total system.In addition,,, also may lose the association between each data or destroy this relevance database, cause total system to stop even the hardware of database has mistake slightly because each data relevance each other is very important.Thus, though the relevance database has increased the convenience on the data search, therefore sacrificed the efficient that data are newly-increased, delete, revise, and increased the unnecessary complexity of program itself; More seriously, Fu Za relational data library structure has been modified as an almost impossible engineering.
Please continue with reference to figure 1.Relevant database with three data forms when relating to key assignments data (key) as if the data of handling, no matter be to increase, delete or revise data newly, all needs three steps in the process that deals with at data itself.For example:
(1) step of newly-increased data:
Step 1: in form 10 newly-increased data K1
Step 2: in form 20 newly-increased data K2
Step 3: in the associated data of form 30 newly-increased data K1 and data K2
(2) step of deleted data:
Step 1: the associated data of data K1 and data K2 in the deletion form 30
Step 2: data K1 in the deletion form 10
Step 3: data K2 in the deletion form 20
(3) step of modification data (key assignments data):
Step 1: the associated data of data K1 and data K2 in the modification form 30
Step 2: revise the data K1 in the form 10
Step 3: revise the data K2 in the form 20
Above-mentionedly only relate to relation between form 30 and form 10, the form 20, do not comprise the relation of form 30 and other form as yet about newly-increased, deletion and the step of revising data.If relevant database has a n data form, then we can expect that the related table as form 30 will have C2n kind situation at most.When form quantity continued to increase, the operand newly-increased, that delete or revise that only carries out simple data or form was just very surprising.
On the other hand, because the program of object-orienteds (object oriented) such as C++ is come out one after another, nearly all program design all is design standards with the object-oriented.The notion of Object-Oriented Design is that the assembly with all base program analyses converts the interbehavior of object and object to.Also because the basic module of program design becomes analyzable notion, the simplification of object-oriented program just supported in succession in the language of UML (unified modeling language) language one class by invention and reinforcement.Yet very unfortunate, be reinforced into the object-oriented idea simultaneously at program language at present, though the utilization of database has so-called OODB Object Oriented Data Base to cooperate, but still in order on searching, to adopt relevant database with the consideration of degree of stability.
Just because of this, no matter be OODB Object Oriented Data Base or relevant database, when meeting with the demand of system upgrade, the upgrading of database all can be suffered incomparable risk.In a word, these risks from:
(1) field of database table tends to increase because of the demand of upgrading, and under the structure of relevant database, " increase field " can change database basic structure.
(2) data form of relevant database can and then be changed because of the change of master meter lattice, equally also can change the basic structure of database.
(3) when database version changes, the data of database form may be compatible.
Because the risk of these database design, the data that most information personnel often look mobile relevant database are the dangerous road, do not use even database usefulness has not been applied, and also only utilize the mode of instruction usefulness (performance tuning) to attempt to solve.
Summary of the invention
Therefore, fundamental purpose of the present invention provides a kind of multilayer database system that solves the database upgrade risk.
The invention provides a kind of multi-level Database Systems, it includes an entity data layers and an index data layer.This entity data layers comprises a tables of data, this tables of data records many object datas of these Database Systems, each object data of the tables of data of these Database Systems comprises a plurality of data item, each data item of a plurality of data item of this of this object data has a Property Name, one object identification code, contents of a project and an index codes.This index data layer records index data, and the index codes that is used for searching according to this these a plurality of data item meets the desired object data of application program to obtain in these Database Systems.
The present invention also provides a kind of method of setting up the multilayer database system, it comprises the following step: produce an entity data layers, it comprises a tables of data, this tables of data records many object datas of these Database Systems, each object data of the tables of data of these Database Systems comprises a plurality of data item, each data item of a plurality of data item of this of this object data has a Property Name, an object identification code, contents of a project and an index codes; And produce an index data layer, and it records index data, and according to the index data of this index data layer, the index codes of searching these a plurality of data item meets the desired object data of application program to obtain in these Database Systems.
Description of drawings
Fig. 1 is the synoptic diagram of related table in the existing relevant database.
Fig. 2 is the synoptic diagram of multilayer database one embodiment of system of the present invention.
Fig. 3 is the data list structure synoptic diagram of multilayer database of the present invention system.
Fig. 4 is for setting up the synoptic diagram of a tables of data in the multilayer database of the present invention system.
Fig. 5 is the synoptic diagram of an index data table in the multilayer database of the present invention system.
Fig. 6 is for setting up the synoptic diagram of index in tables of data in the multilayer database of the present invention system.
Fig. 7 is the synoptic diagram of deletion one object data in the multilayer database of the present invention system.
Fig. 8 is the gather together synoptic diagram of practical operation method of entity data layers among multilayer database another embodiment of system of the present invention.
The reference numeral explanation
K1, K2 list data B1 relevant database
10,20,30 forms, 40 associated data tables
42 data recording, 44 field names
50 application programs, 100 multilayer database systems
200 index data layers, 210 index data table
220 tables of comparisons, 300 dynamic data layers
400 entity data layers 410 are gathered together
422 object datas, 424 data item
430 tables of data, 432 Property Names
434 object identification codes, 436 contents of a project
440,440A, 440B index codes
Embodiment
Please refer to Fig. 2.Fig. 2 is the synoptic diagram of multilayer database of the present invention system 100.Multilayer database system 100 includes an index data layer 200, a plurality of dynamic data layer 300 and an entity data layers 400.Wherein, multilayer database system 100 links by index data layer 200 and application program, and index data layer 200 also is connected with entity data layers 400 with a plurality of dynamic data layers 300.Comprise in the entity data layers 400 and a plurality ofly gather together 410, the tables of data 430 of record solid data then is contained in gathers together in 410.Comprise a plurality of index data tables 210 in index data layer 200 and a plurality of dynamic data layer 300, be used for the recording indexes data.Index data table 210 and the index data that write down thereof are produced by application program according to the search condition of application program.Index data layer 200 and a plurality of dynamic data layer 300 also produce according to the design requirement of application program, if application requirement is comparatively simple, multilayer database system 100 even can not possess dynamic data layer 300 only is made of index data layer 200 and entity data layers 400.
When the application program of computer system produced the index data table 210 (and index data table 210 of a plurality of dynamic data layers 300) of index data layer 200 according to search condition and required type of database after, application program was promptly searched tables of data 430 according to the index data of the index data table 210 in index data layer 200 and the dynamic data layer 300.
Please refer to Fig. 3.Fig. 3 is in the multilayer database of the present invention system 100, gather together 410 synoptic diagram of one of entity data layers 400.Tables of data 430 is made of object-oriented program, tables of data 430 tables of data 430 record many object datas 422 of Database Systems 100, wherein each object data 422 comprises a plurality of data item 424, and each data item 424 of a plurality of data item 424 of object data 422 has a Property Name 432, an object identification code 434, contents of a project 436 and an index codes 440A.In the tables of data 430 of this embodiment, Property Name 432, object identification code 434 and the contents of a project 436 are the static data in the multilayer database system 100, the pattern of this static data (Schema) is promptly planned in entity data layers 400 the first of foundation, when Database Systems 100 operate or carry out the operation of any data processing, this pattern is neither influenced, that is the solid data of entity data layers 400 has the basic structure that need not change in the multilayer database system 100, can guarantee the stability and the security of solid data.As discussed previously, be provided with in the entity data layers 400 and a plurality ofly gather together 410, and in order to adapt to the various solid data different in kinds of database, each is gathered together and 410 can allow to have a kind of deployment outline, belongs to these 430 of all tables of data of 410 of gathering together to design with a kind of deployment outline.
In addition, in the tables of data 430 of this embodiment, index codes 440A is the dynamic data in the multilayer database system 100, it is set up according to the index data of index data table 210 in index data layer 200 and a plurality of dynamic data layer 300, and when index data table 210 changes to some extent, index codes 440A also can be synchronously along with changing (normally rebuliding), and when index data table 210 was deleted, its index codes 440A that sets up is deletion thereupon also.Also adapt to the design of application program and the complexity of data search, can comprise more than one index codes 440A in the tables of data 430.And application program is the index data according to index index data table 210, to search the index codes 440A of data item 424 in the tables of data 430, to obtain the data item 424 that meets in the multilayer database system 100 in desired object data 422 of application program or the object data 422.
Please continue with reference to figure 4.Fig. 4 is converted to the synoptic diagram of the tables of data of multilayer database 100 1 embodiment of system of the present invention for an associated data table of existing relevant database, first display field title 44 of associated data table 40 wherein, total " record identification code ", " name ", " sex ", " age " reach " blood group " five fields in associated data table 40.Each row of all the other of associated data table 40 then show each data record 42 according to field name 44.When desire is set up the tables of data 430 of one embodiment of the invention, the content that Property Name 432 1 hurdles of tables of data 430 are merged in the tables of data title (named herein is " personnel " tables of data) and the data field position 44 of associated data table 40 then; Because every data record 42 all has a unique record identification code in the associated data table 40, to do difference (main) with the index of this record identification code as the associated data table with other data recording, when practical operation one embodiment of the invention, then this record identification code is recorded in second hurdle of tables of data 430, as the content on object identification code 434 1 hurdles; Correspond to the data content of data field position 44 in 436 record data records 42 of the contents of a project of tables of data 430, with content as the contents of a project 436 1 hurdles.
With the first stroke data recording 42 in the associated data table 40 (" personnel " tables of data) for instance, the first stroke data recording 42 records " name " field contents: " Chen Jianhong ", " sex " field contents: " man ", " age " field contents: " 30 ", " blood group " field contents: " A ", the record identification code of the first stroke data recording 42 is " 1 " in addition, then the practical manner of one embodiment of the invention can be set up an object data 422 in view of the above, it comprises four data item 424, wherein the data content on Property Name 432 1 hurdles of the first stroke data item 424 be " personnel name " (as previously mentioned, this hurdle content is the merging of tables of data title and data field position title in the associated data table 40), the content on object identification code 434 1 hurdles is " 1 ", and the content on the contents of a project 436 1 hurdles is " Chen Jianhong "; In like manner, the data content on Property Name 432 1 hurdles of second data item 424 is " a personnel sex ", the content on object identification code 434 1 hurdles is " 1 " (all belong to the same target data, so the object identification code being identical), and the content on the contents of a project 436 1 hurdles then is " man " ... the rest may be inferred by analogy.Thus, a data record 42 in the associated data table 40 can be created as four project datas 424 of the tables of data 430 of one embodiment of the invention, these four project datas 424 constitute an object data 422, and therefore the content on object identification code 434 1 hurdles of four project datas 424 is all identical.
Please refer to Fig. 5, Fig. 6.As previously mentioned, application program produces the index data table 210 (and index data table 210 of a plurality of dynamic data layers 300 back) of index data layer 200 according to search condition and the required type of database of application program, and carries out the data search of tables of data 430 according to this.Fig. 5, Fig. 6 are illustrated in index data layer 200 and establish an index data table 210, wherein comprise index data and be used for having the project data 424 of data content in the contents of a project 436 with project data 424 for " man ", in the index codes 440A of this project data 424 field, be denoted as " 0 ", and be used for having the project data 424 of data content in the contents of a project 436 with project data 424 for " woman ", in the index codes 440A of this project data 424 field, be denoted as " 1 ".After the foundation of index data table 210 is finished, the tables of data 430 that can set up in entity data layers 400 dynamically increases by an index codes 440A field, and according to aforementioned condition " 0 " and " 1 " are inserted in the field of suitable project data 424, index codes 440A one hurdle of all the other ineligible project datas 424 does not then act on.
When desiring to search the object data 422 that meets in the tables of data 430 according to the index data that index data table 210 is indicated, for example desire is searched the data of all male sex employees in the database, then only need in index codes 440A, extract the data item 424 of code content, and obtain required object data 422 according to object identification code 434 in the data item 424 for " 0 ".So finished the seek operations of data.
In like manner, as desire to find out in the tables of data 430, age was less than 30 years old male sex employee, then according to an index codes 440B who sets up in tables of data 430 in addition in the index data table 210 (or index data table 210 of in dynamic data layer 300, setting up) of index data layer 200 foundation in advance, intersect search with the index codes 440A that had originally set up again, can extract the data that two conditions all meet.
In addition, when fit applications program requirements and desire realize the purpose of " a newly-increased field in existing associated data table 40 ", in the tables of data 430 of one embodiment of the invention be direct newly-increased data item 424 in tables of data 430 as rule, its each field contents is then set up according to the aforementioned mode of setting up.For example to increase the field of " marital status " newly, and the field contents with respect to " marital status " field of the first stroke data recording 42 is when being " married ", then in tables of data 430, increase a data item 424 newly, the data content on its Property Name 432 1 hurdles is " a personnel marital status ", the content on object identification code 434 1 hurdles is that " 1 " (belongs to the same target data, therefore the object identification code is identical), the content on the contents of a project 436 1 hurdles then is " married ".
Please refer to Fig. 7.Fig. 7 deletes the illustration of an object data for multilayer database of the present invention system 100 desires.If fit applications program requirements and desire realize " data record 42 of deletion in existing associated data table 40 " during the purpose of " deletion one field in existing associated data table 40 ", in the tables of data 430 of one embodiment of the invention be directly in the index data table 210 of index data layer 200 as rule, the index data table 210 that records data available table 430 in the entity data layers 400, object data 422 or data item 424 is indicated index data effective or commonly used.
Application program can dynamically be set up a universe index data table 210 in index data layer 200, wherein can be on demand being planned to the unit of deal with data with data item 424 be unit, or is unit with object data 422 even with tables of data 430.Certainly can also set up two layers to the index data table 210 more than the multilayer, to realize simultaneously at the target of gathering together 410, solid data scopes such as tables of data 430, object data 422 and data item 424 are made the universe index.When application program is desired in the deleted data table 430 the 3rd object data 422, in universe index data table 210 " availability " field is denoted as "No", then the index content of " the effectively index " of " universe index " field corresponding data table 430 also will be read as invalid data.In other words, multilayer database system 100 can by in index data layer 200, set up the index data table with indicate tables of data effective or commonly used in the entity data layers 400 430, gather together 410, object data 422 or data item 424.
What pay special attention to is, " effectively index " of tables of data 430 dynamic index hurdle of also setting up according to application programming wherein for index data layer 200, itself and object identification code 434 are inequality, no matter be object identification code 434 or effectively index (or even other index codes of dynamically setting up) all can help Domain Index or partial indexes according to the program design Demand Design.
Fig. 8 is the gather together synoptic diagram of practical operation method of entity data layers among multilayer database 100 another embodiment of system of the present invention.When constantly increasing because of year in year out development and change when data type, the tables of data 430 of entity data layers 400 does not need unconfined expansion.Multilayer database of the present invention system 100 sets up in addition in entity data layers 400 and gathers together 410 to place a plurality of tables of data 430.Gathering together 410 itself is had fixing capacity limit by default, enlarges to avoid arbitrary unbounded size system of 410 of gathering together.When the object data quantity growth of a class during to a certain degree, entire database can be opened one again and be gathered together 410, to place newly-increased tables of data 430 and object data wherein.In large-scale Database Systems, if can remake further classification and screening to the data of searching, then help the lifting of searching efficiency, therefore, gathered together 410 o'clock in foundation, the present invention is promptly to 410 operations of setting up index of gathering together, and sets up a table of comparisons 220 of searching clustered index and make further scope and limit will search object in index data layer 200.And a plurality of gathering together 410 also need not be defined and be stored in the single main frame in the entity data layers 400.A plurality of gathering together 410 is stored in respectively in a plurality of main frames that link to each other via network system, to disperse the processing load of host computer system.
For the person of being used still is accustomed to setting up the data of database content with forms mode, the interface of application program still can be designed to import data with the form of form (or similar form) for the user, no matter be the newly-increased of data, deletion, revise, or the data field position is newly-increased, deletion, revise, so that the foundation of the data relationship between above form, remove, all can in the tables of data 430 of entity data layers 400, set up relevant index codes 440 fields (one or more) to finish the foundation of object data 422 by above-mentioned index data layer 200 or dynamic data layer 300.With previous embodiment, when user's desire is set up the data with twenty field, the existing practice is exactly to write the data with twenty field in database, and an embodiment of multilayer database of the present invention system 100 sets up twenty data item 424 with three fields (under situation of not setting up index codes 440 as yet) in tables of data 430.For avoiding occupying system resources when data item 424 is set up so that influence the usefulness of multilayer database system 100, between the index data layer 200 of application program end and multilayer database system 100, can set up a queue buffer in addition, make multilayer database system 100 can utilize all systems the idle time to carry out the work of setting up of data.
On the other hand, also can present than the forms mode of being accustomed to convert the user to through the data after searching by program design, for application program, multilayer database system 100 provides the data storing structure of a safety, and user's end can be continued to use original data processing method to avoid the change of use habit.Also because the mode of 100 kinds of storage object data of multilayer database system almost is constant, at demands such as the structural change of database, system upgrades, multilayer database system 100 can finish these changes for the suitable tool risk of system R.
The above only is preferred embodiment of the present invention, and all equalizations of doing according to claim of the present invention change and modify, and all should belong to covering scope of the present invention.