In the figures which illustrate example embodiments of this disclosure:
In one aspect of the below-described embodiment, there is provided a method comprising determining a current version of a database; based on the determined current version of the database and one or more markup language documents containing a plurality of markup language portions, each the markup language portion describing a set of changes to the database for upgrading the database from a starting version to a subsequent version, selecting one of the markup language portions for implementation; and implementing the set of changes to the database described by the selected markup language portion.
In another aspect of the below-described embodiment, there is provided a machine-readable medium comprising: machine-executable code for determining a current version of a database; machine-executable code for selecting, based on the determined current version of the database and one or more markup language documents containing a plurality of markup language portions, each the markup language portion describing a set of changes to the database for upgrading the database from a starting version to a subsequent version, one of the markup language portions for implementation; and machine-executable code for implementing the set of changes to the database described by the selected markup language portion.
In yet another aspect of the below-described embodiment, there is provided a computing device comprising: at least one processor; and memory coupled to the at least one processor storing: machine-executable code for determining a current version of a database; machine-executable code for selecting, based on the determined current version of the database and one or more markup language documents containing a plurality of markup language portions, each the markup language portion describing a set of changes to the database for upgrading the database from a starting version to a subsequent version, one of the markup language portions for implementation; and machine-executable code for implementing the set of changes to the database described by the selected markup language portion.
Volatile memory 14 stores three executable computer programs, namely database upgrade software 22, database management system 24 and software application 25.
Database upgrade software 22 is responsible for upgrading a database 32 stored in non-volatile memory 16, and is a focus of the present description. As will be described, the database upgrade software 22 takes as its input a markup language database upgrade description document 30 which governs the behavior of the software 22 when performing a database upgrade. During the course of a database upgrade, database upgrade software 22 instantiates various objects 34 (i.e. instances of object oriented classes) for the purpose of effecting the upgrade, as will be described.
Database management system (DBMS) 24 is a conventional DBMS which facilitates access to and manipulation of data stored in database 32. Commercially available database management systems that may be used on wireless communication devices include Sybase™, Microsoft® Pocket Access, Microsoft(® SQLCE, Oracle, and J2ME MIDP storage. For example, DBMS 24 may be capable of executing queries (such as structured query language (SQL) queries) for extracting desired records from tables within the database 32. Alternatively DBMS 24 could be a proprietary DBMS which provides application programming interfaces (APIs) for accessing or manipulating data in database 32. In either case, the DBMS 24 is utilized by database upgrade software 22 (and, more specifically, by objects 34) for the purpose of effecting database upgrades, as will be described.
Software application 25 is a computer program which stores data in database 32 via DBMS 24. Application 25 may be virtually any type of program capable of storing, accessing and manipulating data in a database. In the present embodiment, it is assumed that software application 25 has recently been upgraded from an initially released version 1.0 to a current version 1.2 (with an intermediate version 1.1 being skipped) and that the new version of application 25 now requires data stored in database 32 to be upgraded from an original version 1.0 to a subsequent, desired version 1.2.
Each of the database upgrades software 22, DBMS 24 and software application 25 may be downloaded from a server 26 via wireless network 20. The executable programs may have been loaded to server 26 from a machine-readable medium such as an optical disk 28. Alternatively, the programs could be loaded directly to memory 14 from a machine-readable medium. Each of these computer programs 22, 24 and 25 comprises machine-executable code (e.g. machine code or byte code), and are thus capable of execution by the computing device 10, either alone or in conjunction with other programs such as a “virtual machine” execution environment (e.g. Java™ virtual machine or .NET compact framework) for example.
Non-volatile memory 16 stores database upgrade description document 30 and database 32.
Database upgrade description document 30 is a markup language document that is read by the database upgrade software 22 prior to its execution of a database upgrade. Document 30 may be thought of as a “plug-in” to the database upgrade software 22 which determines the substance of the database upgrade to be performed. In the present embodiment, the database upgrade description document 30 is an Extensible Markup Language (XML) document, a form of markup language document that is well known in the art. The XML may for example be formed in accordance with the Extensible Markup Language (XML) 1.0 (Third Edition) W3C Recommendation dated 4 Feb. 2004, which is provided at www.w3.org/TR/2004/REC-xml-20040204/. As will be described, the document 30 contains a hierarchy of XML elements with attributes describing a series of incremental upgrades which may be performed to database 32. An incremental upgrade refers to a database upgrade between consecutive database versions (e.g., a change between consecutive database versions 1.0 and 1.1) as distinguished from a change spanning multiple database versions (e.g., version 1.0 to, say, version 1.2, skipping version 1.1). Each incremental upgrade of the present embodiment describes changes to one or more database tables and their subordinate fields. Database upgrade description document 30 is described in more detail below.
Database 32 comprises one or more files storing data in the form of tables containing records (rows) with user-defined fields (columns). Each field has a type (e.g. integer, string, date, and the like). The database 32 may be a relational database, but this is not a requirement.
As illustrated, original database 32 has four tables 52, 54, 56 and 58 named tblCustomer, tblWorkOrder, tblPriority and tblTemporary, respectively. Each table defines a number of fields. For example, the tblCustomer table 52 defines three fields named intCustomerlD, strEmail and strEmail2. The type of each field is indicated by the field name prefix (“int” indicating integer and “str” indicating string). All of the tables 52, 54, 56 and 58 are assumed to store data (not expressly illustrated).
As shown in
As shown in
In the present embodiment, all possible database table changes are grouped into four categories of “actions”: (1) ADD TABLE; (2) DROP TABLE; (3) RENAME TABLE; and (4) UPDATE TABLE. The ADD TABLE action adds a table to the database. The DROP TABLE action deletes an existing table from a database. The RENAME TABLE action assigns a new name to an existing database table. Finally, the UPDATE TABLE action modifies an existing database table in some way. The latter action includes the addition of new fields to the table or the renaming or deleting of existing fields. As will be appreciated, the INSTRUCTION and FIELD elements are used in combination to represent all of the different types of database changes possible in the present embodiment.
In
The UPGD elements each contain at least one INSTRUCTION element. An INSTRUCTION element represents a constituent step for effecting the incremental upgrade represented by the containing UPGD element. To effect a particular incremental upgrade, the INSTRUCTION elements are “executed” in sequence, as will be described. Each INSTRUCTION element represents one of the four above-described types of changes to a named table. The type of change is indicated by the “action” attribute of the INSTRUCTION element. The affected table is identified by the “table” attribute. Each of the four categories of changes is represented in
One or more FIELD elements may be contained by an INSTRUCTION element. A FIELD element represents a particular type of change to be made to a named field in the context of the table change represented by the containing INSTRUCTION element. There are three types of changes that can be made to a field: (a) ADD FIELD, where a new field with a specified name and type is added to a table; (b) DROP FIELD, where a specified field is deleted from the table; or (c) RENAME FIELD, where a specified field is renamed. For all three types of changes, the type of change is indicated by the “action” attribute and the name of the impacted field is specified in a “name” attribute. For an ADD FIELD action, the type of the new field is specified in a “type” attribute and an optional “allownull” boolean attribute specifies whether the field can have a null value. For a RENAME FIELD action, a new name for the field is specified in a “newname” attribute of the FIELD element.
In the description which follows, use of the database upgrade software 22 of
In operation, when database upgrade software 22 of
The outermost object of the hierarchy of objects 34 is an instance 100 of an Upgrades class 600 (illustrated in
As should be appreciated from the following description of classes 600, 700, 800 and 900, instantiation of the hierarchy of objects 34 is performed in a “top-down” fashion.
Referring to
Referring to
Referring now to
Referring to
Once the above-described “cascade” of invocations of fromXML( ) methods through the various instances of classes 600, 700, 800 and 900 has successfully completed, the result is a hierarchical set of objects 34 as shown in
At this stage, the execute( ) method of the “parent” Upgrades object 100 is invoked. This method, which is illustrated at lines 22-31 of
Initially, the execute( ) method sets the currentVersion and finalVersion data members to the current database version and desired final database version respectively. The current database version may be determined simply by reading a “current version” field of the database. The desired final version may for example be obtained from a configuration setting that may be set when the new version of application 25 of
Thereafter, the execute( ) method enters a loop whose termination condition is attainment of the desired database version. Within the loop, the execute( ) method scans the upgrades array for an Upgrade object (i.e. instance of an Upgrade class 700 of
The invoked execute( ) method, which is illustrated at lines 23-29 of
Referring to
In the case of an ADD TABLE action, one or more appropriate API calls are made to DBMS 24 or commands sent to DBMS 24 for causing a new table with a name matching the value of the data member tablename to be created in the database. Then, to add fields to the newly created table, the execute( ) method of each Field object (i.e. each instance of Field class 900) of the fields array is invoked in turn, with the tablename data member being passed as an input parameter. For example, in the case of Instruction object 110, the execute( ) method of each of Field objects 118, 120, 122 and 124 (see
In the case of a DROP TABLE action, one or more appropriate API calls are made to DBMS 24 or commands sent to DBMS 24 for causing the table with name matching the tablename data member value to be deleted from the database. This action would be taken by Instruction object 134 for example to cause the table named “tblTemporary” to be dropped.
In the case of an UPDATE TABLE action, the execute( ) method of each Field object of the fields array is invoked in turn, again with the tablename data member being passed as an input parameter, in order to add, drop or rename one or more fields of the table. For example, in the case of Instruction object 106, the execute( ) method of Field objects 112 and 114 are invoked with the input parameter “tblCustomer”.
In the case of a RENAME TABLE action, one or more appropriate API calls are made to DBMS 24 or commands sent to DBMS 24 for causing the table whose name matches the tablename data member value to be renamed to the value of the newname data member. This action would be taken by Instruction object 130 for example in to rename table “tblPriority” to “tblWOProirity”.
Referring to
In the case of an ADD FIELD action, one or more appropriate API calls are made to DBMS 24 or commands sent to DBMS 24 for causing a new field with a name matching the value of the data member fieldname to be created in the specified table. The API calls are such that the type of the new field will match the value of the data member newtype, and the field is not permitted to have a null value if the allownull data member is set to FALSE for example. This action would be effected by Field object 112 for example to cause a field named “strCustomerName” to be added to table “tblCustomer”.
In the case of a DROP FIELD action, one or more appropriate API calls are made to DBMS 24 or commands sent to DBMS 24 for causing the field with a name matching the fieldname data member value to be deleted from the relevant database table. This action would be taken by Field object 114 for example to cause the field named “strEmail2” to be dropped from table “tblCustomer”.
In the case of a RENAME FIELD action, one or more appropriate API calls are made to DBMS 24 or commands sent to DBMS 24 for causing the field whose name matches the fieldname data member value to be renamed to the value of the newname data member. This action would be taken by Field object 116 for example in to rename field “strDescription” to “strWODesc”.
In the present embodiment, when the “cascade” of execute( ) method invocations triggered by the invocation of the execute( ) method of the Upgrade object 102 has been completed, a value of “1.1 ” is returned, indicating to the calling execute( ) method of the Upgrades object 100 that the first incremental upgrade to v1.1 is complete. The currentVersion data member of the Upgrades object 100 will accordingly be set to 1.1, and a check may be performed to determine whether v1.1 is the desired final version. Given that V1.1 is not the desired final version in this example, the execute( ) method of the Upgrade object 104 is called in order to perform the next incremental upgrade from v1.1 to v1.2. This results in a similar cascade of execute( ) method invocations. Thus, as should now be appreciated, the desired level or degree of database upgrade determines which of the objects' 34 execute methods are invoked. When the latter cascade of invocations is completed, the database will be upgraded to v1.2, and operation terminates.
It is noted that, due to certain similarities between the four classes 600, 700, 800 and 900, these classes could implement a standard object oriented interface. The interface could for example require the definition of a fromXML( ) method and an execute( ) method, but would leave the bodies of these methods to be defined by the implementing classes. To account for the fact that the execute( ) method implementation in the Upgrade class takes a parameter “resultantVersion” while the implementations in the other classes do not take any parameters, the execute( ) method could be overloaded.
The above-described approach may be used in conjunction with a system that presents server-side applications at varied wireless communication devices, as described in U.S. Patent Publication No. US 2003/0060896 published Mar. 27, 2003 for example, which publication is hereby incorporated by reference hereinto. Specifically, the XML illustrated in
When database table updates are applied, they may be applied one record at a time, with old records being deleted on the fly, to avoid memory exhaustion at the wireless communication device 10.
If the database to be upgraded is stored at a wireless communication device 10 (as in the above-described embodiment), it may be advantageous to use the above described approach for upgrading the database locally at the device in lieu of alternative possible database upgrade techniques. One alternative technique may involve wireless transmission of the database contents to a server for upgrading, and then transmission of the database contents back to the wireless communication device. The latter approach can be costly, especially when the database is large. This is due to the fact that some wireless network providers charge wireless transmission or “air time” fees based on the amount of data transmitted or the amount of time spent transmitting. Operation of the present embodiment to upgrade a database locally at the device may circumvent such fees.
When it is necessary to rename a database field, the particular DBMS API calls or DBMS commands that must be specified to effect the field rename may differ from database to database. In some cases, a simple “rename” API call or command may be sufficient to rename a field. In other cases, the database may not support a simple “rename” command. Instead, it may be necessary to perform a series of “add” and “drop” API calls or commands to effect a rename. For example, it may be necessary to create a new temporary field, copy existing data into that temporary field, drop the old field, create a new field with the desired name, copy the data from the temporary field to the new field, and then drop the temporary field. The developer should be familiar with the relevant database and DBMS so that it is known which API calls and commands are available for achieving a database upgrade.
Creation of the database upgrade description document 30 may be facilitated by the use of a rapid application development (RAD) tool. A RAD tool is a computing device executing RAD software which provides an intuitive graphical user interface (GUI) facilitating “drag and drop” development of XML documents, so that even developers who lack XML knowledge may generate database upgrade description documents 30. The tool may permit the developer to create icons representative of the above-described XML elements in visual hierarchies corresponding the XML element hierarchies illustrated in the document 30 of
As will be appreciated by those skilled in the art, modifications to the above-described embodiment can be made without departing from the essence of the invention. For example, the database upgrade description document 30 could be generated using a markup language other than XML, such as Standard Generalized Markup Language. Different element and attribute names could be used rather than those indicated above.
In some embodiments, an UPGD element could define a non-incremental, “major” upgrade that effectively “skips” interim versions. This may be the case if it is known that certain changes in successive, incremental updates are redundant (e.g. an “add” and a “drop” of the same field in different incremental upgrades) or if it is know that that only a database with a very early version number needs to be upgraded to a much later version number, and that no databases with interim version numbers that would require upgrading remain in existence. The creator of such a database upgrade description document 30 may choose to simply eliminate any redundant changes between incremental updates when creating such a document 30.
Some embodiments may have multiple database upgrade description documents. For example, each document could contain a single UPGD element. Alternatively, a single database upgrade description document 30 may in some cases contain only one UPGD element.
The code which actually interfaces with the DBMS 24 for purposes of upgrading the database may be coded within general purpose routines. These routines could form part of database upgrade software 22 and could be invoked from the execute( ) methods of certain ones of objects 34. This may be done, e.g., to facilitate the capacity of the software 22 to be used with different types of databases or database management systems. For example, if access to a new type of database or DBMS is desired, new general purpose routines for interacting with the DBMS (having the same signature as existing general purpose routines for interacting with the DBMS) could be substituted, and the software 22 could be otherwise unchanged.
Other modifications will be apparent to those skilled in the art and, therefore, the invention is defined in the claims.