A kind of database access and integrated approach and system thereof
Technical field
The present invention relates to a kind ofly towards secondary development, at database application developer's computer software, particularly a kind of new relational database visit and integrated solution based on theme mapping metadata specifically comprise correlation theory and realization thereof.
Background technology
Along with military training deepen continuously and the application of general training simulation information platform is constantly expanded, units such as base, training place, commander and technology universities and colleges have gathered and have produced lot of data and ensured separately training, these military training data are treasures of army's informatization process, also are the important foundations of military training informatization.
Commensurate can not produce and exchange mutually various data in war simulation system operational process, and they generate and be present in each different phase of operational training, it is many more to participate in unit, the single training time is long more, and the demand of data and generation are just big more, and management and use are just difficult more.Because form, form, content and the quality of data that constituent parts produces have usually than big-difference, when these data are used simultaneously by different units, this species diversity can directly influence effective enforcement of combined operation training, must integrate the objective requirement that these data resources satisfy the combined operation training.Under the existence conditions, how could focus on the combined operation training with strategy, the data resource that can use these constantly to increase, distribute easily, improve the ease for use of data access, to also consider security and control of authority in the data use? can develop a data access system that addresses these problems use is provided? these all are pendulum is needed solution badly in face of us problems.
Specifically, current database access at the system development personnel exists not enough in the following aspects:
1. data deposits, before not generation standard of military training data, constituent parts can only be deposited training data according to the standard of oneself, there is different standards in different units, and these data qualifications and the standard major part deposited do not pass through the checking and the deliberation of specialty yet, and the result is exactly that deposit data is more mixed and disorderly, not only influences reusing and further developing of data itself, increase the not difficulty of commensurate's connection instruction, also influence effective enforcement of combined operation training.
2. data searches, because the standard difference that each unit data is deposited, not through specialty checking and the various criterion weighed to not between the commensurate the mutual use of data constituted big obstacle, promptly can not find the data that need, and the data criteria for classifying of other unit is unfamiliar with oneself according to the standard of oneself being familiar with.
3. the use of data, the table name at the data place that has, field name all are English or Pinyin abbreviation, have both increased the difficulty of seeking data, also cause the semantic unclear of data, are difficult to be understood by different units and use.
4. data access interface disunity, lack of standardization, the database access code of different common data bank interfaces still can not be reused,
5. the capability of sustainable development of data is poor, application program and data structure are tightly coupled, in a single day data structure changes, and the application program that comprises data access just must be made a large amount of changes, and the data structure of military training data and content change are inevitable, frequent.
6. safety of data is poor, application program uses real database name, table name, field name can bring the problem of security in SQL, might allow third party or do not have authority to use the people of these data, recognize real data structure, increase data by the risk of undesired use.
7. the user wishes to use mode natural more, that contain semanteme to carry out data access, progressively improves " intelligence " degree of data access.
Summary of the invention
(1) goal of the invention
The purpose of this invention is to provide a kind of database access and integrated approach and system thereof based on theme mapping metadata and overcome the problems referred to above.
(2) summary of the invention
A kind of database access and integrated approach, this method are based on theme mapping metadata, said method comprising the steps of:
S1: analyze the affiliated relation schema feature of data semantic and data, propose the data in the database are carried out subject indexing and relationship map, generate the theme mapping metadata of reflection data subject attribute and data relationship pattern;
S2: subject data base connects configuration, comprising:
Subject data base connects the setting of content, adopt the bottom data access technique can compatible database connection string, or self-defined a kind of database connection string that can be converted into the form that the bottom data access technique can discern be provided with subject data base and connect content;
The integrated configuration that subject data base connects forms a file with described database connection string organize together;
S3: browsing data, and generate auxiliary data access protocal statement simultaneously;
S4: test the auxiliary data access protocal statement that generates among the described step S3, obtain active data access protocal statement and visit result, thereby verify whether this statement can realize user's requirements for access really;
S5: the unified system interface by the COM encapsulation is provided, will obtains active data access protocal statement and be submitted to database, and receive the result who returns from database.
Wherein, described step S1 is an iterative process, by browsing repeatedly, analyzing and revising to data, the final theme mapping metadatabase that forms, be used to describe relational database physically, described theme mapping metadatabase combines the formation subject data base with physically relational database, and data access service is provided.
Wherein, described theme mapping metadata store is in theme mapping metadatabase.
Wherein, described theme mapping metadatabase is stored in the theme mapping metadata warehouse, and described theme mapping metadata warehouse is corresponding with physically relational database.
Wherein, being provided with of subject data base connection content adopted ADO concatenation character string format among the described step S2.
Wherein, the file that forms in the integrated layoutprocedure that subject data base connects among the described step S2 is the file that meets XML standard and XML modulo check.
Wherein, browsing data comprises among the described step S3: read configuration, show topics, select theme and video data.
Wherein, the auxiliary data access protocal among described step S3, S4 and the S5 is that active data access protocal described in S4 and the S5 is Structured Query Language (SQL) SQL based on the query language of theme mapping metadata.
A kind ofly it is characterized in that, comprising based on described database access and integrated approach designed system:
Be used to analyze data semantic and the affiliated relation schema feature of data, propose the data in the database are carried out subject indexing and relationship map, generate the module of the theme mapping metadata of reflection data subject attribute and data relationship pattern;
Be used for subject data base and connect configuration module, this module comprises:
Subject data base connects the module that is provided with of content, be used to adopt the bottom data access technique can compatible database connection string, or self-defined a kind of database connection string that can be converted into the form that the bottom data access technique can discern be provided with subject data base and connect content;
The integrated configuration module that subject data base connects is used for described database connection string organize is formed a file together;
Be used for browsing data, and generate the module of auxiliary data access protocal statement simultaneously;
Be used to test auxiliary data access protocal statement, obtain active data access protocal statement and visit result, thereby verify whether this statement can realize the module of user's requirements for access really;
Be used for obtaining active data access protocal statement, the unified system interface by COM encapsulation is submitted to database, and receives the result's who returns from database module.
(3) beneficial effect
The present invention has following beneficial effect:
1, database access of the present invention and integrated system have been simplified the data access size of code greatly for data access provides succinctly, the interface of unified and standard, and data access interface is supported multiple program development language based on the COM standard.
2, to introduce semantic data query language (SMQL), increased the ease for use of data access as DAP.
3, with data query language as DAP, increased the dirigibility of data access.When function that native system provided can not satisfy new demand data, only need get final product for data query language increases new syntax rule, when keeping compatibility, improved the adaptability of native system to new demand.
4, utilize theme mapping metadata to hide the actual data structure in the database, made things convenient for depositing, search and using of data, improved safety of data.
5, reduced the degree of coupling of application program and data, the present invention uses theme mapping metadata description demand data, the hard coded that does not have database connection and database structure information in the code, when these information take place to change, only need change theme mapping metadata both can, need not change source code, original application program still can normally be visited desired data.
Description of drawings
Fig. 1 shows according to database access and the main process of integrated approach based on theme mapping metadata of the present invention, and this figure adopts OMG standard----Business Process Model andNotation (BPMN) to draw;
Embodiment
Database access and integrated approach that the present invention proposes based on theme mapping metadata, accompanying drawings is as follows:
As shown in Figure 1, effective visit data must be earlier effective data of description, metadata description among the step S1 (generator data) comprises before to the browsing of data structure and content in the True Data storehouse, for metadata description ready.In the metadata description process data of browsing are before carried out signature analysis, by the relation schema feature under analysis data semantic and the data, proposed the data in the database are carried out subject indexing and relationship map, generated the theme mapping metadata of reflection data theme and data relationship pattern.Use the metadata description of subject indexing and relationship map to observe following rule in this method:
1. a theme can be used for 1 relation (certain table in the True Data storehouse) in the index relational model;
2. a relation (certain table in the True Data storehouse) can be carried out index with a plurality of different themes in the relational model;
3. a theme can be used for 1 territory (certain row name in certain table in the True Data storehouse) in the index relational model;
4. index can be carried out with a plurality of different themes in 1 territory (certain row name in certain table in the True Data storehouse) in the relational model;
5. each theme can only corresponding father's theme.Father's theme and sub-topics can be membership, whole and part relations or concern that comprehensively with in a certain respect father's descriptor is a upperseat concept that conceptive the sub-topics speech is a subordinate concept;
6. each theme can corresponding 0 or 1 sub-topics;
7. each theme can corresponding a plurality of descriptor;
8. all themes of a subject data base constitute a subject tree;
9. the root node of subject tree is not only described the principal character of entire database content, and is the metadata that subject data base connects, can corresponding a plurality of subject data library names;
In order to distinguish different themes, reduce and use difficulty, the descriptor of descriptive data base and connection thereof is called storehouse unit, the descriptor of descriptive data base table is called classification or list cell, and the descriptor that is listed as in the descriptive data base table is called field unit.When the table name in the True Data storehouse or field name change, only need the corresponding theme of change that the mapping relations of table name or field name are got final product, prior application program need not change, and has reduced the degree of coupling of data access logical and True Data structure.All theme mapping metadata form one or more databases, i.e. theme mapping metadatabase.The database schema of theme mapping metadatabase will be introduced at following joint.Because data involve a wide range of knowledge, metadata description generally is an iterative process, by browsing, analyze, revising repeatedly, forms final theme and shines upon metadatabase.The theme mapping metadatabase that relational database physically and being used to is described it has formed an integral body, be data access service together, claims this integral body database that is the theme herein, abbreviation theme storehouse.
Corresponding to relational database real on each physical layer, a theme mapping metadata warehouse can be arranged, a theme mapping metadata store mode can comprise one or more theme mapping metadatabase relation schemas, formation is to the different themes mapping relations of same relational database, and this is the key of data in the same database being classified with different themes.
Step S2 subject data base connects configuration, comprising: the integrated configuration that the setting of subject data base connection content is connected with subject data base.
Subject data base connects being provided with of content and can adopt the bottom data access technique can certain compatible database connection string, perhaps self-defined a kind of database connection string is converted into the form that the bottom data access technique can be discerned in the time of concrete then the use.Adopt ADO Connection String form in this method, be called for short ACS.ADO and follow-up ADO.NET can use this form connection of ACS to comprise SQL Server, Sybase, Informix, Firebird, Interbase, Ingres, AS/400, Oracle, MySQL, PostgreSQL, IBM DB2, database servers such as Paradox, can also connect Excel such as MS, MS Access, MS Project, Foxpro, SQLite, Textfile, Filemaker, file type data storehouses such as LotusNotes, even can also connect Exchange, Active Directory, catalogue that Index Server is such and index information.For instance, ACS connects string " Provider=SQLOLEDB.1; Network Library=DBMSSOCN; PersistSecurity Info=True; Data Source=10.80.83.42,1433; User ID=wang; Password=secret; Initial Catalog=Subject_dxsj; " represent to connect the SQL Server database server that is positioned at 10.80.83.42, port numbers 1433 by ICP/IP protocol, the username and password of visit is respectively wang and secret, and initial database name is called Subject_dxsj.
The method that the integrated configuration that subject data base connects is adopted is different ACS databases to be connected be placed in the trail in the file that meets XML standard and XML pattern (XML Schema) verification.Verification comprises that mainly ACS connects string verification (value of connectionString), subject data base and connects the different databases that subject data base (the name attribute of subjectDatabase) can not repeat, subject data base is quoted that repeat, open of string another name (the name attribute of connectionString) and connect string and must have (value of the connectionString of subjectDatabase Already in the name property value of connectionString in).
Step S3 browsing data also generates auxiliary data access protocal statement, wherein browsing data comprise read configuration, show topics, select theme, video data 4 sub-steps, in the navigation process, if do not find needed data, can return previous step and select different themes, up to finding needed data.If data qualification is various, can be first search for mapping metadata, and then select the theme that searches.Browsing data is for the final data visit, has association to a certain degree between the data that the data that the user browsed must and need to visit.The data that the data of browsing may need be visited exactly, the also part of the data that may just need visit.Generate auxiliary data access protocal statement and be exactly the data browsed according to the user and this relation of data of needs visit, automatically generate auxiliary DAP statement, promptly shine upon the query language SMQL (Subject and Mapping Metadatabased Query Language) of metadata based on theme.This language shines upon metadata based on theme, do not use real database name, table name, field name, reduced the degree of coupling of application program and data, improved safeness of Data Bank, and database connected include language in, having expanded not have the directly function of realization among the SQL, can realize that file uploads download function, have the extensive upgrading space of upgrading, before the intellectual access direction, go a step further.
Step S4 tests the SMQL statement that generates among the described step S3, the SMQL language is resolved to the general query language SQL of database, visit database by SQL and obtain required result and related commissioning information, thereby verify whether this SMQL statement can realize user's requirements for access really.
Step S5 visit data will obtain effective SQL statement, and the unified system interface that encapsulates by COM is submitted to database, and database access (to increase, deletion, modification or the inquiry etc. of data in the database) is also received the result who returns from database.
The present invention adopts the subject data manager to come performing step S1, S2 and the pairing module of S3, and the subject data manager has theme and adjusts function, and data are carried out subject indexing and relationship map generator data; Browsing data and additional function, the basic functions of subject data manager is exactly a browsing data, at first read the theme configuration during browsing data and be connected to the theme storehouse, then show topics, select theme, last video data then as required, if in this process, do not find needed data, can return previous step and select different themes, up to finding needed data.In browsing data, realize other 4 additional functions by shortcut: the additions and deletions that the additions and deletions of data change, generate auxiliary SMQL statement, metadata change, file is uploaded and download; The metasearch function when the user is unfamiliar with subject classification, just can find related data information by this function; Data access is provided with and configuration feature, the connection string of subject data base is set, and is configured to integrated a plurality of subject data base, for data access provides access; Authority is provided with function, for the seat of different stage is provided with different access rights, has improved access security.
The present invention adopts the module of coming performing step S4 correspondence based on the data query language tester (SMQL tester) of theme mapping metadata, adopts the module of coming performing step S5 correspondence based on the database access middleware of theme mapping metadata.Wherein, database access middleware based on theme mapping metadata is the dynamic link library (DLL) form, unified data access interface is provided, and this interface encapsulates second development interface for adopting the COM mode, only just can call all functions that the database access middleware provides with a function in the interface.This middleware is by the SMQL resolver, and the SMQL statement that application program is imported is construed to SQL statement, again SQL statement is submitted to database.The SMQL tester calls the test that this middleware is finished the SMQL statement, obtains effective SQL statement, carries out this statement and return results, thereby whether checking SMQL statement satisfies user's requirements for access.
Above embodiment only is used to illustrate the present invention; and be not limitation of the present invention; the those of ordinary skill in relevant technologies field; under the situation that does not break away from the spirit and scope of the present invention; can also make various variations and modification; therefore all technical schemes that are equal to also belong to category of the present invention, and scope of patent protection of the present invention should be defined by the claims.