CN102254029A - View-based data access system and method - Google Patents

View-based data access system and method Download PDF

Info

Publication number
CN102254029A
CN102254029A CN2011102168802A CN201110216880A CN102254029A CN 102254029 A CN102254029 A CN 102254029A CN 2011102168802 A CN2011102168802 A CN 2011102168802A CN 201110216880 A CN201110216880 A CN 201110216880A CN 102254029 A CN102254029 A CN 102254029A
Authority
CN
China
Prior art keywords
sql
view
connector
maker
control unit
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.)
Granted
Application number
CN2011102168802A
Other languages
Chinese (zh)
Other versions
CN102254029B (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.)
Zhuzhou CRRC Times Electric Co Ltd
Hunan CRRC Times Signal and Communication Co Ltd
Original Assignee
Zhuzhou CSR Times Electric Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhuzhou CSR Times Electric Co Ltd filed Critical Zhuzhou CSR Times Electric Co Ltd
Priority to CN 201110216880 priority Critical patent/CN102254029B/en
Publication of CN102254029A publication Critical patent/CN102254029A/en
Application granted granted Critical
Publication of CN102254029B publication Critical patent/CN102254029B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The invention discloses a view-based data access system and method. An interface element is connected with a data access layer, an object creating element of the data access layer creates a data access element, the data access element comprises a complex view element and a simple view element; the data access element generates an SQL (Structured Query Language) operation statement, the data access element is connected with a database interface, the database interface transmits the SQL operation statement to a relational database through a relational database connecting module, the relational database executes the SQL operation statement and obtains an inquiry statement defined by a data attribute from a data access element object as well as transmits the inquiry statement to the relational database, the relational database executes the inquiry statement; the relational database connecting module transmits data returned by the inquiry statement to the data access element; and the data access element transmits an obtained data source to the interface element for displaying. According to the invention, work amount of developers is effectively reduced and whole development cycle can be shortened.

Description

