# US 2008/0306983 A1 · Mapping hierarchical data from a query result into a tabular format with jagged rows

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2008/0306983 A1
- Document ID: US20080306983A1
- Status: Published application
- Kind: A1
- Application number: 11/760,619
- Filed: 2007-06-08
- Published: 2008-12-11
- Earliest claimed: 2007-06-08
- Assignees: International Business Machines Corporation
- Inventors: Hardeep Singh
- Web page: https://patentgrep.com/patent/US20080306983A1

## CPC

- G06F 40/18: of spreadsheets (form-filling G06F40/174)
- G06F 16/258: {Data format conversion from or to a database}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Embodiments of the present invention provide techniques for mapping hierarchical data from a query result into a tabular display, such as a spreadsheet. The tabular display allows some (or all) of the elements included in the hierarchical display to be mapped to positions on the report. In one embodiment, a field of the result that stores hierarchical data with repeating elements (e.g., an XML document) is mapped into the tabular report using jagged rows. This approach allows a user to map both the hierarchical and relational data in the result set to cells in the spreadsheet, and in the process, handle any embedded collection (repeated element) in the hierarchical data.

## Claims

### Claim 1

A computer-implemented method of representing hierarchical data from a database query result in a tabular display, comprising:
obtaining the database query result of an executed database query, wherein the query result includes one or more result fields, and wherein at least one of the result fields contains a hierarchal data object;
encapsulating the query result in a tree hierarchy;
retrieving mapping information defining mappings from one or more nodes of the tree hierarchy to specified cells of the tabular display, wherein at least one of the one or more nodes is flagged as a repeating node;
parsing the tree hierarchy to identify the one or more nodes mapped to the specified cells of the tabular display;
copying data values from the identified nodes of the tree hierarchy to the specified cells of the tabular display;
upon determining, based on the mapping information, that a current node being copied from the tree hierarchy to a cell of the tabular display is flagged as the repeating node, determining whether multiple instances of the repeating node are present in a given record of the query result; and
for each of the multiple instances of the repeating node present in the given record of the query result, incrementing a row position of the tabular display to which the current node is copied, while maintaining a column position of the tabular display to create a jagged row in the tabular display for the result fields that contain the hierarchal data object.

### Claim 2 (depends on 1)

The method of claim 1, wherein the tree hierarchy represents the query result as a single hierarchical document, wherein child nodes of a root node of the single hierarchical document are the rows of the query result, and wherein child nodes of each row are the one or more result fields included in the query result.

### Claim 3 (depends on 1)

The method of claim 1, further comprising, upon determining that the data values copied to the specified cells of the tabular display have been modified, copying the modified data values from the specified cells of the tabular display to the corresponding nodes of the tree hierarchy.

### Claim 4 (depends on 3)

The method of claim 3, further comprising, performing an update query to update the database with the modified data values copied to the tree hierarchy.

### Claim 5 (depends on 1)

The method of claim 1, wherein the tree hierarchy represents the query result as a single hierarchical document, wherein child nodes of the root node are the rows of the query result, and wherein child nodes of each row are the one or more fields.

### Claim 6 (depends on 1)

The method of claim 1, wherein the hierarchal data object is an XML document.

### Claim 7 (depends on 1)

The method of claim 1, wherein the database query is a relational database query.

### Claim 8 (depends on 1)

The method of claim 1, wherein the tabular display is a spreadsheet.

### Claim 9

A computer program product comprising a computer useable storage medium having a computer readable program, wherein the computer readable program when executed on a computer causes the computer to perform an operation to generate a tabular display of hierarchical data included in a database query result, the operation comprising:
obtaining the database query result of an executed database query, wherein the query result includes one or more result fields, and wherein at least one of the result fields contains a hierarchal data object;
encapsulating the query result in a tree hierarchy;
retrieving mapping information defining mappings from one or more nodes of the tree hierarchy to specified cells of the tabular display, wherein at least one of the one or more nodes is flagged as a repeating node;
parsing the tree hierarchy to identify the one or more nodes mapped to the specified cells of the tabular display;
copying data values from the identified nodes of the tree hierarchy to the specified cells of the tabular display;
upon determining, based on the mapping information, that a current node being copied from the tree hierarchy to a cell of the tabular display is flagged as the repeating node, determining whether multiple instances of the repeating node are present in a given record of the query result; and
for each of the multiple instances of the repeating node present in the given record of the query result, incrementing a row position of the tabular display to which the current node is copied, while maintaining a column position of the tabular display to create a jagged row in the tabular display for the result fields that contain the hierarchal data object.

