CN100535855C - Device and method for obtaining object-oriented model from relational database - Google Patents
Device and method for obtaining object-oriented model from relational database Download PDFInfo
- Publication number
- CN100535855C CN100535855C CNB200610080711XA CN200610080711A CN100535855C CN 100535855 C CN100535855 C CN 100535855C CN B200610080711X A CNB200610080711X A CN B200610080711XA CN 200610080711 A CN200610080711 A CN 200610080711A CN 100535855 C CN100535855 C CN 100535855C
- Authority
- CN
- China
- Prior art keywords
- information
- relational database
- oriented programming
- class
- object oriented
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Abstract
The invention relates to a device and method for obtaining object-oriented model from relation database, where the device comprises: relation database interface module, converting module connected with the relation database interface module, and object-oriented module interface module connected with the converting module; and the method comprises: inputting list information in the relation database; resolving the list information and obtaining class name information and attribute information and corresponding relation type and role information and outputting them. And the invention builds an intermediate layer between relation database and object-oriented model and generates object-oriented model according to the information in the database.
Description
Technical field
The present invention relates to a kind of device and method that from relational database, obtains object oriented programming model, particularly a kind of device and method that the table in the relational database is converted to OO class by the category information in the extraction relational database.
Background technology
At present, be extensive use of Object Oriented method and thinking designs and carry out business model, and store with relational database.The relational model that is adopted in the mechanism of Object-Oriented Design and the relational database is different, has caused not matching between Object-Oriented Design and the relational Database Design.
Object-Oriented Design is based on as coupling, polymerization, encapsulation scheduling theory, and relational model is based on mathematical principle, and the two is based on different theoretical foundation.Object model lays particular emphasis on and uses the object that comprises data and behavior to make up application program; Relational model then is primarily aimed at the storage in data.When seeking a kind of suitable method for visit data, this not matching just becomes principal contradiction: use object model, usually conduct interviews by relation between objects; Relational theory is then by the connection of table, the access of duplicating implementation data of ranks.This basic difference make two kinds of mechanism in conjunction with unsatisfactory.
The method that solves at present the visit of object oriented programming model and relational database comprise with object video certain lasting mechanism and to the simple change of relational database structure not influence surface to one persistent layer of object identification code.This method preferably resolves from the problem of object oriented programming model to relational database mapping, still, if from relational database, becomes object oriented programming model according to the structural framing of relational database, and this method is just powerless.
Summary of the invention
The objective of the invention is at above-mentioned the deficiencies in the prior art, a kind of device and method that obtains object oriented programming model from relational database is provided, between relational database and object oriented programming model, set up a middle layer, this middle layer has translation and explains the database function that meets specific standard, by this middle layer, generate object oriented programming model according to the information in the database.
For achieving the above object, the present invention proposes a kind of device that obtains object oriented programming model from relational database, this device comprises: the relational database interface module, and this relational database interface module is used for importing the table information of relational database; Modular converter, this modular converter is connected with described relational database interface module, the category information that to be used for described table information translation be object oriented programming model; The object oriented programming model interface module, this object oriented programming model interface module connects described modular converter, is used to export described category information.
The invention allows for a kind of method of from relational database, obtaining object oriented programming model, comprising following steps:
Table information in step 1, the input relational database;
Table name and field name information in step 2, the described table information of parsing are obtained class name information and attribute information;
Step 3, set up class hierarchy relation, and export described class hierarchy relation and attribute information according to described class name information;
Foreign key information in step 4, the described table information of parsing is obtained relationship type and Role Information in the described foreign key information, and is exported described relationship type and Role Information;
Step 5, end.
The present invention sets up a middle layer between relational database and object oriented programming model, by the explanation and the conversion in this middle layer, the table in the relational database can be converted to object oriented programming model.
The present invention is by setting up a middle layer, explanation and conversion between having realized from the relational database to the object oriented programming model.Because the basis that relational database is set up is a relational model, and the basis that object oriented programming model is set up is based on object-oriented method.Because both are based on different mathematical models, both can't directly change.Only can the English-speaking person can't exchange equally like the people of the literary composition that only can be right with one, at this moment just need a translation and finish convert task between the bilingual.And the role who is equivalent to translate has just been played the part of in the middle layer that the present invention describes, and making can intercommunication between relational database and the object oriented programming model.
Below by drawings and Examples, technical scheme of the present invention is described in further detail.
Description of drawings
Fig. 1 obtains the structural representation of preferred embodiment of the device of object oriented programming model from relational database for the present invention;
Fig. 2 obtains the structural representation of the better embodiment of relational database interface module in the device of object oriented programming model from relational database for the present invention;
Fig. 3 obtains the structural representation of the better embodiment of modular converter in the device of object oriented programming model from relational database for the present invention;
Fig. 4 obtains the structural representation of the better embodiment of object oriented programming model interface module in the device of object oriented programming model from relational database for the present invention;
Fig. 5 obtains the process flow diagram of preferred embodiment of the method for object oriented programming model from relational database for the present invention;
Fig. 6 is the process flow diagram of the better embodiment type identifier judged among Fig. 5;
Fig. 7 is the process flow diagram of the better embodiment that need judge class hierarchy among Fig. 5 or Fig. 6.
Embodiment
Fig. 1 obtains the structural representation of preferred embodiment of the device of object oriented programming model for the present invention from relational database, relational database interface module B1 is used for importing the table information of relational database A; Modular converter B2 is connected with described relational database interface module B1, the category information that to be used for described table information translation be object oriented programming model; Object oriented programming model interface module B3 connects described modular converter B2, is used to export described category information, obtains object oriented programming model C.
As shown in Figure 1, by the table information in the relational database interface module input relational database, to show the category information that information translation is an object oriented programming model by modular converter then, and again category information be exported by the object oriented programming model interface module, thereby obtained object oriented programming model C.
For the relational database interface module, the invention provides preferred implementation, as shown in Figure 2, the structure of the relational database interface module B1 that is connected with relational database A is: table name MIM message input module B11 is connected with described modular converter B2, is used for importing the table name information of described table information; Field information load module B12 is connected with described modular converter B2, is used for importing the field name information of described table information; Foreign key information load module B13 is connected with described modular converter B2, is used for importing the foreign key information of described table information.
For modular converter, the invention provides preferred implementation, as shown in Figure 3, the structure of the modular converter B2 that is connected with relational database interface module B1 is: table name information translation module B21 is connected with described object oriented programming model interface module B3, and the table name information translation that is used for described table information is described category information; Field information modular converter B22 is connected with described object oriented programming model interface module B3, and being used for the field name information translation with described table information is the attribute information of the class in the described category information; Foreign key information modular converter B23 is connected with described object oriented programming model interface module B3, is used for foreign key information with described table information and is converted to relation information in the described category information.
For the object oriented programming model interface module, the invention provides preferred implementation, as shown in Figure 4, the structure of the object oriented programming model interface module B3 that is connected with modular converter B2 is: category information output module B31 is connected with described modular converter B2, is used to export described category information; Generic attribute message output module B32 is connected with described modular converter B2, is used for exporting the attribute information of the class of described category information; Class relation information output module B33 is connected with described modular converter B2, is used for exporting the relation information between the class of described category information.
Among the present invention, the table name in the relational database includes: information such as type identifier, class name identifier, type name, the subscriber separation symbol separates therebetween.Wherein type identifier can be information such as class table identifier, multi-valued attribute table identifier, many-to-many relationship table identifier.If the type identifier that comprises in the table name is the multi-valued attribute table identifier, then also include information such as attribute-name identifier and attribute-name in the table name; If the type identifier in the table name is the many-to-many relationship table identifier, then also include more than one class name identifier and type name in the table name.Field name in the relational database includes information such as attribute-name identifier and attribute-name; For the table that includes class hierarchy, the field name of its field also includes information such as class name identifier and class name.Outer key name in the relational database includes information such as external key identifier, relationship type name, role name identifier and role name.
Fig. 5 is the present invention obtains the method for object oriented programming model from relational database the process flow diagram of preferred embodiment, specifically carries out following steps:
Table information in step 101, the input relational database.The present invention's preferred implementation of providing of step for this reason is the table information from relational database interface module input relational database;
Table name information and field name information in step 102, the described table information of parsing are obtained class name information and attribute information.The present invention's preferred implementation of providing of step for this reason is, resolves table name information and field name information the described table information from modular converter, obtains class name information and attribute information.Suppose that the table name in the table information is ClsTbl_Class_Student, field is called Class_Student-Class_CollegeStudent_Attr_Degree, then modular converter obtains parent class name Student and subclass class name CollegeStudent according to class name identifier Class and class name separator "-", and according to attribute-name identifier Attr getattr name Degree.
So just obtained having class and class hierarchy relation, obtained OO data structure from relational database.That is, realized that table from relational database is to the conversion of OO class.
When the type identifier in the table name is multi-valued attribute table identifier or many-to-many relationship table identifier, as shown in Figure 6, further comprise between step 101 and the step 102 among described Fig. 5:
Type identifier in table name is the class table identifier, but when the pairing table of this table name does not have the table that is associated, as shown in Figure 7, further comprises between step 102 and the step 103 among Fig. 5:
Class after the conversion and relation be by object oriented programming model interface output, and this method is by setting up a middle layer between relational database and object oriented programming model, realized that table from relational database is to the conversion of OO class.
It should be noted last that, above embodiment is only unrestricted in order to technical scheme of the present invention to be described, although the present invention is had been described in detail with reference to preferred embodiment, those of ordinary skill in the art is to be understood that, can make amendment or be equal to replacement technical scheme of the present invention, and not break away from the spirit and scope of technical solution of the present invention.
Claims (7)
1, a kind of device that obtains object oriented programming model from relational database is characterized in that comprising:
The relational database interface module, this relational database interface module is used for importing the table information of relational database;
Modular converter, this modular converter is connected with described relational database interface module, the category information that to be used for described table information translation be object oriented programming model;
The object oriented programming model interface module, this object oriented programming model interface module connects described modular converter, is used to export described category information.
2, the device that obtains object oriented programming model from relational database according to claim 1 is characterized in that described relational database interface module comprises:
The table name MIM message input module, this table name MIM message input module is connected with described modular converter, is used for importing the table name information of described table information;
The field information load module, this field information load module is connected with described modular converter, is used for importing the field name information of described table information;
The foreign key information load module, this foreign key information load module is connected with described modular converter, is used for importing the foreign key information of described table information.
3, the device that obtains object oriented programming model from relational database according to claim 1 and 2 is characterized in that described modular converter comprises:
Table name information translation module, this table name information translation module is connected with described object oriented programming model interface module, is used for table name information translation with described table information and is the class name information in the described category information;
The field information modular converter, this field information modular converter is connected with described object oriented programming model interface module, and being used for the field name information translation with described table information is the attribute information of the class in the described category information;
The foreign key information modular converter, this foreign key information modular converter is connected with described object oriented programming model interface module, is used for foreign key information with described table information and is converted to relation information in the described category information.
4, the device that obtains object oriented programming model from relational database according to claim 1 and 2 is characterized in that described object oriented programming model interface module comprises:
The category information output module, such message output module is connected with described modular converter, is used for exporting the class name information of described category information;
The generic attribute message output module, such attribute information output module is connected with described modular converter, is used for exporting the attribute information of the class of described category information;
Class relation information output module, such relation information output module is connected with described modular converter, is used for exporting the relation information between the class of described category information.
5, a kind of method of obtaining object oriented programming model from relational database is characterized in that may further comprise the steps:
Table information in step 1, the input relational database;
Table name and field name information in step 2, the described table information of parsing are obtained class name information and attribute information;
Step 3, set up class hierarchy relation, and export described class hierarchy relation and attribute information according to described class name information;
Foreign key information in step 4, the described table information of parsing is obtained relationship type and Role Information in the described foreign key information, and is exported described relationship type and Role Information;
Step 5, end.
6, the method for obtaining object oriented programming model from relational database according to claim 5 is characterized in that further comprising between described step 1 and the step 2:
Table name information in step 11, the described table information of parsing, and judge whether the type identifier in the described table name information is the class table identifier, if, execution in step 2, otherwise, execution in step 12;
Step 12, judge whether described type identifier is the multi-valued attribute table identifier, if, execution in step 13, otherwise, execution in step 14;
The attribute information of the class in step 13, the described table name information of extraction, and export described attribute information, execution in step 5;
Step 14, judge whether described type identifier is the many-to-many relationship table identifier, if, execution in step 15, otherwise, execution in step 5;
Step 15 is extracted the many-to-many relationship information in the described table name information, and exports described many-to-many relationship, execution in step 5.
7, according to claim 5 or the 6 described methods of from relational database, obtaining object oriented programming model, it is characterized in that further comprising between described step 2 and the step 3:
Step 21, judge in the described class name information whether have parent information, if, execution in step 3, otherwise, execution in step 22;
Step 22, with the output of described class name information, execution in step 4.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CNB200610080711XA CN100535855C (en) | 2006-05-12 | 2006-05-12 | Device and method for obtaining object-oriented model from relational database |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CNB200610080711XA CN100535855C (en) | 2006-05-12 | 2006-05-12 | Device and method for obtaining object-oriented model from relational database |
Publications (2)
Publication Number | Publication Date |
---|---|
CN101071371A CN101071371A (en) | 2007-11-14 |
CN100535855C true CN100535855C (en) | 2009-09-02 |
Family
ID=38898608
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CNB200610080711XA Active CN100535855C (en) | 2006-05-12 | 2006-05-12 | Device and method for obtaining object-oriented model from relational database |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN100535855C (en) |
Families Citing this family (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103699555A (en) * | 2013-07-03 | 2014-04-02 | 国电南瑞科技股份有限公司 | Multisource data real-time database data generation method applicable to scheduling and transformer substation integrated system |
CN107729330B (en) * | 2016-08-10 | 2020-12-29 | 创新先进技术有限公司 | Method and apparatus for acquiring data set |
CN107678806A (en) * | 2017-09-30 | 2018-02-09 | 北京酷我科技有限公司 | A kind of object type switchs to the method for type of database |
CN108920664B (en) * | 2018-07-05 | 2022-04-15 | 福建星瑞格软件有限公司 | Database intelligent index implementation method based on index value |
-
2006
- 2006-05-12 CN CNB200610080711XA patent/CN100535855C/en active Active
Also Published As
Publication number | Publication date |
---|---|
CN101071371A (en) | 2007-11-14 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN101145152B (en) | System and method for automatically refining reality in specific context | |
WO2016004733A1 (en) | Integrated system and method for figure/model/data of main distributed grid based on remote retrieval and information interaction | |
CN100535855C (en) | Device and method for obtaining object-oriented model from relational database | |
CN102779156B (en) | Configuration method for database of communication device in digital substation | |
CN104239406A (en) | High-visualization display method for secondary device configuration of intelligent substation | |
CN101464879B (en) | Method and system for implementing dynamic catalog based on regulation | |
CN106095404A (en) | A kind of business process model is to the automodel conversion method servicing composition model | |
CN103559189A (en) | Power simulation training resource management system and method based on metadata integration model | |
CN103150623A (en) | Cloud manufacture capacity service modeling method based on meta-model | |
CN104598606A (en) | Integration method aiming at dynamic heterogeneous spatial information plotting data | |
CN102722368B (en) | Plug-in software designing method based on document tree and message pump | |
CN102611197B (en) | Digital power monitoring system according with IEC61850 (Communication Networks and Systems in Substations) standard | |
CN101458711A (en) | Image describing and transforming method and system | |
CN113407681A (en) | Energy industry public data model construction method | |
CN105468793B (en) | A kind of automatic management method of simulation model data | |
CN107729561A (en) | The method that the table handling of paired data storehouse is reversely given birth to based on database table structure | |
CN105447645B (en) | Universal loading method for power dispatching heterogeneous service system model based on meta-model tree | |
Turnitsa et al. | Battle management language: A triangle with five sides | |
WO2021003843A1 (en) | Method for hierarchical and distributed coordinated control of time sequence for integrated energy system in industrial complex | |
CN108446145A (en) | A kind of distributed document loads MPP data base methods automatically | |
Wu et al. | Overview of CIM-oriented database design and data exchanging in power system applications | |
CN105550176A (en) | Basic mapping method for relational database and XML | |
CN105404741A (en) | Dynamic modeling method for intelligent electronic device of intelligent substation | |
CN101393554A (en) | Conversion method and device from IDL information to OWL information | |
Szulman et al. | Using ontology-based reference models in digital production engineering integration |
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 |