A kind of data access system and method thereof based on view
Technical field
The present invention relates to computer data access technique field, especially relate to a kind of data access system and method thereof that is applied to the computerized information field based on view.
Background technology
Current, in the data access based on relational database, mainly contain several several methods down:
(1) embedded SQL code
Method employed in figure 1 is that SQL (Structured Query Language, Structured Query Language (SQL)) code directly is embedded in the service class, and this strategy is can develop fast at mini-system.But its shortcoming also is obviously, and the SQL code is to write in the source code, and this just means any one simple change, for example changes a row name of showing in the database, then must revise source code.This modification still can be accepted for a mini-system, if for big-and-middle-sized system, this defective is very serious.
(2) service class is set up independently data class
Method employed in figure 2 is that the SQL code of service class writes in independently one or more data class or in storing process.This method has had very big progress with respect to the SQL code is embedded in the service class, but this method only is applicable to that equally also service class is less than about 40 to 50 mini-system.Simultaneously, when database simply changed, corresponding data class will recompilate.This method has just been accomplished the pressure source code, and treatment S QL has been placed on data class.Adopt this method, supporting to lack dirigibility aspect the corresponding same mapping definition of a plurality of object models, the developer must manual each object model of mapping.Worse, in enterprise-level application, this method is can not be well in the isomery component environment independent, and because method is static, that is: corresponding mapping model of class is so can not expand.
(3) service class is set up the data class of sharing
Method employed in figure 3 is to set up a shared data class for all service class to realize data access, is actually at the improvement of setting up the independent data class methods for each service class.Compare with above-mentioned independent data class methods, the shared data class has realized the reusability of code.Shared data class figure shown in Figure 4, wherein method parameter tableName is a table name, two static array Name and Value deposit row name and train value respectively.Concrete grammar comprises inquiry, increase, deletion and revises, and according to table name parameter and two static arrays, utilizes the dynamic sql technology to realize the automatic generation of SQL code.The shared data class methods have been broken away from heavy SQL statement, have realized the automatic generation of SQL statement.From this angle, the shared data class methods are greatly improved, but the shared data class only is adapted to single table handling, inapplicable multilist operation, and when for example needing in the query manipulation to obtain data from many tables of database, above-mentioned shared data class can't realize.
In the middle of prior art, a kind of is to be applied on 05 10th, 2007 by LANG CHAO GENERASOFT Co Ltd with the immediate technology of the present invention, on November 07th, 2007 is open, and publication number is that the Chinese invention patent application " mapping conversion method between data access layer XML formatted data and relation data " of CN101067814A is disclosed.This invention mainly is binding mode, the method for explanation data access layer.It provides the mapping conversion method between a kind of data access layer XML formatted data and relation data, two stages when this method mainly comprises when design and operation, wherein: the stage when design, carry out modeling at the data structure of relation data and the mapping and the conversion of object and relation data, be described as two kinds of metadata of data object and data model, data object is that relation data carries out modeling, come out the data structure of table in the database and view is abstract, describe its title, field attribute etc.Stage when operation, by data accessing engine, the metadata information of definition during according to design, data message in conjunction with input, SQL (Structured Query Language (SQL)) statement of dynamic constructs database access visit, accessing database is finished the function that additions and deletions change the data access layer of looking into automatically, and the result of dynamic construction process is carried out an amount of buffer memory.
(1) in embedded SQL code method, the SQL code writes in the source code, and any one simple change then must be revised source code;
(2) in service class was set up independently the data class method, the SQL code write in independently one or more data class or in storing process.Adopt this method, supporting to lack dirigibility aspect the corresponding same mapping definition of a plurality of object models, the developer must manual each object model of mapping.Worse, in enterprise-level application, this method is can not be well in the isomery component environment independent, and because method is static, that is: corresponding mapping model of class is so can not expand;
(3) set up in the data class method of sharing in service class, set up a shared data class for all service class and realize data access, utilize the dynamic sql technology to realize the automatic generation of SQL code.The shared data class methods have been broken away from heavy SQL statement, have realized the automatic generation of SQL statement.From this angle, the shared data class methods are greatly improved, but the shared data class only is applicable to single table handling, are not suitable for the multilist operation, when for example needing in the query manipulation to obtain data from many tables of database, above-mentioned shared data class can't realize.
(4) when the user uses the method for CN101067814A application for a patent for invention to carry out the list data operation, if the data source of form is following situation:
(a) view of use DISTINCT operational character in the SELECT statement;
(b) view of aggregate functions such as similar SUN of use or MAX;
(c) comprise GROUP BY, ORDER BY clause's view;
(d) view of use subquery in the SELECT tabulation;
(e) view of a plurality of tables of associating.
Several class views of above-mentioned this can not upgrade by SQL statement in the ordinary course of things, for example can't operate the viewdata that a plurality of physics tables are formed with a standard SQL (for example Update);
When data source has view and physics table, the developer not only wants the table definition in acquaint with data storehouse, also will be familiar with a large amount of view definitions, has increased development difficulty.
Summary of the invention
The invention provides a kind of data access system and method thereof based on view, the SQL code does not appear in this system and method thereof in source code file, realize of the mapping of MDAC object, reduced developer's quantities effectively, can shorten the whole construction cycle relational database.Total system is easy to study and operation simultaneously.
The invention provides a kind of technic relization scheme of the data access system based on view, a kind of data access system based on view comprises: interface assembly, data access layer, database interface, relational database link block, relational database;
Interface assembly links to each other with data access layer, and sends user message to data access layer;
Data access layer comprises Object Creation assembly and MDAC, the Object Creation building component MDAC of data access layer, and MDAC comprises complex view assembly and simple view assembly;
MDAC produces the SQL action statement, and MDAC is connected with database interface, obtains database information by the XML configuration file, obtains database connection object simultaneously;
Database interface links to each other with the relational database link block, by the relational database link block SQL action statement is passed to relational database, relational database is carried out the SQL action statement, and the defined query statement of data attribute that obtains in the MDAC object being passed to relational database by the relational database link block, relational database is carried out query statement;
The relational database link block is given MDAC according to query statement with the data transmission of being returned;
MDAC transfers to interface assembly with the data source of obtaining and shows, the interface assembly refresh data, and notify the user.
As the further improvement of a kind of data access system technical scheme based on view of the present invention, the complex view assembly comprises first central control unit, SQL operation maker, the first view maker, INSTEAD OF trigger maker, the first dynamic sql assembly unit maker, first connector, the set of first public attribute;
First central control unit receives user message, return user data or information, the analyzing XML mapped file also writes the set of first public attribute, send action message to SQL operation maker, the first view maker, INSTEAD OF trigger maker, and receive SQL operation maker, the first view maker, the message of INSTEAD OF trigger maker and the return results of relational database;
The one SQL operation maker generates SQL, and is sent to relational database by first connector and database interface;
The first view maker is created the dynamic sql that assembly relies on view according to different relational databases;
INSTEAD OF trigger maker is created a dynamic sql that relies on the INSTEAD OF trigger of operating on the view at assembly according to different relational databases;
Dynamic sql assembly unit maker carries out the assembly unit of SQL according to the public attribute value of first public attribute set output, realizes dynamic sql;
First connector is connected with database interface;
First public attribute set storage is from the relevant information of the first central control unit analyzing XML mapped file.
As the further improvement of a kind of data access system technical scheme based on view of the present invention, the simple view assembly comprises second central control unit, the 2nd SQL operation maker, the second view maker, the second dynamic sql assembly unit maker, second connector, the set of second public attribute;
Second central control unit receives user message, return user data or information, the analyzing XML mapped file also writes the public attribute set, and, receive the 2nd SQL operation maker and the message of the second view maker and the return results of database to the 2nd SQL operation maker and second view maker transmission action message;
The 2nd SQL operation maker generates SQL, and is sent to relational database by second connector and database interface;
The second view maker is created the dynamic sql that assembly relies on view according to different relational databases;
The second dynamic sql assembly unit maker carries out the assembly unit of SQL according to the public attribute value of second public attribute set output, realizes dynamic sql;
Second connector is connected with database interface;
Second public attribute set storage is from the relevant information of the second central control unit analyzing XML mapped file.
The present invention also provides a kind of the utilization above-mentionedly to carry out the technic relization scheme of the method for data access based on the data access system of view, and this method may further comprise the steps:
S101: interface assembly sends to data access layer and comprises that path, MDAC object identity, the MDAC of concrete operation information, view component type identification, XML mapped file and XML configuration file obtain the user message of Data Identification;
S102: the Object Creation assembly of data access layer is created a data access component object according to the view component sign, the MDAC object comprises complex view component object or simple view component object, and finishes the initial work of MDAC object;
S103: the MDAC object is finished initial work according to the type of complex view assembly or simple view assembly, and according to the operation information attribute, if data are obtained, then carries out data acquisition; If data deletion is then carried out the data delete procedure; If data increase or revise, then carrying out data increases or modification process, produces a SQL action statement by MDAC at last;
S104: the MDAC object connects database interface, obtains database information by the XML configuration file, obtains a database connection object simultaneously;
S105: the relational database link block passes to relational database by database connection object with the SQL action statement, and relational database is carried out the SQL action statement;
S106: the relational database link block passes to relational database by database connection object with the defined query statement of data attribute that obtains in the MDAC object, and relational database is carried out query statement;
S107: database connection object is passed to the MDAC object according to query statement with the data of being returned, and behind the complete operation, this database connection object is closed;
S108: the MDAC object offers the interface assembly object with the data source of obtaining and shows, this MDAC object of system-kill;
S109: interface assembly object refresh data, and notify the user.
As the further improvement of a kind of data access method technical scheme based on view of the present invention, comprise complex view component object initialization procedure based on the data access method of view, this process may further comprise the steps:
S201: first central control unit writes user message respectively in the public attribute set of component object, comprises concrete operations message attributes, XML mapped file path attribute, XML Profile Path attribute, object identity attribute, obtains the Data Identification attribute or obtains the query condition value of data;
S202: first central control unit finds the XML mapped file according to the XML mapped file path attribute of component object, in the XML mapped file, realize the location according to the object identity attribute, find corresponding data block, first central control unit carries out XML to data block and resolves work, and the public attribute that physics table name, Table Properties etc. is write object is concentrated;
S203: first central control unit sends to SQL operation maker and obtains the Data Identification attribute message, call the first dynamic sql assembly unit maker and select query statement of the dynamic generation of first public attribute set by SQL operation maker, the one SQL operation maker returns to first central control unit with select query statement message, and first central control unit writes the select query statement obtaining in the data attribute of object again;
S204: first central control unit sends Query Database view message to SQL operation maker, call the first dynamic sql assembly unit maker and first public attribute by SQL operation maker and gather the SQL whether view that dynamic generation component object relied on exists, and send to first connector;
S205: first connector is created a database connection object after connecting database interface, and relational database is carried out the SQL whether the inquiry view exists, and the result is returned to first connector, and first connector is passed to first central control unit with message; Otherwise if first connector is overtime, then first central control unit sends an error message, and flow process finishes;
S206: first central control unit is received the message of first connector, if view exists, and then direct execution in step S211; Otherwise first connector cuts out the database connection object of new establishment by database interface, first central control unit sends to the first view maker and creates view message simultaneously, the interface of the first view maker obtains the relational database type according to the XML configuration file, select corresponding relational database view formation component, this component call first dynamic sql assembly unit maker and the set of first public attribute dynamically produce a SQL who creates view, and this SQL is sent to first connector;
S207: first connector is received the SQL that creates view, connects database interface, creates a database connection object, and relational database is carried out and created view SQL, and the result is returned to first connector, and first connector is passed to first central control unit with message; Otherwise if first connector is overtime, then first central control unit sends an error message, and flow process finishes;
S208: first central control unit is received the message that view is created, close the database connection object of new establishment by database interface by first connector, send to INSTEAD OF trigger maker simultaneously and create INSTEAD OF trigger message, the interface of INSTEAD OF trigger maker obtains the relational database type according to the XML configuration file, select corresponding relational database INSTEAD OF trigger formation component, this component call first dynamic sql assembly unit maker and the set of first public attribute dynamically produce a SQL who generates INSTEAD OF trigger, and this SQL is sent to first connector;
S209: first connector is received the SQL that creates INSTEAD OF trigger, connect database interface, create a database connection object, relational database is carried out and is created INSTEAD OF trigger SQL, the result is returned to first connector, and first connector is passed to first central control unit with message; Otherwise if first connector is overtime, then first central control unit sends an error message, and flow process finishes;
S210: first central control unit is received the message that INSTEAD OF trigger is created;
S211: first central control unit sends closing information to first connector, closes new establishment database connection object by first connector by database interface, sends the completed information of initialization simultaneously, and this flow process finishes.
As the further improvement of a kind of data access method technical scheme based on view of the present invention, comprise complex view component object data acquisition based on the data access method of view, this process may further comprise the steps:
S301:, then carry out the initialization flow process earlier if the view component object does not carry out initialization;
S302: first central control unit sends data to SQL operation maker and obtains information;
S303: SQL operation maker receives that data obtain information, and the data getattr of object is sent to first connector;
S304: after first connector connects database interface, create a database connection object, relational database is carried out a select and is obtained data on the view that component object relied on, and the result is returned to first connector, and first connector is passed to first central control unit with data set; Otherwise if first connector is overtime, then first central control unit sends an error message, and flow process finishes;
S305: after first central control unit is received data set, send message, close the database connection object of new establishment by first connector by database interface to first connector;
S306: first central control unit is to interface assembly object Data transmission, interface assembly object refresh data, notify the user after, this flow process finishes.
As the further improvement of a kind of data access method technical scheme based on view of the present invention, comprise complex view component object data deletion process based on the data access method of view, this process may further comprise the steps:
S401: the initial work flow process of carrying out object earlier;
S402: first central control unit is deletion work from the concrete operations determined property, then sends deletion information to SQL operation maker;
S403: SQL operation maker receives deletion information, at first obtains the parent table attribute according to the public attribute collection, and secondly the physics table of determination component object is multilist or single table, if single table is then directly carried out S406; If multilist, then SQL operation maker generates a SQL who obtains parent table master external key, sends to first connector;
S404: first connector is created a database connection object after connecting database interface, and relational database is carried out the SQL that obtains parent table master external key, and the result is returned to first connector, and first connector is passed to first central control unit with message; Otherwise if first connector is overtime, then first central control unit sends an error message, and flow process finishes;
S405: first central control unit is received the main foreign key information of parent table, close the database connection object of new establishment by the first connector notification data bank interface, simultaneously main foreign key information is write the set of first public attribute, write finish after, first central control unit sends main external key to SQL operation maker and successfully obtains information;
S406: SQL operation maker calls the first dynamic sql assembly unit maker and public attribute set, generates the deletion SQL of an operation parent table, realizes the information deletion of single table or multilist;
S407: first connector is created a database connection object after connecting database interface, and relational database is carried out the deletion SQL of an operation parent table, and the result is returned to first connector, and first connector is passed to first central control unit with message; Otherwise if first connector is overtime, then first central control unit sends an error message, and flow process finishes;
S408: first central control unit is received deletion action message, closes the database connection object of new establishment by the first connector notification data bank interface, sends the information of obtaining to SQL operation maker simultaneously;
S409: after the data of executive module object were obtained flow process, flow process finished.
As the further improvement of a kind of data access method technical scheme based on view of the present invention, comprise that based on the data access method of view complex view component object data increase and modification process, this process may further comprise the steps:
S501: the initial work flow process of first executive module object;
S502: first central control unit is to increase datamation or revise datamation from the concrete operations determined property, then sends increase information to SQL operation maker;
S503: SQL operation maker receives increase information, produces one by the first dynamic sql assembly unit maker and is relied on the insertion statement of operating on the view at component object, realizes increasing data and revises datamation, the renewal of realization view;
S504: first connector is created a database connection object after connecting database interface, and relational database is carried out and inserted statement, and the result is returned to first connector, and first connector is passed to first central control unit with message; Otherwise if first connector is overtime, then first central control unit sends an error message, and flow process finishes;
S505: first central control unit is received the insertion operation information, closes the database connection object of new establishment by the first connector notification data bank interface, sends the information of obtaining to SQL operation maker simultaneously;
S506: after the data of executive module object were obtained flow process, flow process finished.
As the further improvement of a kind of data access method technical scheme based on view of the present invention, comprise simple view component object initialization procedure based on the data access method of view, this process may further comprise the steps:
S601: the user message that second central control unit will comprise concrete operations message attributes, XML mapped file path attribute, XML Profile Path attribute, object identity attribute, obtain the Data Identification attribute, obtain the query condition value of data writes the public attribute of component object respectively and concentrates;
S602: second central control unit finds the XML mapped file according to the XML mapped file path attribute of component object, secondly in the XML mapped file, realize the location according to the object identity attribute, find corresponding data block, second central control unit begins that data block is carried out XML and resolves work, and the public attribute that physics table name, Table Properties etc. is write object is concentrated;
S603: second central control unit sends to the 2nd SQL operation maker and obtains the Data Identification attribute message, call the second dynamic sql assembly unit maker and select query statement of the dynamic generation of second public attribute set by the 2nd SQL operation maker, the 2nd SQL operation maker returns to second central control unit with select query statement message, and second central control unit writes the select query statement obtaining in the data attribute of object again;
S604: second central control unit sends Query Database view message to the 2nd SQL operation maker, call the second dynamic sql assembly unit maker and second public attribute by the 2nd SQL operation maker and gather the SQL whether view that dynamic generation component object relied on exists, and send to second connector;
S605: second connector is created a database connection object after connecting database interface, and relational database is carried out the SQL whether the inquiry view exists, and the result is returned to second connector, and second connector is passed to second central control unit with message; Otherwise if second connector is overtime, then second central control unit sends an error message, and flow process finishes;
S606: second central control unit is received the message of second connector, if view exists, and then direct execution in step S609; Otherwise second connector cuts out new establishment database connection object by database interface, second central control unit sends to the second view maker and creates view message simultaneously, the interface of the second view maker obtains the relational database type according to the XML configuration file, select corresponding relational database view formation component, this component call second dynamic sql assembly unit maker and the set of second public attribute dynamically produce a SQL who creates view, and this SQL is sent to second connector;
S607: second connector is received the SQL that creates view, connects database interface, creates a database connection object, and relational database is carried out and created view SQL, and the result is returned to second connector, and second connector is passed to second central control unit with message; Otherwise if second connector is overtime, then second central control unit sends an error message, and flow process finishes;
S608: second central control unit is received the message that view is created;
S609: second central control unit sends closing information to second connector, closes new establishment database connection object by second connector by database interface, sends the completed information of initialization simultaneously, and this flow process finishes.
As the further improvement of a kind of data access method technical scheme based on view of the present invention, comprise simple view component object data deletion process based on the data access method of view, this process may further comprise the steps:
S701: the initial work flow process of first executive module object;
S702: second central control unit is deletion work from the concrete operations determined property, then sends deletion information to the 2nd SQL operation maker;
S703: the 2nd SQL operation maker receives deletion information, calls the set of the second dynamic sql assembly unit maker and second public attribute, generates one at the deletion SQL that relies on the enterprising line operate of view, realizes information deletion;
S704: second connector is created a database connection object after connecting database interface, and relational database is carried out the deletion SQL that an operation relies on view, and the result is returned to second connector, and second connector is passed to second central control unit with message; Otherwise if connector is overtime, then second central control unit sends an error message, and flow process finishes;
S705: second central control unit is received deletion action message, closes the database connection object of new establishment by the second connector notification data bank interface, sends the information of obtaining to the 2nd SQL operation maker simultaneously;
S706: after the data of executive module object were obtained flow process, flow process finished.
Described a kind of by using the invention described above embodiment based on the data access system of view and the technical scheme of method thereof, reached following technique effect:
(1) utilizes XML configuration file and XML mapped file to generate dynamic sql, the SQL code in source code file, do not occur, realize of the mapping of MDAC object relational database; (2) be simple and easy to usefulness concerning the operator, the quantities that provides share service to reduce the developer effectively simultaneously can shorten the whole construction cycle; (3) developer needs only the table definition in acquaint with data storehouse, and view definition is by the MDAC Object Operations.View in the database is transparent to the developer; (4) developer is when configuration XML mapped file, according to treaty rule, as long as the physics table in the configuration database, need not be concerned about the data source of actual generation.
Description of drawings
In order to be illustrated more clearly in the embodiment of the invention or technical scheme of the prior art, to do to introduce simply to the accompanying drawing of required use in embodiment or the description of the Prior Art below, apparently, accompanying drawing in describing below only is some embodiments of the present invention, for those of ordinary skills, under the prerequisite of not paying creative work, can also obtain other accompanying drawing according to these accompanying drawings.
Fig. 1 is that the described SQL code of 1 one kinds of embodiments of prior art is embedded in the data access system structural representation in the service class;
Fig. 2 sets up the data access system structural representation of independent data class for 2 one kinds of described service class of embodiment of prior art;
Fig. 3 sets up the data access system structural representation of shared data class for 3 one kinds of described service class of embodiment of prior art;
Fig. 4 is the described data access system fundamental diagram based on view of a kind of embodiment of the present invention;
Fig. 5 is the functional structure chart of the described data access system complex view assembly based on view of a kind of embodiment of the present invention;
Fig. 6 is the functional structure chart of the described data access system simple view assembly based on view of a kind of embodiment of the present invention;
Wherein, 1-interface assembly, 2-data access layer, the 3-database interface, 4-relational database link block, 5-relational database, 6-Object Creation assembly, 7-MDAC, 8-complex view assembly, 9-simple view assembly, 10-first central control unit, 11-the one SQL operates maker, the 12-first view maker, 13-INSTEAD OF trigger maker, the 14-first dynamic sql assembly unit maker, 15-first connector, the set of 16-first public attribute, 17-second central control unit, 18-the 2nd SQL operates maker, the 19-second view maker, the 20-second dynamic sql assembly unit maker, 21-second connector, the set of 22-second public attribute.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the invention, the technical scheme in the embodiment of the invention is clearly and completely described, obviously, described embodiment only is a part of embodiment of the present invention, rather than whole embodiment.Based on the embodiment among the present invention, those of ordinary skills belong to the scope of protection of the invention not making the every other embodiment that is obtained under the creative work prerequisite.
Shown in accompanying drawing 4,5,6, provided a kind of specific embodiment that is applied to the visit of computer information technology field database based on the data access system and the method thereof of view of the present invention, the invention will be further described below in conjunction with the drawings and specific embodiments.
The data access system that the present invention is based on view is complex view based on view with following view definition:
(1) view of use DISTINCT operational character in the SELECT statement;
(2) view of aggregate functions such as similar SUN of use or MAX;
(3) comprise GROUP BY, ORDER BY clause's view;
(4) view of use subquery in the SELECT tabulation;
(5) view of a plurality of tables of associating.
View except that complex view then is defined as simple view.
MDAC is divided into complex view assembly and simple view assembly by above-mentioned view classification.
The data access system based on view as shown in Figure 4 comprises: interface assembly 1, data access layer 2, database interface 3, relational database link block 4, relational database 5;
Interface assembly 1 links to each other with data access layer 2, and sends user message to data access layer 2;
Data access layer 2 comprises Object Creation assembly 6 and MDAC 7, and the Object Creation assembly 6 of data access layer 2 is created MDAC 7, and MDAC 7 comprises complex view assembly 8 and simple view assembly 9;
MDAC 7 produces the SQL action statement, and MDAC 7 is connected with database interface 3, obtains database information by the XML configuration file, obtains database connection object simultaneously;
Database interface 3 links to each other with relational database link block 4, by relational database link block 4 the SQL action statement is passed to relational database 5, relational database 5 is carried out the SQL action statement, and the defined query statement of data attribute that obtains in the MDAC object is passed to relational database 5, relational database 5 by relational database link block 4) carry out query statement;
Relational database link block 4 is given MDAC 7 according to query statement with the data transmission of being returned;
MDAC 7 transfers to interface assembly 1 with the data source of obtaining and shows, interface assembly 1 refresh data, and notify the user.
The fundamental diagram of Fig. 4 has illustrated a kind of work structuring of the data access method based on view techniques, and its course of work is as follows:
S101: interface assembly 1 sends user message to data access layer 2, this message comprises concrete operation information operations such as (for example insert) deletions, path, MDAC object identity, the MDAC of view component type identification (complex view assembly or simple view assembly), XML (Extensible Markup Language, XML (extensible Markup Language)) mapped file and XML configuration file obtain Data Identification etc.;
S102: the Object Creation assembly of data access layer 2 is created a data access component object (complex view component object or simple view component object) according to the view component sign, and finish the initial work of MDAC object, this part work mainly is to finish work such as analyzing XML mapped file, establishment view, and internal mechanism sees the initial work flow process of following complex view assembly and simple view assembly for details;
S103: the MDAC object is finished initial work according to the type of complex view assembly 8 or simple view assembly 9, and according to the operation information attribute, if data are obtained, then carries out data acquisition; If data deletion is then carried out the data delete procedure; If data increase or revise, then carrying out data increases or modification process, produces a SQL action statement (for example delete statement) by MDAC 7 at last;
S104: the MDAC object connects database interface 3, obtains related data library information (as certain type of relationship database, database name, IP address etc.) by the XML configuration file, obtains a database connection object by static factory mode;
S105: by database connection object the SQL action statement is passed to relational database 5, relational database 5 is carried out the SQL action statement;
S106: by database connection object the defined query statement of data attribute that obtains in the MDAC object is passed to relational database 5, relational database 5 is carried out query statement;
S107: database connection object is passed to the MDAC object according to query statement with the data of being returned, and behind the complete operation, this database connection object is closed;
S108: the MDAC object offers the interface assembly object with the data source of obtaining and shows, this MDAC object of system-kill;
S109: interface assembly object refresh data, and notify the user.
Wherein, complex view assembly as shown in Figure 5 further comprises first central control unit 10, SQL operation maker 11, the first view maker 12, INSTEAD OF trigger maker 13, the first dynamic sql assembly unit maker 14, first connector 15, first public attribute set 16.Each functions of components structure is described as follows shown in the table 1 in the complex view assembly.
First central control unit 10 receives user message, return user data or information, the analyzing XML mapped file also writes first public attribute set 16, send action message to SQL operation maker 11, the first view maker 12, INSTEAD OF trigger maker 13, and receive SQL operation maker 11, the first view maker 12, the message of INSTEAD OF trigger maker 13 and the return results of relational database 5;
The one SQL operation maker 11 generates SQL, and is sent to relational database 5 by first connector 15 and database interface 3;
The first view maker 12 is created the dynamic sql that assembly relies on view (view that component object is created according to mapped file, module data operates on this view and carries out) according to different relational database 5;
INSTEAD OF trigger maker 13 is created a dynamic sql that relies on the INSTEAD OF trigger of operating on the view at assembly according to different relational database 5;
The first dynamic sql assembly unit maker 14 carries out the assembly unit of SQL according to the public attribute value of first public attribute set, 16 outputs, realizes dynamic sql;
First connector 15 is connected with database interface 3;
First public attribute set, 16 storages are from the relevant information of the analyzing XML mapped file of first central control unit 10.
The functional structure explanation of table 1 complex view assembly
The complex view component object is carried out initial work process, deleted data, increase data, is revised data and obtain the datamation process, below is introduced respectively.
1, the initial work process of complex view component object is as follows:
S201: first central control unit 10 writes user message respectively in the public attribute set of component object, comprises concrete operations message attributes operations such as (for example insert) deletions, XML mapped file path attribute, XML Profile Path attribute, object identity attribute, obtains the Data Identification attribute.If user message also comprises the query condition value of obtaining data, also write public attribute and concentrate;
S202: first central control unit 10 finds the XML mapped file according to the XML mapped file path attribute of component object, secondly realizes the location according to the object identity attribute in the XML mapped file, finds corresponding data block.First central control unit 10 begins that data block is carried out XML and resolves work, and the public attribute that physics table name, Table Properties etc. is write object is concentrated;
S203: first central control unit 10 is operated maker 11 transmissions to a SQL and is obtained the Data Identification attribute message, calls the first dynamic sql assembly unit maker 14 and select query statement of first public attribute set, 16 dynamic generations by SQL operation maker 11.The one SQL operation maker 11 returns to first central control unit, 10, the first central control units 10 with select query statement message and the select query statement is write obtaining in the data attribute of object again;
S204: first central control unit 10 sends Query Database view message to SQL operation maker 11, call the dynamically SQL that whether exists of the view that relied on of generation component object of the first dynamic sql assembly unit maker 14 and first public attribute set, 16 (according to the physics table names) by SQL operation maker 11, and send to first connector 15;
S205: after first connector 15 connects database interface 3, create a database connection object, relational database 5 is carried out the SQL whether the inquiry view exists, and the result is returned to first connector, 15, the first connectors 15 message is passed to first central control unit 10; Otherwise if first connector 15 is overtime, then first central control unit 10 sends an error message, and flow process finishes;
S206: first central control unit 10 is received the message of first connector 15, if view exists, and then direct execution in step S211; Otherwise first connector 15 cuts out new establishment database connection object by database interface 3, and first central control unit 10 sends to the first view maker 12 and creates view message simultaneously.The interface of the first view maker 12 obtains relational database type (as oracle, sqlserver etc.) according to the XML configuration file, selects certain relational database view formation component.This component call first dynamic sql assembly unit maker 14 and first public attribute set 16 dynamically produce a SQL who creates view, and this SQL is sent to first connector 15;
S207: first connector 15 is received the SQL that creates view, connect database interface 3, create a database connection object, relational database 5 is carried out and is created view SQL, the result is returned to first connector, 15, the first connectors 15 message is passed to first central control unit 10; Otherwise if first connector 15 is overtime, then first central control unit 10 sends an error message, and flow process finishes;
S208: first central control unit 10 is received the message that view is created, and closes the database connection object of new establishment by first connector 15 by database interface 3, sends to INSTEAD OF trigger maker 13 simultaneously and creates INSTEAD OF trigger message.The interface of INSTEAD OF trigger maker 13 obtains relational database type (as oracle, sqlserver etc.) according to the XML configuration file, selects certain relational database INSTEAD OF trigger formation component.This component call first dynamic sql assembly unit maker 14 and first public attribute set 16 dynamically produce a SQL who generates INSTEAD OF trigger, and this SQL is sent to first connector 15;
S209: first connector 15 is received the SQL that creates INSTEAD OF trigger, connect database interface 3, create a database connection object, relational database 5 is carried out and is created INSTEAD OF trigger SQL, the result is returned to first connector, 15, the first connectors 15 message is passed to first central control unit 10; Otherwise if first connector 15 is overtime, then first central control unit 10 sends an error message, and flow process finishes;
S210: first central control unit 10 is received the message that INSTEAD OF trigger is created;
S211: first central control unit 10 sends closing information to first connector 15, closes new establishment database connection object by first connector 15 by database interface 3, sends the completed information of initialization simultaneously, and this flow process finishes.
2, the complex view component object to obtain the datamation flow process as follows:
S301:, then carry out the initialization flow process earlier if the view component object does not carry out initialization;
S302: first central control unit 10 sends data to SQL operation maker 11 and obtains information;
S303: SQL operation maker 11 receives that data obtain information, and the data getattr of object is sent to first connector 15;
S304: after first connector 15 connects database interface 3, create a database connection object, relational database 5 is carried out a select and is obtained data on the view that component object relied on, and the result is returned to first connector, 15, the first connectors 15 data set is passed to first central control unit 10; Otherwise if first connector 15 is overtime, then first central control unit 10 sends an error message, and flow process finishes;
S305: after first central control unit 10 is received data set, send message, close the database connection object of new establishment by first connector 15 by database interface 3 to first connector 15;
S306: first central control unit 10 is to interface assembly object Data transmission, interface assembly object refresh data, notify the user after, this flow process finishes.
3, deleted data work, the flow process of complex view component object are as follows:
S401: the initial work flow process of carrying out object earlier;
S402: first central control unit 10 is deletion work from the concrete operations determined property, then sends deletion information to SQL operation maker 11;
S403: SQL operation maker 11 receives deletion information, at first obtains the parent table attribute according to the public attribute collection, and secondly the physics table of determination component object is multilist or single table, if single table is then directly carried out S406; If (multilist adopts main foreign key reference to multilist, main external key is set during the database initialize table, in definition on delete cascade option is set during external key and realizes the data deletion of being correlated with), then SQL operation maker 11 generates a SQL who obtains parent table master external key, sends to first connector 15;
S404: after first connector 15 connects database interface 3, create a database connection object, relational database 5 is carried out the SQL that obtains parent table master external key, the result is returned to first connector, 15, the first connectors 15 message is passed to first central control unit 10; Otherwise if first connector 15 is overtime, then first central control unit 10 sends an error message, and flow process finishes;
S405: first central control unit 10 is received the main foreign key information of parent table, closes the database connection object of new establishment by first connector, 15 notification data bank interfaces, simultaneously main foreign key information is write the public attribute collection after.Write finish after, first central control unit 10 sends main external key to SQL operation maker and successfully obtains information;
S406: SQL operation maker 11 calls the first dynamic sql assembly unit maker 14 and first public attribute set 16, generates the deletion SQL of an operation parent table, realizes the information deletion of single table or multilist;
S407: after first connector 15 connects database interface 3, create a database connection object, relational database 5 is carried out the deletion SQL of an operation parent table, the result is returned to first connector, 15, the first connectors 15 message is passed to first central control unit 10; Otherwise if first connector 15 is overtime, then first central control unit 10 sends an error message, and flow process finishes;
S408: first central control unit 10 is received deletion action message, closes the database connection object of new establishment by first connector, 15 notification data bank interfaces 3, sends the information of obtaining to SQL operation maker 11 simultaneously;
S409: after the data of executive module object were obtained flow process, flow process finished.
4, the increase data of complex view component object and modification datamation flow process are as follows:
S501: the initial work flow process of carrying out object earlier;
S502: first central control unit 10 is to increase datamation or revise datamation from the concrete operations determined property, then sends increase information to SQL operation maker 11;
S503: SQL operation maker 11 receives increase information, produces one by the first dynamic sql assembly unit maker 14 and is relied on insertion (insert) statement of operating on the view at component object.Owing in the component object initialization, on the dependence view, created an INSTEAD OF trigger, insert (insert) statement and can realize increasing data simultaneously and revise datamation, realize view update;
S504: after first connector 15 connects database interface 3, create a database connection object, relational database 5 is carried out and is inserted (insert) statement, the result is returned to first connector, 15, the first connectors 15 message is passed to first central control unit 10; Otherwise if first connector 15 is overtime, then first central control unit 10 sends an error message, and flow process finishes;
S505: first central control unit 10 is received the insertion operation information, closes the database connection object of new establishment by first connector, 15 notification data bank interfaces 3, sends the information of obtaining to SQL operation maker 11 simultaneously;
S506: after the data of executive module object were obtained flow process, flow process finished.
Simple view assembly as shown in Figure 6 further comprises second central control unit 17, the 2nd SQL operation maker 18, the second view maker 19, the second dynamic sql assembly unit maker 20, second connector 21, second public attribute set 22;
Second central control unit 17 receives user message, return user data or information, the analyzing XML mapped file also writes the public attribute set, and, receive the 2nd SQL operation maker 18 and the message of the second view maker 19 and the return results of database to the 2nd SQL operation maker 18 and the second view maker, 19 transmission action messages;
The 2nd SQL operation maker 18 generates SQL, and is sent to relational database 5 by second connector 21 and database interface 3;
The second view maker 19 is created the dynamic sql that assembly relies on view according to different relational database 5;
The second dynamic sql assembly unit maker 20 carries out the assembly unit of SQL according to the public attribute value of second public attribute set, 22 outputs, realizes dynamic sql;
Second connector 21 is connected with database interface 3;
Second public attribute set, 22 storages are from the relevant information of the analyzing XML mapped file of second central control unit 17.
The simple view component object is carried out initial work process, deleted data, increase data, is revised data and obtain the datamation process, below is introduced respectively.
5, the initial work flow process of simple view component object is as follows:
S601: second central control unit 17 is concentrated the public attribute that user message writes component object respectively, comprises concrete operations message attributes operations such as (for example insert) deletions, XML mapped file path attribute, XML Profile Path attribute, object identity attribute, obtains the Data Identification attribute.If user message also comprises the query condition value of obtaining data, also write public attribute and concentrate;
S602: second central control unit 17 finds the XML mapped file according to the XML mapped file path attribute of component object, secondly realizes the location according to the object identity attribute in the XML mapped file, finds corresponding data block.Second central control unit 17 begins that data block is carried out XML and resolves work, and the public attribute that physics table name, Table Properties etc. is write object is concentrated;
S603: second central control unit 17 is operated maker 18 transmissions to the 2nd SQL and is obtained the Data Identification attribute message, calls the second dynamic sql assembly unit maker 20 and select query statement of second public attribute set, 22 dynamic generations by the 2nd SQL operation maker 18.The 2nd SQL operation maker 18 returns to second central control unit, 17, the second central control units 17 with select query statement message and the select query statement is write obtaining in the data attribute of object again;
S604: second central control unit 17 sends Query Database view message to the 2nd SQL operation maker 18, call the dynamically SQL that whether exists of the view that relied on of generation component object of the second dynamic sql assembly unit maker 20 and second public attribute set, 22 (according to the physics table names) by the 2nd SQL operation maker 18, and send to second connector 21.
S605: after second connector 21 connects database interface 3, create a database connection object, relational database 5 is carried out the SQL whether the inquiry view exists, and the result is returned to second connector, 21, the second connectors 21 message is passed to second central control unit 17; Otherwise if second connector 21 is overtime, then second central control unit 17 sends an error message, and flow process finishes;
S606: second central control unit 17 is received the message of second connector 21, if view exists, and then direct execution in step S609; Otherwise second connector 21 cuts out new establishment database connection object by database interface 3, and second central control unit 17 sends to the second view maker 19 and creates view message simultaneously.The interface of the second view maker 19 obtains relational database type (as oracle, sqlserver etc.) according to the XML configuration file, selects certain relational database view formation component.This component call second dynamic sql assembly unit maker 20 and second public attribute set 22 dynamically produce a SQL who creates view, and this SQL is sent to second connector 21;
S607: second connector 21 is received the SQL that creates view, connect database interface 3, create a database connection object, relational database 5 is carried out and is created view SQL, the result is returned to second connector, 21, the second connectors 21 message is passed to second central control unit 17; Otherwise if second connector 21 is overtime, then second central control unit 17 sends an error message, and flow process finishes;
S608: second central control unit 17 is received the message that view is created;
S609: second central control unit 17 sends closing information to second connector 21, closes new establishment database connection object by second connector 21 by database interface 3, sends the completed information of initialization simultaneously, and this flow process finishes.
6, the datamation flow process of obtaining of simple view component object is obtained the datamation flow process with the complex view object.
7, the deleted data workflow of simple view component object is as follows:
S701: the initial work flow process of carrying out object earlier;
S702: second central control unit 17 is deletion work from the concrete operations determined property, then sends deletion information to the 2nd SQL operation maker 18;
S703: the 2nd SQL operation maker 18 receives deletion information, calls the second dynamic sql assembly unit maker 20 and second public attribute set 22, generates one at the deletion SQL that relies on the enterprising line operate of view, realizes information deletion;
S704: after second connector 21 connects database interface 3, create a database connection object, relational database 5 is carried out the deletion SQL that an operation relies on view, the result is returned to second connector, 21, the second connectors 21 message is passed to second central control unit 17; Otherwise if second connector 21 is overtime, then second central control unit 17 sends an error message, and flow process finishes;
S705: second central control unit 17 is received deletion action message, closes the database connection object of new establishment by second connector, 21 notification data bank interfaces 3, sends the information of obtaining to the 2nd SQL operation maker 18 simultaneously;
S706: after the data of executive module object were obtained flow process, flow process finished.
8, the increase data of simple view component object and modification datamation flow process are with the increase datamation and the modification datamation flow process of complex view object.
Wherein, in the structural design part of XML configuration file, adopt the XML formatted file to realize configuration, the attribute of configuration file is as follows:
(1) dbType: type of database (as Oracle);
(2) connect-server: server name;
(3) connect-dataBase: database name;
(4) connect-user: log database user name;
(5) connect-password: log database password;
Specific as follows:
<?xml?version=’1.0’encoding=’UTF-8’?>
<configuration>
<property name=" dbType " value (as sqlserver)</property 〉
<property name=" connection-server " value (as 192.168.0.1)</property 〉
<property name=" connection-dataBase " value (as EA)</property 〉
<property name=" connection-user " value (as sa)</property 〉
<property name=" connection-password " value (as sa)</property 〉
</configuration>
The structure of the XML mapped file of complex view assembly is as follows:
Figure BDA0000079922390000181
Aspect the structural design of XML mapped file, the XML mapped file of complex view assembly be defined as follows table 2.
The structural design instruction card of table 2 complex view assembly
It below is an instantiation of the XML mapped file of complex view assembly.
Figure BDA0000079922390000192
Figure BDA0000079922390000201
The structure of the XML mapped file of simple view assembly is as follows:
Figure BDA0000079922390000202
The XML mapped file structural design of simple view assembly is as shown in table 3 below:
Figure BDA0000079922390000211
The structural design instruction card of table 3 simple view assembly
It below is an example of the XML mapped file of simple view assembly.
Figure BDA0000079922390000212
By using embodiment of the present invention described a kind of data access system and method thereof, reached following technique effect based on view:
(1) utilizes XML configuration file and XML mapped file to generate dynamic sql, the SQL code in source code file, do not occur, realize of the mapping of MDAC object relational database;
(2) be simple and easy to usefulness, data access is finished following work as long as the developer adopts this method realization:
(a) XML configuration file and XML mapped file are set;
(b) attribute (as the path of XML mapped file, MDAC object name etc.) of MDAC object is set
(3) provide share service to reduce developer's quantities;
(4) developer needs only the table definition in acquaint with data storehouse, and view definition is by the MDAC Object Operations.View in the database is transparent to the developer;
(5) developer is when configuration XML mapped file, according to treaty rule, as long as the physics table in the configuration database, need not be concerned about the data source of actual generation.Comprise following any one situation:
(a) view of use DISTINCT operational character in the SELECT statement;
(b) view of aggregate functions such as similar SUN of use or MAX;
(c) comprise GROUP BY, ORDER BY clause's view;
(d) view of use subquery in the SELECT tabulation;
(e) view of a plurality of tables of associating.
(6) support multiple relational database, and provide interface to expand.
The above only is preferred embodiment of the present invention, is not the present invention is done any pro forma restriction.Though the present invention discloses as above with preferred embodiment, yet be not in order to limit the present invention.Any those of ordinary skill in the art, do not breaking away under the technical solution of the present invention scope situation, all can utilize the method and the technology contents of above-mentioned announcement that technical solution of the present invention is made many possible changes and modification, or be revised as the equivalent embodiment of equivalent variations.Therefore, every content that does not break away from technical solution of the present invention, according to technical spirit of the present invention to any simple modification that above embodiment did, be equal to replacements, equivalence changes and modify, all still belong in the scope that technical solution of the present invention protects.

