# US 2014/0208063 A1 · Polymorph table with shared columns

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

- Number: US 2014/0208063 A1
- Document ID: US20140208063A1
- Status: Published application
- Kind: A1
- Application number: 14/160,228
- Filed: 2014-01-21
- Published: 2014-07-24
- Earliest claimed: 2013-01-22
- Assignees: International Business Machines Corporation
- Applicants: International Business Machines Corporation
- Inventors: Gaetano Ruggiero
- Web page: https://patentgrep.com/patent/US20140208063A1

## CPC

- G06F 12/1036: for multiple virtual address spaces, e.g. segmentation (G06F12/1045 takes precedence)
- G06F 16/22: Indexing; Data structures therefor; Storage structures
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

For managing a database in a data-processing system, a polymorph table and a mapping structure are provided. The polymorph table includes a discrimination column and a total number of columns of each type equal to a maximum of the virtual columns of the type. The mapping structure stores information mapping each virtual column to a polymorph column of the same type. A virtual access request is received based on one of the virtual columns of one of the virtual tables. Selected mapping information is retrieved that maps each selected virtual column to one of the polymorph columns. The virtual access request is converted into a polymorph access request according to an identifier of the selected virtual table and the selected mapping information. The polymorph table is accessed according to the polymorph access request.

## Claims

### Claim 1

A method for managing a database in a data-processing system, the method comprising:
providing, for a set of virtual tables each one comprising a set of virtual columns each one of a data type, a polymorph table stored in the database and a mapping structure, the polymorph table comprising a discrimination column for storing an identifier of the virtual tables and a total number of polymorph columns of each data type equal to a maximum number of the virtual columns of the data type in the virtual tables, and the mapping structure storing mapping information mapping each virtual column to a corresponding one of the polymorph columns of the same data type,
receiving a virtual access request for accessing at least part of the virtual tables, the virtual access request being based on at least a selected one of the virtual columns of at least a selected one of the virtual tables,
retrieving selected mapping information mapping each selected virtual column to a selected one of the polymorph columns from the mapping structure,
converting the virtual access request into a polymorph access request for the polymorph table according to the identifier of said at least one selected virtual table and the selected mapping information, and
accessing the polymorph table according to the polymorph access request.

### Claim 2 (depends on 1)

The method according to claim 1, wherein each virtual table and the polymorph table are child tables of a parent table stored in the database, the parent table comprising at least one primary column being a primary key thereof, and each virtual table and the polymorph table comprising at least one foreign column being a foreign key referencing said primary key.

### Claim 3 (depends on 1)

The method according to claim 1, wherein each polymorph column has a polymorph name comprising an indication of the data type of the polymorph column and an indication of a progressive number of the polymorph column within the total number of the polymorph columns of the same data type.

### Claim 4 (depends on 1)

The method according to claim 1, wherein the converting the virtual access request into a polymorph access request comprises:
replacing a name of said at least one selected virtual table with a name of the polymorph table and a virtual name of each selected virtual column with a polymorph name of the corresponding selected polymorph column, and
adding a condition for the discrimination column based on the identifier of said at least one selected virtual table.

### Claim 5 (depends on 1)

The method according to claim 1, wherein the accessing the polymorph table according to the polymorph access request comprises:
retrieving a set of selected records from the polymorph table, for at least part of said at least one selected virtual columns each selected record comprising a selected field of the corresponding selected polymorph column,
assigning the selected fields of each selected polymorph column to the corresponding selected virtual column according to the selected mapping information, and
returning the selected records with each selected field thereof associated with the assigned selected virtual column.

### Claim 6 (depends on 1)

The method according to claim 1, wherein the step of providing, for a set of virtual tables each one comprising a set of virtual columns each one of a data type, a polymorph table stored in the database and a mapping structure includes:
receiving a request for adding a new virtual column of a new data type to a further selected virtual table,
adding a new polymorph column of the new data type to the polymorph table if the addition of the new virtual column increases the maximum number of the virtual columns of the new data type in the virtual tables, and
adding new mapping information mapping the new virtual column to a first available one of the polymorph columns of the new data type to the mapping structure.

### Claim 7 (depends on 6)

The method according to claim 6, wherein the step of providing, for a set of virtual tables each one comprising a set of virtual columns each one of a data type, a polymorph table stored in the database and a mapping structure includes:
receiving a request for adding at least one new virtual table with a set of new virtual columns each one of a new data type to the virtual tables, and
repeating, for each new virtual column, said step of adding a new polymorph column and said step of adding new mapping information.

### Claim 8 (depends on 6)

The method according to claim 6, wherein each polymorph column has a polymorph name comprising an indication of the data type of the polymorph column and an indication of a progressive number of the polymorph column within the total number of the polymorph columns of the same data type, and wherein the first available polymorph column of the new data type is the polymorph column being available with the polymorph name comprising the indication of the new data type and the lowest progressive number, the step of adding a new polymorph column including:
assigning a new polymorph name to the new polymorph column obtained by incrementing the highest progressive number in the polymorph names comprising the indication of the new data type.

### Claim 9 (depends on 1)

