The content of the invention
It is an object of the invention to provide a kind of database separate design method, by carrying out separate design to database,
With cause on terminal device application program carry out modularization processing after, each component can shared data bank, and then improve
The operating characteristics of database.
Another object of the present invention is to provide a kind of database separate design device, set by carrying out separation to database
Meter, with cause on terminal device application program carry out modularization processing after, each component can shared data bank, Jin Erti
The operating characteristics of high database.
To achieve these goals, the technical scheme that the embodiment of the present invention uses is as follows:
In a first aspect, the embodiments of the invention provide a kind of database separate design method, it is described applied to terminal device
Multiple application programs are installed, each application program is made up of multiple components, and methods described includes on terminal device:Will wound
The same database file built is distributed in each component of the application program;Obtained according to the database file predefined
Database object;According to the function in the predefined database object invocation component to change the data in the component
Data in table.
Second aspect, the embodiment of the present invention additionally provide a kind of database separate design device, applied to terminal device, institute
State and multiple application programs are installed on terminal device, each application program is made up of multiple components, and described device includes:Point
Module is sent out, for the same database file of establishment to be distributed in each component of the application program;Object acquisition module,
For obtaining predefined database object according to the database file;Calling module, for according to the predefined number
According to the function in the object reference component of storehouse to change the data in the tables of data in the component.
A kind of database separate design method and device provided in an embodiment of the present invention, the database separate design method and
Device is applied to terminal device, and multiple application programs are provided with the terminal device, and each application program is made up of multiple components.
The database separate design method includes:The same database file of establishment is distributed to each component of the application program
In, predefined database object is obtained according to the database file, according in predefined database object invocation component
Function to change the data in the tables of data in the component.
In this programme, an application program is made up of multiple components, between multiple components independently of each other, it is impossible to mutually draw
With functional based method, and the corresponding database of an application program.By the way that the database file is distributed in each component, with
Each component is allowd to call database object to operate tables of data corresponding to the component, in other words, by by a data
Each tables of data in storehouse is distributed to each component, make it that multiple components in same application program can be with shared data
Storehouse, improve the performance of database.
To enable the above objects, features and advantages of the present invention to become apparent, preferred embodiment cited below particularly, and coordinate
Appended accompanying drawing, is described in detail below.
Embodiment
Below in conjunction with accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is carried out clear, complete
Ground describes, it is clear that described embodiment is only part of the embodiment of the present invention, rather than whole embodiments.Generally exist
The component of the embodiment of the present invention described and illustrated in accompanying drawing can be configured to arrange and design with a variety of herein.Cause
This, the detailed description of the embodiments of the invention to providing in the accompanying drawings is not intended to limit claimed invention below
Scope, but it is merely representative of the selected embodiment of the present invention.Based on embodiments of the invention, those skilled in the art are not doing
The every other embodiment obtained on the premise of going out creative work, belongs to the scope of protection of the invention.
It should be noted that:Similar label and letter represents similar terms in following accompanying drawing, therefore, once a certain Xiang Yi
It is defined, then it further need not be defined and explained in subsequent accompanying drawing in individual accompanying drawing.Meanwhile the present invention's
In description, term " first ", " second " etc. are only used for distinguishing description, and it is not intended that instruction or hint relative importance.
Fig. 1 is refer to, is a kind of schematic diagram of prior art provided in an embodiment of the present invention.In the prior art, install
In a single database in the application program on terminal device be present, because each functional module in application program does not have
Single area separates, and therefore, each functional module in same application program can directly obtain database and to the data
Storehouse carries out corresponding business processing, such as inquires about data, calls data, increase data, deletes data.In other words, existing
In technology, the functional module in same application program can share a database and can while the database be grasped
Make.Wherein, the functional module of same application program is the method for realizing some function of the application program and the set of attribute.
As can be seen here, application program is made up of multiple functional modules in scheme in the prior art, each functional module
Share a database so that degree of coupling is high between each functional module, may if one of functional module need to be changed
Need to change other functional modules simultaneously.
In order to reduce the degree of coupling between module, development efficiency is improved, modularization processing need to be carried out to application program, should
Modularization processing is that application program split into multiple widgets according to the difference of business function characteristic, between each component mutually
Isolation, and can not mutually be quoted between each component.It is readily appreciated that, after carrying out modularization processing to application program, due to each
Between individual component independently of each other, then degree of coupling is reduced, but due to independently of each other, then being needed as each group between each component
Part provides a database, in order to which each component can normal work.If each component provide a database, then with
Component increases, and database will also increase, and will greatly influence the operating characteristics of database.Thus, there is provided one kind is using journey
The method of Database vendors is extremely necessary in sequence, to realize when reducing inter-module degree of coupling, improves database
Operating characteristics.
Fig. 2 is refer to, is a kind of schematic flow sheet of database separate design method provided in an embodiment of the present invention, the number
It is applied to terminal device according to storehouse separate design method, the terminal device may be, but not limited to, the intelligence such as mobile phone, tablet personal computer
Electronic equipment.Multiple application programs are installed, each application program is made up of multiple components, this method bag on the terminal device
Include:
Step S110, the same database file of establishment is distributed in each component of the application program.
The system installed on a terminal device database shared by some application program is created, the data
Storehouse is a database file actually, and the database file includes database-name.System on the terminal device is by establishment
Database file is distributed in each component in application program, to cause each component to know the name of the database
Claim.
Step S120, predefined database object is obtained according to the database file.
Only need to know that the title can of database should by the name acquiring of database in the system of terminal device
The adduction relationship of database, meanwhile, the construction of SqliteHelper tool-class has also been pre-defined in the system of the terminal device
Function.By the title of the database in database file, dbName can be defined as, it is pre- so as to obtain to be transferred to the constructed fuction
The database object of definition, the database object can be defined as dbHlper.
Step S130, according to the function in the predefined database object invocation component to change in the component
Data in tables of data.
According to the number in the tables of data in the function pair component in predefined database object (dbHlper) invocation component
According to being modified, the operation of the change includes the data in tables of data are increased, deleted, changed and inquired about.And then cause,
Each component can be modified to the data of itself according to the demand of itself, and not influence other assemblies, improve each group
Independence between part.Meanwhile each component is to respective by same database object corresponding to same database
Tables of data operated, show that all tables of data in each component together constitute a database, i.e. the database leads to
Cross and each establish tables of data in each component respectively, tables of data is distributed to each component to realize, and then realize each group
The purpose of part shared data bank, avoid as one single database of each component construction, drastically increase database
Operating characteristics.
Fig. 3 is refer to, is the schematic flow sheet of another database separate design method provided in an embodiment of the present invention, should
Database separate design method includes:
Step S210, the same database file of establishment is distributed in each component of the application program.
The system installed on a terminal device database shared by some application program is created, the data
Storehouse is a database file actually, and the database file includes database-name.System on the terminal device is by establishment
Database file is distributed in each component in application program, to cause each component to know the name of the database
Claim.
Step S220, predefined database object is obtained according to the database file.
Only need to know that the title can of database should by the name acquiring of database in the system of terminal device
The adduction relationship of database, meanwhile, the construction of SqliteHelper tool-class has also been pre-defined in the system of the terminal device
Function.By the title of the database in database file, dbName can be defined as, it is pre- so as to obtain to be transferred to the constructed fuction
The database object of definition, the database object can be defined as dbHlper.
Step S230, obtain the title of the tables of data in each component.
One or more tables of data are included in each component in the application program, it is readily appreciated that, in different components
Tables of data can be with identical, can also be different.The tables of data included in the component is not according to predefined database object
Be the empty table not comprising any data before being operated to tables of data, but the tables of data in each component type (row and
The content of row) it can be designed and safeguard according to business demand.
Step S240, according to the predefined database object according to the letter in the title invocation component of the tables of data
Several data in corresponding tables of data are modified.
According to predefined database object (dbHlper) according to the function pair component in the title invocation component of tables of data
Data in interior tables of data are modified, and the operation of the change includes increasing the data in tables of data, deleting, changing
And inquiry.And then cause, each component can be modified to the data of itself according to the demand of itself, and not influence other groups
Part, improve the independence between each component.Meanwhile each component is by same number corresponding to same database
Respective tables of data is operated according to storehouse object, shows that all tables of data in each component together constitute a data
Tables of data is distributed to each component by storehouse, the i.e. database by each establishing tables of data in each component respectively, to realize,
And then the purpose of each component shared data bank is realized, avoid as one single database of each component construction, greatly
Ground improves the operating characteristics of database.
Refer to Fig. 4, be the effect diagram of the technical program provided in an embodiment of the present invention, it can be seen that, pass through by
The different pieces of information table of same database is scattered in different components, in the case where ensureing each component lower coupling, is realized
Each component shares the purpose of same database, improves the operating characteristics of database.
Fig. 5 is refer to, is a kind of functional module signal of database separate design device 100 provided in an embodiment of the present invention
Figure, the database separate design device 100 are applied to terminal device, and the database separate design device 100 includes distribution module
110th, object acquisition module 120, name acquiring module 130 and calling module 140, wherein,
Distribution module 110, for the same database file of establishment to be distributed in each component of the application program.
In embodiments of the present invention, step S110 and step S210 can be performed by distribution module 110.
Object acquisition module 120, for obtaining predefined database object according to the database file.
In embodiments of the present invention, step S120 and step S220 can be performed by object acquisition module 120.
Name acquiring module 130, for obtaining the title of the tables of data in each component.
In embodiments of the present invention, step S230 can be performed by name acquiring module 130.
Calling module 140, described in being changed according to the function in the predefined database object invocation component
The data in tables of data in component.
In embodiments of the present invention, step S130 and step S240 can be performed by calling module 140.
Due to being had been described in database separate design method part, will not be repeated here.
In summary, a kind of database separate design method and device provided in an embodiment of the present invention, database separation
Design method and device are applied to terminal device, multiple application programs are provided with the terminal device, each application program is by more
Individual component is formed.The database separate design method includes:The same database file of establishment is distributed to the application program
Each component in, predefined database object is obtained according to the database file, according to predefined database object
Function in invocation component is to change the data in the tables of data in the component.
In this programme, an application program is made up of multiple components, between multiple components independently of each other, it is impossible to mutually draw
With functional based method, and the corresponding database of an application program.By the way that the database file is distributed in each component, with
Each component is allowd to call database object to operate tables of data corresponding to the component, in other words, by by a data
Each tables of data in storehouse is distributed to each component, make it that multiple components in same application program can be with shared data
Storehouse, improve the performance of database.
In several embodiments provided herein, it should be understood that disclosed apparatus and method, can also pass through
Other modes are realized.Device embodiment described above is only schematical, for example, flow chart and block diagram in accompanying drawing
Show the device of multiple embodiments according to the present invention, method and computer program product architectural framework in the cards,
Function and operation.At this point, each square frame in flow chart or block diagram can represent the one of a module, program segment or code
Part, a part for the module, program segment or code include one or more and are used to realize holding for defined logic function
Row instruction.It should also be noted that at some as in the implementation replaced, the function that is marked in square frame can also with different from
The order marked in accompanying drawing occurs.For example, two continuous square frames can essentially perform substantially in parallel, they are sometimes
It can perform in the opposite order, this is depending on involved function.It is it is also noted that every in block diagram and/or flow chart
The combination of individual square frame and block diagram and/or the square frame in flow chart, function or the special base of action as defined in performing can be used
Realize, or can be realized with the combination of specialized hardware and computer instruction in the system of hardware.
In addition, each functional module in each embodiment of the present invention can integrate to form an independent portion
Point or modules individualism, can also two or more modules be integrated to form an independent part.
If the function is realized in the form of software function module and is used as independent production marketing or in use, can be with
It is stored in a computer read/write memory medium.Based on such understanding, technical scheme is substantially in other words
The part to be contributed to prior art or the part of the technical scheme can be embodied in the form of software product, the meter
Calculation machine software product is stored in a storage medium, including some instructions are causing a computer equipment (can be
People's computer, server, or network equipment etc.) perform all or part of step of each embodiment methods described of the present invention.
And it should be noted that herein, such as first and second or the like relational terms be used merely to an entity or
Operation makes a distinction with another entity or operation, and not necessarily requires or imply these entities or exist between operating any
This actual relation or order.Moreover, term " comprising ", "comprising" or its any other variant be intended to it is non-exclusive
Property includes, so that process, method, article or equipment including a series of elements not only include those key elements, and
Also include the other element that is not expressly set out, or also include for this process, method, article or equipment inherently
Key element.In the absence of more restrictions, the key element limited by sentence "including a ...", it is not excluded that including described
Other identical element also be present in the process of key element, method, article or equipment.
The preferred embodiments of the present invention are the foregoing is only, are not intended to limit the invention, for the skill of this area
For art personnel, the present invention can have various modifications and variations.Within the spirit and principles of the invention, that is made any repaiies
Change, equivalent substitution, improvement etc., should be included in the scope of the protection.It should be noted that:Similar label and letter exists
Similar terms is represented in following accompanying drawing, therefore, once being defined in a certain Xiang Yi accompanying drawing, is then not required in subsequent accompanying drawing
It is further defined and explained.
The foregoing is only a specific embodiment of the invention, but protection scope of the present invention is not limited thereto, any
Those familiar with the art the invention discloses technical scope in, change or replacement can be readily occurred in, should all be contained
Cover within protection scope of the present invention.Therefore, protection scope of the present invention described should be defined by scope of the claims.