Claims (10)

1. the data access system based on view is characterized in that, comprising: interface assembly (1), data access layer (2), database interface (3), relational database link block (4), relational database (5);
Interface assembly (1) links to each other with data access layer (2), and sends user message to data access layer (2);
Data access layer (2) comprises Object Creation assembly (6) and MDAC (7), the Object Creation assembly (6) of data access layer (2) is created MDAC (7), and MDAC (7) comprises complex view assembly (8) and simple view assembly (9);
MDAC (7) produces the SQL action statement, and MDAC (7) is connected with database interface (3), obtains database information by the XML configuration file, obtains database connection object simultaneously;
Database interface (3) links to each other with relational database link block (4), by relational database link block (4) the SQL action statement is passed to relational database (5), relational database (5) is carried out the SQL action statement, and the defined query statement of data attribute that obtains in the MDAC object being passed to relational database (5) by relational database link block (4), relational database (5) is carried out query statement;
Relational database link block (4) is given MDAC (7) according to query statement with the data transmission of being returned;
MDAC (7) transfers to interface assembly (1) with the data source of obtaining and shows, interface assembly (1) refresh data, and notify the user.
2. a kind of data access system based on view according to claim 1 is characterized in that: described complex view assembly (8) comprises first central control unit (10), SQL operation maker (11), the first view maker (12), INSTEAD OF trigger maker (13), the first dynamic sql assembly unit maker (14), first connector (15), first public attribute set (16);
First central control unit (10) receives user message, return user data or information, the analyzing XML mapped file also writes first public attribute set (16), send action message to SQL operation maker (11), the first view maker (12), INSTEADOF trigger maker (13), and receive SQL operation maker (11), the first view maker (12), the message of INSTEAD OF trigger maker (13) and the return results of relational database (5);
The one SQL operation maker (11) generates SQL, and is sent to relational database (5) by first connector (15) and database interface (3);
The first view maker (12) is created the dynamic sql that assembly relies on view according to different relational database (5);
INSTEAD OF trigger maker (13) is created a dynamic sql that relies on the INSTEAD OF trigger of operating on the view at assembly according to different relational database (5);
The first dynamic sql assembly unit maker (14) carries out the assembly unit of SQL according to the public attribute value of first public attribute set (16) output, realizes dynamic sql;
First connector (15) is connected with database interface (3);
First public attribute set (16) storage is from the relevant information of first central control unit (10) analyzing XML mapped file.
3. a kind of data access system based on view according to claim 2 is characterized in that: described simple view assembly (9) comprises second central control unit (17), the 2nd SQL operation maker (18), the second view maker (19), the second dynamic sql assembly unit maker (20), second connector (21), second public attribute set (22);
Second central control unit (17) receives user message, return user data or information, the analyzing XML mapped file also writes the public attribute set, and, receive the 2nd SQL operation maker (18) and the message of the second view maker (19) and the return results of database to the 2nd SQL operation maker (18) and the second view maker (19) transmission action message;
The 2nd SQL operation maker (18) generates SQL, and is sent to relational database (5) by second connector (21) and database interface (3);
The second view maker (19) is created the dynamic sql that assembly relies on view according to different relational database (5);
The second dynamic sql assembly unit maker (20) carries out the assembly unit of SQL according to the public attribute value of second public attribute set (22) output, realizes dynamic sql;
Second connector (21) is connected with database interface (3);
Second public attribute set (22) storage is from the relevant information of second central control unit (17) analyzing XML mapped file.
4. one kind is carried out the method for data access to arbitrary claim in the claim 1,2,3 is described based on the data access system of view, it is characterized in that, may further comprise the steps:
S101: interface assembly (1) sends to data access layer (2) and comprises that path, MDAC object identity, the MDAC of concrete operation information, view component type identification, XML mapped file and XML configuration file obtain the user message of Data Identification;
S102: the Object Creation assembly (6) of data access layer (2) is created a data access component object according to the view component sign, the MDAC object comprises complex view component object or simple view component object, and finishes the initial work of MDAC object;
S103: the MDAC object is finished initial work according to the type of complex view assembly (8) or simple view assembly (9), and according to the operation information attribute, if data are obtained, then carries out data acquisition; If data deletion is then carried out the data delete procedure; If data increase or revise, then carrying out data increases or modification process, produces a SQL action statement by MDAC (7) at last;
S104: the MDAC object connects database interface (3), obtains database information by the XML configuration file, obtains a database connection object simultaneously;
S105: relational database link block (4) passes to relational database (5) by database connection object with the SQL action statement, and relational database (5) is carried out the SQL action statement;
S106: relational database link block (4) passes to relational database (5) by database connection object with the defined query statement of data attribute that obtains in the MDAC object, and relational database (5) is carried out query statement;
S107: database connection object is passed to the MDAC object according to query statement with the data of being returned, and behind the complete operation, this database connection object is closed;
S108: the MDAC object offers the interface assembly object with the data source of obtaining and shows, this MDAC object of system-kill;
S109: interface assembly object refresh data, and notify the user.
5. a kind of data access method based on view according to claim 4 is characterized in that: described data access method based on view comprises complex view component object initialization procedure, and this process may further comprise the steps:
S201: first central control unit (10) writes user message respectively in the public attribute set of component object, comprises concrete operations message attributes, XML mapped file path attribute, XML Profile Path attribute, object identity attribute, obtains the Data Identification attribute or obtains the query condition value of data;
S202: first central control unit (10) finds the XML mapped file according to the XML mapped file path attribute of component object, in the XML mapped file, realize the location according to the object identity attribute, find corresponding data block, first central control unit (10) carries out XML to data block and resolves work, physics table name, Table Properties etc. is write in the public attribute set of object;
S203: first central control unit (10) sends to SQL operation maker (11) and obtains the Data Identification attribute message, calling the first dynamic sql assembly unit maker (14) and first public attribute by SQL operation maker (11) gathers (16) and dynamically produces a select query statement, the one SQL operation maker (11) returns to first central control unit (10) with select query statement message, and first central control unit (10) writes the select query statement obtaining in the data attribute of object again;
S204: first central control unit (10) sends Query Database view message to SQL operation maker (11), call the SQL whether view that the first dynamic sql assembly unit maker (14) and the dynamic generation component object of first public attribute set (16) relied on exists by SQL operation maker (11), and send to first connector (15);
S205: after first connector (15) connects database interface (3), create a database connection object, relational database (5) is carried out the SQL whether the inquiry view exists, and the result is returned to first connector (15), and first connector (15) is passed to first central control unit (10) with message; Otherwise if first connector (15) is overtime, then first central control unit (10) sends an error message, and flow process finishes;
S206: first central control unit (10) is received the message of first connector (15), if view exists, and then direct execution in step S211; Otherwise first connector (15) cuts out the database connection object of new establishment by database interface (3), first central control unit (10) sends to the first view maker (12) and creates view message simultaneously, the interface of the first view maker (12) obtains the relational database type according to the XML configuration file, select corresponding relational database view formation component, this component call first dynamic sql assembly unit maker (14) and first public attribute set (16) dynamically produce a SQL who creates view, and this SQL is sent to first connector (15);
S207: first connector (15) is received the SQL that creates view, connect database interface (3), create a database connection object, relational database (5) is carried out and is created view SQL, the result is returned to first connector (15), and first connector (15) is passed to first central control unit (10) with message; Otherwise if first connector (15) is overtime, then first central control unit (10) sends an error message, and flow process finishes;
S208: first central control unit (10) is received the message that view is created, close the database connection object of new establishment by database interface (3) by first connector (15), send to INSTEAD OF trigger maker (13) simultaneously and create the INSTEADOF trigger message, the interface of INSTEAD OF trigger maker (13) obtains the relational database type according to the XML configuration file, select corresponding relational database INSTEAD OF trigger formation component, this component call first dynamic sql assembly unit maker (14) and first public attribute set (16) dynamically produce a SQL who generates INSTEAD OF trigger, and this SQL is sent to first connector (15);
S209: first connector (15) is received the SQL that creates INSTEAD OF trigger, connect database interface (3), create a database connection object, relational database (5) is carried out and is created INSTEAD OF trigger SQL, the result is returned to first connector (15), and first connector (15) is passed to first central control unit (10) with message; Otherwise if first connector (15) is overtime, then first central control unit (10) sends an error message, and flow process finishes;
S210: first central control unit (10) is received the message that INSTEAD OF trigger is created;
S211: first central control unit (10) sends closing information to first connector (15), closes new establishment database connection object by first connector (15) by database interface (3), sends the completed information of initialization simultaneously, and this flow process finishes.
6. according to claim 4 or 5 described a kind of data access methods based on view, it is characterized in that: described data access method based on view comprises complex view component object data acquisition, and this process may further comprise the steps:
S301:, then carry out the initialization flow process earlier if the view component object does not carry out initialization;
S302: first central control unit (10) sends data to SQL operation maker (11) and obtains information;
S303: SQL operation maker (11) receives that data obtain information, and the data getattr of object is sent to first connector (15);
S304: after first connector (15) connects database interface (3), create a database connection object, relational database (5) is carried out a select and is obtained data on the view that component object relied on, and the result returned to first connector (15), first connector (15) is passed to first central control unit (10) with data set; Otherwise if first connector (15) is overtime, then first central control unit (10) sends an error message, and flow process finishes;
S305: after first central control unit (10) is received data set, send message, close the database connection object of new establishment by first connector (15) by database interface (3) to first connector (15);
S306: first central control unit (10) is to interface assembly object Data transmission, interface assembly object refresh data, notify the user after, this flow process finishes.
7. according to claim 4 or 5 described a kind of data access methods based on view, it is characterized in that: described data access method based on view comprises complex view component object data deletion process, and this process may further comprise the steps:
S401: the initial work flow process of carrying out object earlier;
S402: first central control unit (10) is deletion work from the concrete operations determined property, then sends deletion information to SQL operation maker (11);
S403: SQL operation maker (11) receives deletion information, at first obtains the parent table attribute according to the public attribute collection, and secondly the physics table of determination component object is multilist or single table, if single table is then directly carried out S406; If multilist, then SQL operation maker (11) generates a SQL who obtains parent table master external key, sends to first connector (15);
S404: after first connector (15) connects database interface (3), create a database connection object, relational database (5) is carried out the SQL that obtains parent table master external key, and the result is returned to first connector (15), and first connector (15) is passed to first central control unit (10) with message; Otherwise if first connector (15) is overtime, then first central control unit (10) sends an error message, and flow process finishes;
S405: first central control unit (10) is received the main foreign key information of parent table, close the database connection object of new establishment by first connector (15) notification data bank interface (3), simultaneously main foreign key information is write first public attribute set (16), write finish after, first central control unit (10) sends main external key to SQL operation maker (11) and successfully obtains information;
S406: SQL operation maker (11) calls the first dynamic sql assembly unit maker (14) and first public attribute set (16), generates the deletion SQL of an operation parent table, realizes the information deletion of single table or multilist;
S407: after first connector (15) connects database interface (3), create a database connection object, relational database (5) is carried out the deletion SQL of an operation parent table, and the result is returned to first connector (15), and first connector (15) is passed to first central control unit (10) with message; Otherwise if first connector (15) is overtime, then first central control unit (10) sends an error message, and flow process finishes;
S408: first central control unit (10) is received deletion action message, closes the database connection object of new establishment by first connector (15) notification data bank interface (3), sends the information of obtaining to SQL operation maker (11) simultaneously;
S409: after the data of executive module object were obtained flow process, flow process finished.
8. according to claim 4 or 5 described a kind of data access methods based on view, it is characterized in that: described data access method based on view comprises that complex view component object data increase and modification process, and this process may further comprise the steps:
S501: the initial work flow process of first executive module object;
S502: first central control unit (10) is to increase datamation or revise datamation from the concrete operations determined property, then sends increase information to SQL operation maker (11);
S503: SQL operation maker (11) receives increase information, produces one by the first dynamic sql assembly unit maker (14) and is relied on the insertion statement of operating on the view at component object, realizes increasing data and revises datamation, the renewal of realization view;
S504: after first connector (15) connects database interface (3), create a database connection object, relational database (5) is carried out and is inserted statement, and the result is returned to first connector (15), and first connector (15) is passed to first central control unit (10) with message; Otherwise if first connector (15) is overtime, then first central control unit (10) sends an error message, and flow process finishes;
S505: first central control unit (10) is received the insertion operation information, closes the database connection object of new establishment by first connector (15) notification data bank interface (3), sends the information of obtaining to SQL operation maker (11) simultaneously;
S506: after the data of executive module object were obtained flow process, flow process finished.
9. according to claim 4 or 5 described a kind of data access methods based on view, it is characterized in that: described data access method based on view comprises simple view component object initialization procedure, and this process may further comprise the steps:
S601: the user message that second central control unit (17) will comprise concrete operations message attributes, XML mapped file path attribute, XML Profile Path attribute, object identity attribute, obtain the Data Identification attribute, obtain the query condition value of data writes the public attribute of component object respectively and concentrates;
S602: second central control unit (17) finds the XML mapped file according to the XML mapped file path attribute of component object, secondly in the XML mapped file, realize the location according to the object identity attribute, find corresponding data block, second central control unit (17) begins that data block is carried out XML and resolves work, and the public attribute that physics table name, Table Properties etc. is write object is concentrated;
S603: second central control unit (17) sends to the 2nd SQL operation maker (18) and obtains the Data Identification attribute message, calling the second dynamic sql assembly unit maker (20) and second public attribute by the 2nd SQL operation maker (18) gathers (22) and dynamically produces a select query statement, the 2nd SQL operation maker (18) returns to second central control unit (17) with select query statement message, and second central control unit (17) writes the select query statement obtaining in the data attribute of object again;
S604: second central control unit (17) sends Query Database view message to the 2nd SQL operation maker (18), call the SQL whether view that the second dynamic sql assembly unit maker (20) and the dynamic generation component object of second public attribute set (22) relied on exists by the 2nd SQL operation maker (18), and send to second connector (21);
S605: after second connector (21) connects database interface (3), create a database connection object, relational database (5) is carried out the SQL whether the inquiry view exists, and the result is returned to second connector (21), and second connector (21) is passed to second central control unit (17) with message; Otherwise if second connector (21) is overtime, then second central control unit (17) sends an error message, and flow process finishes;
S606: second central control unit (17) is received the message of second connector (21), if view exists, and then direct execution in step S609; Otherwise second connector (21) cuts out new establishment database connection object by database interface (3), second central control unit (17) sends to the second view maker (19) and creates view message simultaneously, the interface of the second view maker (19) obtains the relational database type according to the XML configuration file, select corresponding relational database view formation component, this component call second dynamic sql assembly unit maker (20) and second public attribute set (22) dynamically produce a SQL who creates view, and this SQL is sent to second connector (21);
S607: second connector (21) is received the SQL that creates view, connect database interface (3), create a database connection object, relational database (5) is carried out and is created view SQL, the result is returned to second connector (21), and second connector (21) is passed to second central control unit (17) with message; Otherwise if second connector (21) is overtime, then second central control unit (17) sends an error message, and flow process finishes;
S608: second central control unit (17) is received the message that view is created;
S609: second central control unit (17) sends closing information to second connector (21), closes new establishment database connection object by second connector (21) by database interface (3), sends the completed information of initialization simultaneously, and this flow process finishes.
10. according to claim 4 or 5 described a kind of data access methods based on view, it is characterized in that: described data access method based on view comprises simple view component object data deletion process, and this process may further comprise the steps:
S701: the initial work flow process of first executive module object;
S702: second central control unit (17) is deletion work from the concrete operations determined property, then sends deletion information to the 2nd SQL operation maker (18);
S703: the 2nd SQL operation maker (18) receives deletion information, calls the second dynamic sql assembly unit maker (20) and second public attribute set (22), generates one at the deletion SQL that relies on the enterprising line operate of view, realizes information deletion;
S704: after second connector (21) connects database interface (3), create a database connection object, relational database (5) is carried out the deletion SQL that an operation relies on view, the result is returned to second connector (21), and second connector (21) is passed to second central control unit (17) with message; Otherwise if connector is overtime, then second central control unit (17) sends an error message, and flow process finishes;
S705: second central control unit (17) is received deletion action message, closes the database connection object of new establishment by second connector (21) notification data bank interface (3), sends the information of obtaining to the 2nd SQL operation maker (18) simultaneously;
S706: after the data of executive module object were obtained flow process, flow process finished.
CN 201110216880 2011-07-29 2011-07-29 View-based data access system and method Active CN102254029B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN 201110216880 CN102254029B (en) 2011-07-29 2011-07-29 View-based data access system and method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN 201110216880 CN102254029B (en) 2011-07-29 2011-07-29 View-based data access system and method