The method according to claim 1, wherein the step of providing, for a set of virtual tables each one comprising a set of virtual columns each one of a data type, a polymorph table stored in the database and a mapping structure includes:
receiving a request for removing at least one old virtual column of an old data type from a still further selected virtual table,
removing old mapping information mapping the old virtual column to a corresponding old polymorph column from the mapping structure,
copying, in each record of the polymorph table whose field in the discrimination column stores the identifier of the still further selected virtual table, a field in a last one of the polymorph columns of the old data type into a field in the old polymorph column when the old polymorph column is different from the last polymorph column, if the removal of the old virtual column reduces the maximum number of the virtual columns of the old data type in the virtual tables, and
removing the old polymorph column if the removal of the old virtual column reduces the maximum number of the virtual columns of the old data type in the virtual tables.

### Claim 10 (depends on 3, 9)

The method according to claim 9, when dependent directly or indirectly on claim 3, wherein the last polymorph column of the old data type is the polymorph column with the highest progressive number in the polymorph names comprising the indication of the old data type.

### Claim 11 (depends on 9)

The method according to claim 9, wherein the step of providing, for a set of virtual tables each one comprising a set of virtual columns each one of a data type, a polymorph table stored in the database and a mapping structure includes:
receiving a request for removing at least one old virtual table comprising a set of old virtual columns each one of an old data type,
repeating, for each old virtual column, said step of removing (648) old mapping information and said step of removing the old polymorph column, and
removing each record from the polymorph table whose field in the discrimination column stores the identifier of the old virtual table.

### Claim 12

A computer program product for facilitating communication between a client application and a server application, the computer program product comprising:
a computer readable storage medium having computer readable program code embodied therewith, the computer readable program code executable by a processor for:
providing, for a set of virtual tables each one comprising a set of virtual columns each one of a data type, a polymorph table stored in the database and a mapping structure, the polymorph table comprising a discrimination column for storing an identifier of the virtual tables and a total number of polymorph columns of each data type equal to a maximum number of the virtual columns of the data type in the virtual tables, and the mapping structure storing mapping information mapping each virtual column to a corresponding one of the polymorph columns of the same data type,
receiving a virtual access request for accessing at least part of the virtual tables, the virtual access request being based on at least a selected one of the virtual columns of at least a selected one of the virtual tables,
retrieving selected mapping information mapping each selected virtual column to a selected one of the polymorph columns from the mapping structure,
converting the virtual access request into a polymorph access request for the polymorph table according to the identifier of said at least one selected virtual table and the selected mapping information, and
accessing the polymorph table according to the polymorph access request.

### Claim 13 (depends on 12)

The computer program product according to claim 12, wherein each virtual table and the polymorph table are child tables of a parent table stored in the database, the parent table comprising at least one primary column being a primary key thereof, and each virtual table and the polymorph table comprising at least one foreign column being a foreign key referencing said primary key.

### Claim 14 (depends on 12)

The computer program product according to claim 12, wherein each polymorph column has a polymorph name comprising an indication of the data type of the polymorph column and an indication of a progressive number of the polymorph column within the total number of the polymorph columns of the same data type.

### Claim 15 (depends on 12)

The computer program product according to claim 12, wherein the program code is further executable by the processor for:
replacing a name of said at least one selected virtual table with a name of the polymorph table and a virtual name of each selected virtual column with a polymorph name of the corresponding selected polymorph column, and
adding a condition for the discrimination column based on the identifier of said at least one selected virtual table.

### Claim 16 (depends on 12)

The computer program product according to claim 12, wherein the program code is further executable by the processor for:
retrieving a set of selected records from the polymorph table, for at least part of said at least one selected virtual columns each selected record comprising a selected field of the corresponding selected polymorph column,
assigning the selected fields of each selected polymorph column to the corresponding selected virtual column according to the selected mapping information, and
returning the selected records with each selected field thereof associated with the assigned selected virtual column.

### Claim 17

A system comprising:
a processor configured to execute a module configured for:
providing, for a set of virtual tables each one comprising a set of virtual columns each one of a data type, a polymorph table stored in the database and a mapping structure, the polymorph table comprising a discrimination column for storing an identifier of the virtual tables and a total number of polymorph columns of each data type equal to a maximum number of the virtual columns of the data type in the virtual tables, and the mapping structure storing mapping information mapping each virtual column to a corresponding one of the polymorph columns of the same data type,
receiving a virtual access request for accessing at least part of the virtual tables, the virtual access request being based on at least a selected one of the virtual columns of at least a selected one of the virtual tables,
retrieving selected mapping information mapping each selected virtual column to a selected one of the polymorph columns from the mapping structure,
converting the virtual access request into a polymorph access request for the polymorph table according to the identifier of said at least one selected virtual table and the selected mapping information, and
accessing the polymorph table according to the polymorph access request.

### Claim 18 (depends on 17)

The system according to claim 17, wherein each virtual table and the polymorph table are child tables of a parent table stored in the database, the parent table comprising at least one primary column being a primary key thereof, and each virtual table and the polymorph table comprising at least one foreign column being a foreign key referencing said primary key.

### Claim 19 (depends on 17)

The system according to claim 17, wherein each polymorph column has a polymorph name comprising an indication of the data type of the polymorph column and an indication of a progressive number of the polymorph column within the total number of the polymorph columns of the same data type.

### Claim 20 (depends on 17)

The system according to claim 17, wherein the processor is further configured for:
replacing a name of said at least one selected virtual table with a name of the polymorph table and a virtual name of each selected virtual column with a polymorph name of the corresponding selected polymorph column, and
adding a condition for the discrimination column based on the identifier of said at least one selected virtual table.