### Claim 10 (depends on 9)

The computer-readable storage medium of claim 9, wherein the tree hierarchy represents the query result as a single hierarchical document, wherein child nodes of a root node of the single hierarchical document are the rows of the query result, and wherein child nodes of each row are the one or more result fields included in the query result.

### Claim 11 (depends on 9)

The computer-useable storage medium of claim 9, wherein the operation further comprises, upon determining that the data values copied to the specified cells of the tabular display have been modified, copying the modified data values from the specified cells of the tabular display to the corresponding nodes of the tree hierarchy.

### Claim 12 (depends on 11)

The computer-readable storage medium of claim 11, wherein the operation further comprises, performing an update query to update the database with the modified data values copied to the tree hierarchy.

### Claim 13 (depends on 9)

The computer-useable storage medium of claim 9, wherein the tree hierarchy represents the query result as a single hierarchical document, wherein child nodes of the root node are the rows of the query result, and wherein child nodes of each row are the one or more fields.

### Claim 14 (depends on 9)

The computer-useable storage medium of claim 9, wherein the hierarchal data object is an XML document.

### Claim 15 (depends on 9)

The computer-useable storage medium of claim 9, wherein the database query is a relational database query.

### Claim 16 (depends on 9)

The computer-useable storage medium of claim 9, wherein the tabular display is a spreadsheet.

### Claim 17

A system, comprising:
a processor; and
a memory containing a program which, when executed by the processor, is configured to:
obtain the database query result of an executed database query, wherein the query result includes one or more result fields, and wherein at least one of the result fields contains a hierarchal data object;
encapsulate the query result in a tree hierarchy;
retrieve mapping information defining mappings from one or more nodes of the tree hierarchy to specified cells of the tabular display, wherein at least one of the one or more nodes is flagged as a repeating node;
parse the tree hierarchy to identify the one or more nodes mapped to the specified cells of the tabular display;
copy data values from the identified nodes of the tree hierarchy to the specified cells of the tabular display;
upon determining, based on the mapping information, that a current node being copied from the tree hierarchy to a cell of the tabular display is flagged as the repeating node, determine whether multiple instances of the repeating node are present in a given record of the query result; and
for each of the multiple instances of the repeating node present in the given record of the query result, increment a row position of the tabular display to which the current node is copied and maintain a column position of the tabular display to create a jagged row in the tabular display for the result fields that contain the hierarchal data object.

### Claim 18 (depends on 17)

The system of claim 17, wherein the tree hierarchy represents the query result as a single hierarchical document, wherein child nodes of a root node of the single hierarchical document are the rows of the query result, and wherein child nodes of each row are the one or more result fields included in the query result.

### Claim 19 (depends on 17)

The system of claim 17, wherein the program is further configured to, upon determining that the data values copied to the specified cells of the tabular display have been modified, copy the modified data values from the specified cells of the tabular display to the corresponding nodes of the tree hierarchy.

### Claim 20 (depends on 19)

The system of claim 19, wherein the program is further configured to perform an update query to update the database with the modified data values copied to the tree hierarchy.

### Claim 21 (depends on 17)

The system of claim 17, wherein the tree hierarchy represents the query result as a single hierarchical document, wherein child nodes of the root node are the rows of the query result, and wherein child nodes of each row are the one or more fields.

### Claim 22 (depends on 17)

The system of claim 17, wherein the hierarchal data object is an XML document.

### Claim 23 (depends on 17)

The system of claim 17, wherein the database query is a relational database query.

### Claim 24 (depends on 17)

The system of claim 17, wherein the tabular display is a spreadsheet.
