The present invention relates to Database Management Systems (DBMS), and more specifically, to managing data conversion for user-defined data types within a DBMS. Current DBMSs do not offer any functionality that allows for marshaling and unmarshaling of custom data types, nor do they allow comparison of these custom data types. User defined types (UDTs) are supported by many DBMSs, but they are either structured data types or distinct objects made up of built-in data types that are already supported by the DBMS.
Custom data types (CDTs) are defined as a data type that cannot be expressed as a series of built-in data types already supported by the DBMS. One example of a CDT is a bit string, where each bit represents a pre-determined value. CDTs are handled in applications and are typically stored in a database as a so-called Large Object (LOB) or, as in the previous example of a bit string, as a binary data type. There is no meaning associated with the LOB or binary data type. The meaning is handled at the application layer.
It can be difficult to manage the sharing of information and data conversion code for CDTs across an enterprise. CDTs require custom code (i.e., a type converter) to read and write the data from a DBMS to the calling application. As a consequence, it may be necessary to have type converters for the same data type in multiple programming languages as well as support various versions of the type converter code.
A known solution for custom data types in the Java™ programming language is that the Java Database Connectivity (JDBC) protocol allows for the storage of Java Objects directly into the DBMS through Java serialization. However, this solution is not language independent and other programming languages therefore need to know how to read and instantiate the Java object. It also requires the Java class definition to be available in the class path of each calling application.
The Structured Query Language (SQL) provides support for UDTs that are constructs made up of existing SQL Types. However, this solution does not provide the flexibility for a completely unique data type that is not based on any SQL Types. Similar solutions exist for other languages, such as the .NET language, that is, the solution is made up of database built-ins and applies only to the .NET language. The UDT must exist in the application itself and cannot be loaded dynamically from the DBMS.
According to one aspect of the present invention, techniques are provided for managing data conversion for user-defined data types within a DBMS. A custom data type definition and one or more converters are stored within a database management system. Each converter can convert instances of the custom data type between a binary format and a programming language format. The database management system receives a request for a custom data type instance in a specified programming language format. A converter among the one or more converters converts the custom data type instance expressed in the binary format into a custom data type instance expressed in the specified programming language format, using a custom data type definition from the database management system. The request is responded to with the converted custom data type instance in the specified programming language format.
The details of one or more embodiments of the invention are set forth in the accompanying drawings and the description below. Other features and advantages of the invention will be apparent from the description and drawings, and from the claims.
Like reference symbols in the various drawings indicate like elements.
The various embodiments of the invention described herein provide a detailed framework for a DBMS to provide support for CDTs. In one embodiment, the framework has two main components. The first component includes a DBMS interface that provides the calling application with a definition of the CDT in the requested programming language, such that the calling application can instantiate and understand the CDT. The second component includes a query engine call back interface, which allows the DBMS query engine to access the user implementation of the data conversion interface for the CDT for a requested programming language, which also includes the ability to compare two objects of the CDT.
One benefit of this two-component framework is that the framework allows custom data types to be supported by the DBMS for multiple programming languages. It also enhances the data discovery capabilities for applications that contain no prior knowledge of what data is stored in a DBMS.
The various embodiments of this invention also provide techniques by which a CDT can be made known to the DBMS (including comparisons between CDTs and performing arithmetic operations on CDTs) without applications needing to prescribe the meaning themselves. Instead, applications can pull the meaning (in the form of metadata) from the DBMS itself, specific to a given CDT (not generic, as in the case of LOBs, for example).
In accordance with one embodiment, a CDT uses two pieces to work with a DBMS. The first piece is a definition of the custom data type, such that the application knows how to interpret and use the CDT. In programming languages, such as Java or C/C++, this piece would be the class definition for the custom data type. The second piece is a type converter, which is a piece of code that marshals the byte representation of an object from the DBMS to an object of the CDT defined in the first piece, and vice versa. The type converter also provides a comparison mechanism, which allows the DBMS to filter a data query request based on a search predicate. The combination of these two pieces allows the calling application to understand the CDT and to store and retrieve objects based on the CDTs from the DBMS. As a result, both the CDT and the user type converter can both be fully managed by the DBMS so that a calling application doing data discovery does not need to have any prior knowledge of either component.
The User (UDT, CDT) Type Definition
The various embodiments in accordance with the invention can support two different kinds of UDTs. The first kind of UDT is a compound type. The compound user type definition can be a construct up made from built-in database types, such as integers and strings. One example of a compound user type definition is a street address, as shown below. The address can be broken up into different components: house number, street name, city, state, and zip code. These sub-components can be defined as the following primitive types shown below in Java.
The User Type Converter
In one embodiment, each user type also requires one or more user type converters (depending on the number of programming languages supported) to translate the binary data representation to and from an instance of the user type. The user type converter implements two methods: a read method for converting from the binary data in the DBMS to a user type object as defined for a specific programming language, and a write method for converting from the user type object to a raw binary format for storing into the DBMS. Each programming language for which the DBMS provides user type support has a well-defined interface for these read and write methods. In some embodiments, a comparison method is also implemented that allows the DBMS to qualify database queries with search qualifications based on the custom type. The type converter is serializable so it can be stored within the DBMS. The following is an example of a sample Java Interface for the Custom Type Converter definition:
The Database Definition for User Types
In one embodiment, both the user defined type definition and the type converter are stored within the DBMS. This allows tooling products, such as data discovery and business intelligence tools, to interpret and inspect the UDT data without any special considerations, such as the need to manually place the type definitions and type converters within the tool's class path. In embodiments where the DBMS includes a catalog, the type definitions and type converters can be stored in this catalog, as the catalog typically will be grouped together with the rest of the metadata information for columns and tables. When creating a database that requires a user data type in the DBMS, the database definition itself will require syntax to load the user data type definition, the type converter, and the programming language in which the definition and type converter is written. In some embodiments, a version number for the user data type can also be included, which allows users to continue enhancing their existing user types. The following is an example of a custom type “DOGBREED,” expressed in the Data Definition Language (DDL):
Retrieving the Custom Defined Type Definition from the DBMS
The following access methods, whether through a JDBC driver or .NET Data provider, grabs the appropriate type definition and type converter. The following is an example for a JDBC driver.
Using standard database discovery methods, the application can determine if there are any user defined types in the DBMS, based on its catalog metadata. The following code shows how database metadata can be used to retrieve information on a Custom Defined Type, which allows the user to identify the User Defined Types and cast it appropriately on a getter or setter. Similar code will be in place for the ResultSetMetadata methods.
The following example is an example output for sample Java code and shows how DatabaseMetadata can be used to retrieve information on a Custom Defined Type. The DataType of 1111 signifies a SQL type of “OTHER”, which is used to represent a User Type.
Once the user type name is known, the application can optionally request the Connection object for the type definition with the following method:
The following code example shows how an implementation of the ConnectionImp1.getUserTypeDefinition(String) method can be implemented:
Retrieving Custom Defined Types Records
To retrieve the data from the DBMS, the DATA_TYPE value of 1111 signifies to the application that this is of SQL type “OTHER.” The following code examples show how to retrieve the user type object instance from the DBMS.
The following sample application requests the column “breed” from the table “dogs.”
The ResultSet.getObject(String) and ResultSet.getObject(int) methods add the following implementation to load the appropriate user type converter to translate the data from the DBMS.
The create and update methods perform similarly to the read method described above. Furthermore, similar logic can be applied to other languages and data access protocols, such as the .NET Data Provider for C#, for example.
The present invention may be a system, a method, and/or a computer program product. The computer program product may include a computer readable storage medium (or media) having computer readable program instructions thereon for causing a processor to carry out aspects of the present invention.
The computer readable storage medium can be a tangible device that can retain and store instructions for use by an instruction execution device. The computer readable storage medium may be, for example, but is not limited to, an electronic storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. A non-exhaustive list of more specific examples of the computer readable storage medium includes the following: a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), a static random access memory (SRAM), a portable compact disc read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanically encoded device such as punch-cards or raised structures in a groove having instructions recorded thereon, and any suitable combination of the foregoing. A computer readable storage medium, as used herein, is not to be construed as being transitory signals per se, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through a waveguide or other transmission media (e.g., light pulses passing through a fiber-optic cable), or electrical signals transmitted through a wire.
Computer readable program instructions described herein can be downloaded to respective computing/processing devices from a computer readable storage medium or to an external computer or external storage device via a network, for example, the Internet, a local area network, a wide area network and/or a wireless network. The network may comprise copper transmission cables, optical transmission fibers, wireless transmission, routers, firewalls, switches, gateway computers and/or edge servers. A network adapter card or network interface in each computing/processing device receives computer readable program instructions from the network and forwards the computer readable program instructions for storage in a computer readable storage medium within the respective computing/processing device.
Computer readable program instructions for carrying out operations of the present invention may be assembler instructions, instruction-set-architecture (ISA) instructions, machine instructions, machine dependent instructions, microcode, firmware instructions, state-setting data, or either source code or object code written in any combination of one or more programming languages, including an object oriented programming language such as Smalltalk, C++ or the like, and conventional procedural programming languages, such as the “C” programming language or similar programming languages. The computer readable program instructions may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet Service Provider). In some embodiments, electronic circuitry including, for example, programmable logic circuitry, field-programmable gate arrays (FPGA), or programmable logic arrays (PLA) may execute the computer readable program instructions by utilizing state information of the computer readable program instructions to personalize the electronic circuitry, in order to perform aspects of the present invention.
Aspects of the present invention are described herein with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and/or block diagrams, and combinations of blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer readable program instructions.
These computer readable program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks. These computer readable program instructions may also be stored in a computer readable storage medium that can direct a computer, a programmable data processing apparatus, and/or other devices to function in a particular manner, such that the computer readable storage medium having instructions stored therein comprises an article of manufacture including instructions which implement aspects of the function/act specified in the flowchart and/or block diagram block or blocks.
The computer readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable apparatus or other device to produce a computer implemented process, such that the instructions which execute on the computer, other programmable apparatus, or other device implement the functions/acts specified in the flowchart and/or block diagram block or blocks.
The flowchart and block diagrams in the Figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of instructions, which comprises one or more executable instructions for implementing the specified logical function(s). In some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems that perform the specified functions or acts or carry out combinations of special purpose hardware and computer instructions.
The descriptions of the various embodiments of the present invention have been presented for purposes of illustration, but are not intended to be exhaustive or limited to the embodiments disclosed. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The terminology used herein was chosen to best explain the principles of the embodiments, the practical application or technical improvement over technologies found in the marketplace, or to enable others of ordinary skill in the art to understand the embodiments disclosed herein.
Number | Name | Date | Kind |
---|---|---|---|
6167565 | Kanamori | Dec 2000 | A |
6381600 | Lau | Apr 2002 | B1 |
6505211 | Dessloch | Jan 2003 | B1 |
7421621 | Zambrana | Sep 2008 | B1 |
7539688 | Sezgin | May 2009 | B2 |
7596576 | Venkatesh | Sep 2009 | B2 |
7620526 | Back | Nov 2009 | B2 |
7650346 | Henaire | Jan 2010 | B2 |
7653652 | Kagalwala | Jan 2010 | B2 |
7668963 | Miner | Feb 2010 | B1 |
7765239 | Rajan et al. | Jul 2010 | B2 |
8015217 | Challapalli et al. | Sep 2011 | B2 |
8332373 | Milby | Dec 2012 | B1 |
8510341 | Weinberg et al. | Aug 2013 | B2 |
9378226 | Wu | Jun 2016 | B1 |
9507820 | Hannah | Nov 2016 | B1 |
9652312 | Selig, IV | May 2017 | B2 |
10025588 | Tran | Jul 2018 | B1 |
20010056460 | Sahota | Dec 2001 | A1 |
20020123993 | Chau | Sep 2002 | A1 |
20020174128 | Govindarajan | Nov 2002 | A1 |
20030105732 | Kagalwala | Jun 2003 | A1 |
20030145008 | Burrell | Jul 2003 | A1 |
20040172484 | Hafsteinsson | Sep 2004 | A1 |
20040249830 | Sonkin | Dec 2004 | A1 |
20040267766 | Marek et al. | Dec 2004 | A1 |
20050149543 | Cohen | Jul 2005 | A1 |
20050177589 | Venkatesh | Aug 2005 | A1 |
20050251812 | Hayward | Nov 2005 | A1 |
20070136332 | Nolan | Jun 2007 | A1 |
20070239818 | Liou | Oct 2007 | A1 |
20070247464 | Wylie | Oct 2007 | A1 |
20080301703 | Nixon | Dec 2008 | A1 |
20080313532 | Dames | Dec 2008 | A1 |
20090006083 | Bachand | Jan 2009 | A1 |
20090112902 | Sthanikam | Apr 2009 | A1 |
20090171997 | Challapalli | Jul 2009 | A1 |
20090187585 | Mathur | Jul 2009 | A1 |
20090198651 | Shiffer | Aug 2009 | A1 |
20090300054 | Fisher | Dec 2009 | A1 |
20100023542 | Devanathan et al. | Jan 2010 | A1 |
20100094829 | Castellanos | Apr 2010 | A1 |
20100185701 | Ramamurthi et al. | Jul 2010 | A1 |
20100211598 | Martinez et al. | Aug 2010 | A1 |
20110066617 | Liu et al. | Mar 2011 | A1 |
20110282914 | Block | Nov 2011 | A1 |
20120310989 | Weissman | Dec 2012 | A1 |
20130125232 | Hogan | May 2013 | A1 |
20130132826 | Kim | May 2013 | A1 |
20130144896 | Kim | Jun 2013 | A1 |
20130159970 | Welicki et al. | Jun 2013 | A1 |
20140095550 | Rantanen | Apr 2014 | A1 |
20140188917 | Hopkins | Jul 2014 | A1 |
20150178342 | Seering | Jun 2015 | A1 |
20150254316 | Charlet | Sep 2015 | A1 |
20160004578 | Selig, IV | Jan 2016 | A1 |
20160004758 | Block | Jan 2016 | A1 |
20160171026 | Charlet | Jun 2016 | A1 |
20160188686 | Hopkins | Jun 2016 | A1 |
20170220613 | Gass | Aug 2017 | A1 |
20170286412 | Mohanty | Oct 2017 | A1 |
20170337561 | Curtis | Nov 2017 | A1 |
20180121527 | Hsu | May 2018 | A1 |
20180357273 | Srivastava | Dec 2018 | A1 |
20190065553 | Young | Feb 2019 | A1 |
Entry |
---|
Pani et al.; “A Revitalized Interprocedural Slicing in the Presence of Derived and User Defined Data Types”, IACC/IEEE 2nd International Conference on, Feb. 19-20, 2010, pp. 60-65. |
IP.COM et al.; “System and Method to Dynamically Create Optimum Mining Flows in a Strongly Typed Analytics System”, IPCOM000226486D, Apr. 8, 2013, pp. 1-4. |
Ma et al.; “TYPifier: Inferring the Type Semantics of Structured Data”, ICDE/IEEE 29th International Conference on, Apr. 8-12, 2013, pp. 206-217. |
USPTO Office Action; U.S. Appl. No. 14/636,320; Notification Date Mar. 1, 2016. |
USPTO Office Action; U.S. Appl. No. 14/636,320; Notification Date Jul. 1, 2016. |
USPTO Office Action; U.S. Appl. No. 14/636,320; Notification Date Jan. 11, 2017. |
USPTO Office Action; U.S. Appl. No. 14/636,320; Notification Date Aug. 16, 2017. |
Number | Date | Country | |
---|---|---|---|
20150254315 A1 | Sep 2015 | US |