Publications (2)

Publication Number Publication Date
CN102254029A true CN102254029A (en) 2011-11-23
CN102254029B CN102254029B (en) 2013-06-19

Family

ID=44981293

Family Applications (1)

Application Number Title Priority Date Filing Date
CN 201110216880 Active CN102254029B (en) 2011-07-29 2011-07-29 View-based data access system and method

Country Status (1)

Country Link
CN (1) CN102254029B (en)

Cited By (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102567517A (en) * 2011-12-28 2012-07-11 用友软件股份有限公司 Device and method for issuing data of database
CN102609541A (en) * 2012-02-21 2012-07-25 德讯科技股份有限公司 SQL information acquisition auditing system based on MSSQL database
CN103488797A (en) * 2013-10-14 2014-01-01 德讯科技股份有限公司 MYSQL database-based SQL information acquisition and audit system
CN103530538A (en) * 2012-07-03 2014-01-22 沈阳高精数控技术有限公司 XML safety view querying method based on Schema
CN103577465A (en) * 2012-08-02 2014-02-12 亿赞普(北京)科技有限公司 System data processing system and method
CN103678446A (en) * 2012-09-04 2014-03-26 Sap股份公司 Improved schema mapping based on data views and database tables
CN104346334A (en) * 2013-07-23 2015-02-11 上海化工宝电子商务有限公司 Remote visual interface database system
CN105740286A (en) * 2014-12-11 2016-07-06 华为技术有限公司 Stored procedure processing method and device
CN106708967A (en) * 2016-11-30 2017-05-24 北京小米移动软件有限公司 Page display method and device
CN107193950A (en) * 2017-05-22 2017-09-22 环球智达科技(北京)有限公司 WEB data visualisation systems based on relational database
CN107729579A (en) * 2017-11-29 2018-02-23 武汉斗鱼网络科技有限公司 Database separate design method and device
CN110019215A (en) * 2017-10-26 2019-07-16 Sap欧洲公司 Key schema management in multiple lease database system
CN110442602A (en) * 2019-07-02 2019-11-12 新华三大数据技术有限公司 Data query method, apparatus, server and storage medium
US20210295220A1 (en) * 2018-02-27 2021-09-23 Logistiview, Inc. Execution systems using unstructured data
CN115203176A (en) * 2022-09-15 2022-10-18 太平金融科技服务(上海)有限公司深圳分公司 Database operation method, database operation device, database operation equipment, storage medium and program product

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101499070A (en) * 2008-02-02 2009-08-05 北京城市学院 History and real-time data access system and method based on open database interface
WO2011000745A1 (en) * 2009-07-01 2011-01-06 Thomson Licensing Method for accessing files of a file system according to metadata and device implementing the method
CN102063431A (en) * 2009-11-13 2011-05-18 郭承运 Information database system and access control method thereof

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101499070A (en) * 2008-02-02 2009-08-05 北京城市学院 History and real-time data access system and method based on open database interface
WO2011000745A1 (en) * 2009-07-01 2011-01-06 Thomson Licensing Method for accessing files of a file system according to metadata and device implementing the method
CN102063431A (en) * 2009-11-13 2011-05-18 郭承运 Information database system and access control method thereof

Cited By (21)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102567517A (en) * 2011-12-28 2012-07-11 用友软件股份有限公司 Device and method for issuing data of database
CN102609541A (en) * 2012-02-21 2012-07-25 德讯科技股份有限公司 SQL information acquisition auditing system based on MSSQL database
CN103530538A (en) * 2012-07-03 2014-01-22 沈阳高精数控技术有限公司 XML safety view querying method based on Schema
CN103530538B (en) * 2012-07-03 2016-05-18 沈阳高精数控技术有限公司 A kind of XML secured views querying method based on Schema
CN103577465A (en) * 2012-08-02 2014-02-12 亿赞普(北京)科技有限公司 System data processing system and method
CN103678446B (en) * 2012-09-04 2018-06-05 Sap欧洲公司 Improved mode map based on Data View and database table
CN103678446A (en) * 2012-09-04 2014-03-26 Sap股份公司 Improved schema mapping based on data views and database tables
CN104346334A (en) * 2013-07-23 2015-02-11 上海化工宝电子商务有限公司 Remote visual interface database system
CN103488797A (en) * 2013-10-14 2014-01-01 德讯科技股份有限公司 MYSQL database-based SQL information acquisition and audit system
CN105740286A (en) * 2014-12-11 2016-07-06 华为技术有限公司 Stored procedure processing method and device
CN105740286B (en) * 2014-12-11 2019-06-21 华为技术有限公司 A kind of storing process treating method and apparatus
CN106708967A (en) * 2016-11-30 2017-05-24 北京小米移动软件有限公司 Page display method and device
CN107193950A (en) * 2017-05-22 2017-09-22 环球智达科技(北京)有限公司 WEB data visualisation systems based on relational database
CN110019215A (en) * 2017-10-26 2019-07-16 Sap欧洲公司 Key schema management in multiple lease database system
CN110019215B (en) * 2017-10-26 2023-10-20 Sap欧洲公司 Key pattern management in a multi-tenancy database system
CN107729579A (en) * 2017-11-29 2018-02-23 武汉斗鱼网络科技有限公司 Database separate design method and device
CN107729579B (en) * 2017-11-29 2021-04-09 武汉斗鱼网络科技有限公司 Database separation design method and device
US20210295220A1 (en) * 2018-02-27 2021-09-23 Logistiview, Inc. Execution systems using unstructured data
US11741414B2 (en) * 2018-02-27 2023-08-29 Logistiview, Inc. Execution systems using unstructured data
CN110442602A (en) * 2019-07-02 2019-11-12 新华三大数据技术有限公司 Data query method, apparatus, server and storage medium
CN115203176A (en) * 2022-09-15 2022-10-18 太平金融科技服务(上海)有限公司深圳分公司 Database operation method, database operation device, database operation equipment, storage medium and program product

Also Published As

Publication number Publication date
CN102254029B (en) 2013-06-19

Similar Documents

Publication Publication Date Title
CN102254029B (en) View-based data access system and method
CN108874971B (en) Tool and method applied to mass tagged entity data storage
CN108027818B (en) Inquiry based on figure
CN100464329C (en) Construction method for dynamic structured query language statement
CN105849726B (en) For efficiently supporting the general index of the extemporaneous inquiry by demixing marking data
CN103631907B (en) A kind of method and system that relational data is migrated to HBase
CN102426582B (en) Data manipulation management devices and data manipulation management method
CN101493825B (en) GIS middleware collocation and management method
CN106126569A (en) A kind of rapid data method of servicing and system
CN103020158A (en) Report form creation method, device and system
CN101673287A (en) SQL sentence generation method and system
CN101794315A (en) Object relationship mapping model with fixed database schema
CN106933837A (en) A kind of database table model and creation method
US20100057764A1 (en) Building custom dimension trees
CN105447051A (en) Database operation method and device
US20120158807A1 (en) Matching data based on numeric difference
CN101853305A (en) Method for establishing comprehensive agricultural environmental information database
CN103914290A (en) Operating command processing method and device
CN102034152A (en) SOA (Service Oriented Architecture) based heterogeneous software system data integration method and system
CN104142930A (en) Universal Delta data loading technology
CN109902117A (en) Operation system analysis method and device
CN106155769A (en) A kind of workflow processing method, device and workflow engine
CN114328574A (en) Data query method and device, electronic equipment and computer-readable storage medium
CN104615713A (en) SQL executing method and device based on multiple database types
CN103246704A (en) Mapping method for describing entity and relational data based on conventional data structure

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CP01 Change in the name or title of a patent holder

Address after: 412001 Hunan Province, Zhuzhou Shifeng District Tian Xin era Road No. 169

Patentee after: ZHUZHOU CRRC TIMES ELECTRIC Co.,Ltd.

Address before: 412001 Hunan Province, Zhuzhou Shifeng District Tian Xin era Road No. 169

Patentee before: ZHUZHOU CSR TIMES ELECTRIC Co.,Ltd.

CP01 Change in the name or title of a patent holder
CP03 Change of name, title or address

Address after: 21, building 7, building 189, No. 410100, Renmin East Road, Changsha economic and Technological Development Zone, Hunan, Changsha

Patentee after: HUNAN CRRC TIMES SIGNAL & COMMUNICATION Co.,Ltd.

Address before: 412001 Hunan Province, Zhuzhou Shifeng District Tian Xin era Road No. 169

Patentee before: ZHUZHOU CRRC TIMES ELECTRIC Co.,Ltd.

CP03 Change of name, title or address