Summary of the invention
Technical matters to be solved by this invention provides a kind of graphic data base and its implementation, in order to solve the low technical matters of storage efficiency that relational database causes in the prior art when storing tree-shaped or netted data structure.
For solving the problems of the technologies described above, the embodiment of the invention provides a kind of graphic data base, comprising:
Information acquisition unit is used to obtain data message to be stored, and described data message to be stored comprises the relation information between nodal information and each node;
The data set interface unit is used for calling corresponding data structure according to described data message to be stored;
Storage unit is used for according to the form of described data structure described data to be stored being stored.
Preferably, described information acquisition unit comprises:
Node module is used to obtain the nodal information of described data to be stored, and described nodal information comprises definition information, attribute information and the data message of node;
Relationship module is used to obtain the relation information between each node, and described relation information comprises membership credentials and/or the adduction relationship between each node.
Preferably, described data set interface unit specifically comprises:
Read module is used to read the configuration file of described graphic data base, to obtain the type of actual storage unit;
Calling module, the type that is used for according to the storage unit of reality is the data structure that described data call to be stored need be satisfied.
Preferably, described storage unit specifically comprises:
Receiver module is used for obtaining data message to be stored and corresponding data structure information from the data set interface unit;
Memory module is used for according to described data structure information described data to be stored being saved to the tables of data of described reality.
Preferably, the type of described storage unit is specially relational database, can expands the file of programming language XML file or predefined format.
The embodiment of the invention also provides a kind of implementation method of graphic data base, comprising:
Information acquisition unit is obtained data message to be stored, and described data message to be stored comprises the relation information between nodal information and each node;
The data set interface unit calls corresponding data structure according to described data message to be stored;
Storage unit is stored described data to be stored according to the form of described data structure.
Preferably, describedly obtain data message to be stored, specifically comprise:
Obtain the nodal information of described data to be stored, described nodal information comprises definition information, attribute information and the data message of node;
Obtain the relation information between each node, described relation information comprises membership credentials and/or the adduction relationship between each node.
Preferably, describedly call corresponding data structure, specifically comprise according to described data message to be stored:
Read the configuration file of described graphic data base, to obtain the type of actual storage unit;
Type according to the storage unit of reality is the data structure that described data call to be stored need be satisfied.
Preferably, described form according to described data structure is stored described data to be stored, specifically comprises:
Obtain data message to be stored and corresponding data structure information from the data set interface unit;
According to described data structure information described data to be stored are saved in the tables of data of described reality.
Preferably, the type of described storage unit is specially relational database, can expands the file of programming language XML file or predefined format.
Compared with prior art, the present invention has the following advantages:
In the present embodiment, call corresponding data structure according to described data message to be stored, just can described data storage to be stored be advanced in the graphic data base according to the form of described data structure by unified data set interface.The embodiment of the invention can not cause storage efficiency low when storing tree-shaped or netted data structure yet, has improved the storage efficiency of data.
Embodiment
For above-mentioned purpose of the present invention, feature and advantage can be become apparent more, the present invention is further detailed explanation below in conjunction with the drawings and specific embodiments.
With reference to figure 1, show the block architecture diagram of a kind of graphic data base embodiment of the present invention, can comprise with lower unit:
Information acquisition unit 101 is used to obtain data message to be stored, and described data message to be stored comprises the relation information between nodal information and each node.
This information acquisition unit can adopt objects such as node or relation to realize in an embodiment.This information acquisition unit can get access to the relation information between nodal information and each node from the data to be stored that receive, wherein nodal information refers to the record entity information in the data such as tree-shaped or netted, can comprise definition information, attribute information or the data message etc. of node; And the relation information between each node can be the membership credentials between the different nodes, also can be the adduction relationship of a node to another node.
Data set interface unit 102 is used for calling corresponding data structure according to described data message to be stored.
Data set described in the present embodiment (DataSet) is the logic storage unit of data in the graphic data base, the logical definition of data in the graphic data base and graphic data base self all is stored among the DataSet, DataSet can think an interface, can call the configuration file of graphic data base by the data set interface, thus the data structure that the data message that obtains each node by configuration file need mate when storage.
Be understandable that each DataSet is made up of unique title and several row (Column) of the overall situation.Two kinds of data types as shown in table 1 are supported in tabulation in DataSet:
Table 1
Storage unit 103 is used for according to the form of described data structure described data to be stored being stored.
Call the data layout that obtains by the data set interface unit, can know which type of data layout is these data to be stored (relation information between each nodal information and the node) need satisfy when storing, and then carried out the storage of data to be stored according to this kind data layout by storage unit.Concrete, storage unit can adopt relational database, extend markup language (XML, Extensible Markup Language) or the file of user-defined format to realize in actual applications.
Can find out from above-mentioned introduction that the framework of the graphic data base in the embodiment of the invention can be divided into three layers from top to bottom.The superiors' corresponding informance acquiring unit 101 is the tissue and the realization of various conceptual objects in the graphic data base (for example node, concern or quote etc.); Middle layer corresponding data collection interface unit is abstract data physical store interface layer, is several DataSet with the data abstraction of physical store.And layer is then realized for physical store in bottom corresponding stored unit, can realize by present storage engines, for example: traditional relational database or XML file or the like.
Therefore with reference to figure 2, show graphic data base embodiment of the present invention layering synoptic diagram in actual applications.To each ingredient that illustrate among Fig. 2 be elaborated below.
In graphic data base, each record entity can abstractly be Node all, for example when applications of computer network system of statement, for the manufacturer of the network interface card of the port in the switch, PC server, CPU, production accessory, be provided the client of service, user in the system or authority or the like, can abstractly be Node.Each Node has title and some its distinctive attributes that the overall situation is unique, is used for recording configuration information.For example: for the client who is provided service, can be with the Node called after Customer of correspondence, Customer has following attribute: contractedAmount (contract total value), industry (affiliated industry), name (customer name), description (description) etc.In embodiments of the present invention, the attribute of Node specifically can be a data type as shown in table 2.
Table 2
For Node, Node information comprises definition information, attribute information and data message.Wherein, the definition information of each Node all can be kept at name and be called among the DataSet of graphic_db_node_def, and the data structure of this DataSet can be as shown in table 3:
Table 3 (graphic_db_node_def)
The row title |
Data type |
Explanation |
node_id |
?Number |
The ID that the overall situation is unique |
name |
?String |
Be used to preserve the title of Node |
Simultaneously, among each Node defined attribute information be kept at the name be called among the DataSet of graphic_db_node_attr_def, the data structure of this DataSet is as shown in table 4:
Table 4 (graphic_db_node_attr_def)
The data layout that data structure show in DataSet data to be stored need satisfy when storing, in esse tables of data is then different in storage unit.Be directed to the definition information of Node, in esse content in the storage unit then shown in table 5 and table 6:
Table 5
Table 6
On the other hand, the data message of each Node is kept among the DataSet of the same name with it, supposes to have a name to be called the Node of Customer, and the attribute information of this Node can be as shown in table 7:
Table 7
Property Name |
Data type |
Explanation |
RID |
String |
Database is built-in |
name |
String |
Customer name |
contractedAmount |
Number |
Contract value |
industry |
Reference |
Affiliated industry |
description |
String |
Client's descriptor |
This DataSet data layout that is called the Node correspondence of CustomerNode then can be as shown in table 8:
Table 8
Simultaneously, during actual storage, the database structure of its existence form correspondence is then as shown in table 9 in storage unit for this Node that is called CustomerNode:
Table 9
Need to prove that the field that occurs " RID " is a Record ID (Record ID), is used for the data recording of a Node of unique identification in above form.In graphic data base, all can there be a name to be called the attribute of RID when each Node is default, the RID value that is stored in each the bar data among the Node all is that the overall situation is unique, is recorded in sign in the graphic data base as this.The data type of RID is the String type, and each Node all contains this attribute.The RID form is specifically as follows: Node title+underscore+increase progressively numeral.For example, a typical R ID numerical value is similar to following form:
Industry_109
After node, also comprise relation at the object of the superiors of graphic data base.In actual applications, usually need Node is organized by certain logical relation, so relation (Relation) just is used for describing the membership credentials between the different Node, promptly Relation is used to describe the special object that concerns between the different Node.Suppose to have now to represent client's Node name to be called Customer, represent the Node name of system user to be called SysUser simultaneously, the Relation that so just can set up " SysUserServeCustomer " by name between SysUser and Customer explains both relations.With reference to shown in Figure 3, be the synoptic diagram that concerns between node SysUser and the Customer.
A title that the overall situation is unique is all arranged, a source Node, and a target Node in any one Relation.By the direction of source Node to target Node, can be referred to as forward, then can be called oppositely to the direction of initial Node by target Node.The definition information of Relation all can be kept at name and be called among the DataSet of graphic_db_relation_def, and the data structure of this DataSet can be as shown in table 10:
Table 10
The row title |
Data type |
Explanation |
?relation_id |
Number |
The ID that the overall situation is unique |
?name |
String |
Be used to preserve the title of Relation |
?source_node |
?Number |
The ID of source Node |
?target_node |
?Number |
The ID of target Node |
Be directed to the definition information of Relation, its when the storage unit actual storage in esse data then can reference table 11 shown in:
Table 11
Introduction according to above-mentioned Relation, can connect by the data among two Node of Relation connection, all link informations of data then can be kept at name and be called among the DataSet of graphic_db_relation_record_def, the data structure that when preserving, need satisfy can reference table 12 shown in:
Table 12
Relations I D be 201 data message in storage unit during actual storage the physics existence form of its tables of data then can reference table 13 shown in.
Table 13
In graphic data base, sometimes not all node all has relation between any two, also have only part of nodes and the related situation of other nodes, perhaps Chang Yong Node and other most of Node have relation, and these Node data volumes commonly used are limited and can not change substantially, for example: Node such as country, province or city.If adopt this moment the mode of Relation to explain, then need to set up big magnitude relation between these nodes and other Node, this loaded down with trivial details opening relationships process also can will cause certain difficulty and inefficiency to the maintenance in later stage.Under this kind situation, just can consider to adopt the form of quoting (Reference) to explain relation.A Node quotes another one Node by the attribute that it had, and is similar at its Foreign Key (external key) that realizes formal and RDBMS (relational database).Promptly be the RID that preserves data recording among the another one Node in the Dictionary attribute in a certain record.Suppose that the Node that is called Customer for name has this attribute of industry, and in the practical application scene, the quantity of industry is very limited, and can often change.Then can quote certain bar record among this Node of Industry with the mode of Reference attribute in actual applications.With reference to shown in Figure 4, dotted arrow is represented adduction relationship among the figure, promptly be that Customer has quoted Industry, and solid arrow is represented membership credentials, promptly is to have membership credentials between SysUser and the ServerCustomer.
More than be to the detailed introduction in actual applications of the disclosed graphic data base of the embodiment of the invention, the disclosed graphic data base of present embodiment is when storing tree-shaped and netted data structure, can realize data storage by unified data set interface unit, and when preserving, reality stores data according to the relation between each node, just reduce the complexity in the storing process, promoted storage efficiency.
With reference to figure 5, show the process flow diagram of the implementation method embodiment 1 of a kind of graphic data base of the present invention, can may further comprise the steps:
Step 501: obtain data message to be stored, described data message to be stored comprises the relation information between nodal information and each node.
Step 502: call corresponding data structure according to described data message to be stored.
Step 503: the form according to described data structure is stored described data to be stored.
With reference to figure 6, show the process flow diagram of the implementation method embodiment of a kind of graphic data base of the present invention, present embodiment can may further comprise the steps:
Step 601: obtain the nodal information of described data to be stored, described nodal information comprises definition information, attribute information and the data message of node.
Step 602: obtain the relation information between each node, described relation information comprises membership credentials and/or the adduction relationship between each node.
Step 603: read the configuration file of described graphic data base, to obtain the type of actual storage unit.
The configuration file of in store unique correspondence in graphic data base has write down the type of actual storage unit in this configuration file, for example, be relevant database or XML file, still predefined file etc.The data set interface unit calls the type that this configuration file can obtain storage engines, the data structure that needs satisfy in the time of further can determining the storage data according to the type of storage engines.
Step 604: the type according to the storage unit of reality is the data structure that described data call to be stored need be satisfied.
Step 605: obtain data message to be stored and corresponding data structure information from the data set interface unit.
Step 606: described data to be stored are saved in the tables of data of described reality according to described data structure information.
Need to prove, for aforesaid each method embodiment, for simple description, so it all is expressed as a series of combination of actions, but those skilled in the art should know, the present invention is not subjected to the restriction of described sequence of movement, because according to the present invention, some step can adopt other orders or carry out simultaneously.Secondly, those skilled in the art also should know, the embodiment described in the instructions all belongs to preferred embodiment, and related action and module might not be that the present invention is necessary.
Need to prove that each embodiment in this instructions all adopts the mode of going forward one by one to describe, what each embodiment stressed all is and the difference of other embodiment that identical similar part is mutually referring to getting final product between each embodiment.For system class embodiment, because it is similar substantially to method embodiment, so description is fairly simple, relevant part gets final product referring to the part explanation of method embodiment.
Need to prove, in this article, term " comprises ", " comprising " or its any other variant are intended to contain comprising of nonexcludability, thereby make and comprise that process, method, article or the equipment of a series of key elements not only comprise those key elements, but also comprise other key elements of clearly not listing, or also be included as this process, method, article or equipment intrinsic key element.Do not having under the situation of more restrictions, the key element that limits by statement " comprising ... ", and be not precluded within process, method, article or the equipment that comprises described key element and also have other identical element.
More than a kind of graphic data base provided by the present invention and its implementation are described in detail, used specific case herein principle of the present invention and embodiment are set forth, the explanation of above embodiment just is used for helping to understand method of the present invention and core concept thereof; Simultaneously, for one of ordinary skill in the art, according to thought of the present invention, the part that all can change in specific embodiments and applications, in sum, this description should not be construed as limitation of the present invention.