1. Field of the Invention
The present invention generally relates to relational databases. More particularly, the present invention provides a method, system and program product for normalization of database result sets, such as Java Database Connectivity (JDBC) ResultSets.
2. Related Art
Relational database queries are often used to return information from several tables at once. The information is returned in a flat, tabular format that does not represent the relationships between tables in the database. When data is returned in this format, users have to spend considerable time transforming the data back into a normalized format that more closely resembles the underlying database. An example of a flat, tabular format JDBC ResultSet 10 is illustrated in
The JDBC ResultSet 10 illustrated in
In order to extract a list of the employees in ResultSet 10 that work in the “Shoe department,” and to provide the list in a usable format, specialized code such as that listed below could be used:
This code iteratively examines each entry of ResultSet 10 for the string “Shoe Department,” and, if found, extracts the corresponding name of the employee and adds that name to the string “employeeName.” Similar specialized code must be provided to extract other information from ResultSet 10 and to provide that information to a user in a usable format. Thus, there is a need to reduce or eliminate the requirement for users to write specialized code to transform database result sets (e.g., a JDBC ResultSets) into a usable format.
In general, the present invention provides a method, system, and program product for normalization of database result sets, such as Java Database Connectivity (JDBC) ResultSets.
A first aspect of the present invention is directed to a method for normalizing a database result set, comprising: transforming a row in the database result set into a set of data objects using information from the database result set and metadata corresponding to the result set; establishing links between the data objects by iterating through relationships defined in the metadata; and generating a graph of related data objects based on the links.
A second aspect of the present invention is directed to a system for normalizing a database result set, comprising: a system for transforming a row in the database result set into a set of data objects using information from the database result set and metadata corresponding to the result set; a system for establishing links between the data objects by iterating through relationships defined in the metadata; and a system for generating a graph of related data objects based on the links.
A third aspect of the present invention is directed to a program product stored on a recordable medium for normalizing a database result set, which when executed, comprises: program code for transforming a row in the database result set into a set of data objects using information from the database result set and metadata corresponding to the result set; program code for establishing links between the data objects by iterating through relationships defined in the metadata; and program code for generating a graph of related data objects based on the links.
A fourth aspect of the present invention is directed to a system for deploying an application for normalizing a database result set, comprising: a computer infrastructure being operable to: transform a row in the database result set into a set of data objects using information from the database result set and metadata corresponding to the result set; establish links between the data objects by iterating through relationships defined in the metadata; and generate a graph of related data objects based on the links.
A fifth aspect of the present invention provides computer software embodied in a propagated signal for normalizing a database result set, the computer software comprising instructions to cause a computer system to perform the following functions: transform a row in the database result set into a set of data objects using information from the database result set and metadata corresponding to the result set; establish links between the data objects by iterating through relationships defined in the metadata; and generate a graph of related data objects based on the links.
These and other features of this invention will be more readily understood from the following detailed description of the various aspects of the invention taken in conjunction with the accompanying drawings in which:
a-4f illustrate a data transformation of the JDBC ResultSet shown in
The drawings are merely schematic representations, not intended to portray specific parameters of the invention. The drawings are intended to depict only typical embodiments of the invention, and therefore should not be considered as limiting the scope of the invention. In the drawings, like numbering represents like elements.
As indicated above, the present invention provides a method, system, and program product for normalization of database result sets, such as Java Database Connectivity (JDBC) ResultSets. It is assumed for the purposes of this description that the reader has an understanding of databases, database schemas, Java, and JDBC commensurate with one skilled in the art. Accordingly, a detailed description of these topics is not provided herein.
The present invention utilizes information provided by a user to transform data within a ResultSet into a graph of related data objects. The information provided by the user is a description of a subset of a database schema used in the query that generated the ResultSet. As shown in
A flow diagram 50 illustrating the steps of the transformation provided by the present invention is illustrated in
The process illustrated in the flow diagram 50 of
In
At this point in the process, table registry 52 is examined to determine if the “Department” data object having the primary key value of “Shoe Department” exists therein. If the “Department” data object having the primary key value of “Shoe Department” exists in the table registry 50, it is retrieved from the table registry 50. If the “Department” data object having the primary key value of “Shoe Department” does not exist in the table registry 50, it is stored in the table registry 50. As shown in
The above steps are repeated for the child data object of the relationship between “Department” and “Employee Name” in row 20 of ResultSet 10, resulting in the set of data objects “Shoe Department,” “Sam (10/27/1989),” and “Zip Code” shown in
Row 22 of ResultSet 10 is then processed in the same manner. This results in the set of data objects depicted in
In the above example, a single “Shoe Department” data object is linked to employee data objects “Sam” and “Julie.” Similarly, a single “Hat Department” data object is linked to employee data objects “Burt,” “Jack,” and “Susan.” As such, in order to extract a list of the employees in the ResultSet 10 that work in the “Shoe department,” and to provide the list in a usable format, code such as that listed below could be used:
employees=shoeDepartment.getList(“employees”)
Thus, comparing this code with the specialized code of the prior art listed above, it will be readily apparent that it is much easier to extract information from a ResultSet using the method of the present invention.
From the graph 70, it should also be noted that the employee data objects “Sam,” “Burt,” and “Jack” are each linked to a single zip code data object, “27560,” while the employee data objects “Julie” and “Susan” are each linked to a single zip code data object “27709.” Thus, data objects are not duplicated in the final graph 70. Further, since all relationships are bidirectional, a plurality of parent data objects can be obtained from a single child object. For example, the three employee data objects “Sam,” “Burt,” and “Jack” can be obtained from the single zip code object, “27560.”
Referring now to
I/O interfaces 108 may comprise any system for exchanging information to/from an external source. External devices/resources 110 may comprise any known type of external device, including speakers, a CRT, LCD screen, handheld device, keyboard, mouse, voice recognition system, speech output system, printer, monitor/display, facsimile, pager, etc. Bus 106 provides a communication link between each of the components in computer system 100 and likewise may comprise any known type of transmission link, including electrical, optical, wireless, etc.
Storage unit 112 can be any system capable of providing storage for information necessary for the practice of the present invention. As such, storage unit 112 may reside at a single physical location, comprising one or more types of data storage, or may be distributed across a plurality of physical systems in various forms. In another embodiment, storage unit 112 may be distributed across, for example, a local area network (LAN), wide area network (WAN) or a storage area network (SAN), shown generically in
Shown in memory 104 of computer system 100 is a normalization system 120, which may be provided as computer program product. The normalization system 120 is provided to normalize database result sets, such as JDBC ResultSets, stored in storage unit 112. The normalization system 120 includes a transformation system 122 for transforming data within a database result set into data objects, based on the result set and metadata 124 corresponding to the result set. The metadata 124 can be provided by user 126 or in any other suitable manner. As described above, the metadata comprises a subset of a database schema used in the query that generated the result set.
The normalization system 120 further includes a linking system 128 for establishing links between the data objects generated by transformation system 122, by iterating through the relationships defined in the metadata 124. A graphing system 130 for generating a graph 132 of related data objects, which can be displayed to user 126 on display 134, is also provided. The table registry 52 used in this process can be stored in storage unit 112.
It should be appreciated that the teachings of the present invention could be offered as a business method on a subscription or fee basis. For example, computer system 100 could be created, maintained and/or deployed by a service provider that offers the functions described herein for customers. That is, a service provider could be used to normalize database result sets as describe above. It should also be understood that the present invention can be realized in hardware, software, a propagated signal, or any combination thereof. Any kind of computer/server system(s)—or other apparatus adapted for carrying out the methods described herein—is suited. A typical combination of hardware and software could be a general purpose computer system with a computer program that, when loaded and executed, carries out the respective methods described herein. Alternatively, a specific use computer, containing specialized hardware for carrying out one or more of the functional tasks of the invention, could be utilized. The present invention can also be embedded in a computer program product or a propagated signal, which comprises all the respective features enabling the implementation of the methods described herein, and which—when loaded in a computer system—is able to carry out these methods. Computer program, propagate signal, software program, program, or software, in the present context mean any expression, in any language, code or notation, of a set of instructions intended to cause a system having an information processing capability to perform a particular function either directly or after either or both of the following: (a) conversion to another language, code or notation; and/or (b) reproduction in a different material form.
The foregoing description of the preferred embodiments of this invention has been presented for purposes of illustration and description. It is not intended to be exhaustive or to limit the invention to the precise form disclosed, and obviously, many modifications and variations are possible. Such modifications and variations that may be apparent to a person skilled in the art are intended to be included within the scope of this invention as defined by the accompanying claims.