A method and system for data processing

The method of generating new primary key columns and creating a linking table in relational databases addresses the inefficiencies and inaccuracies of traditional JOINs, ensuring reliable and accurate data querying and processing.

WO2024179947A1PCT designated stage expired Publication Date: 2024-09-06PUPPINI FRANCESCO
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
PCT/EP2024/054732
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-02-28
Filing Date
2024-02-25
Publication Date
2024-09-06

AI Technical Summary

Technical Problem

Traditional relational databases face issues with computational efficiency and accuracy in querying data due to the need for multiple JOINs, which can lead to inaccurate results and data loss, especially when handling tables with measures and orphan rows.

Method used

A method and system that generate new primary key columns and create a linking table with specific columns to redefine links between data tables, allowing for querying without traditional JOINs, thereby reducing computational expense and ensuring accurate data processing.

Benefits of technology

This approach enhances data processing reliability by eliminating duplicate information, preventing data loss, and enabling accurate calculations across multiple tables without requiring users to understand the underlying database structure.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure EP2024054732_06092024_PF_FP
    Figure EP2024054732_06092024_PF_FP
Patent Text Reader

Abstract

The present invention relates to a method of storing and querying data in a relational database including a plurality of original data tables, including the steps of: generating a new primary key column for each original table, creating a linking table with, at least, the following columns: a table name column and a new foreign key column corresponding to the new primary key column for each original table, and querying the database using the linking table. The linking table defines links between the data tables using the new foreign key columns. A system and software are also herein described.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] A Method and System for Data Processing Field of Invention The present invention is in the field of data processing. More particularly, but not exclusively, the present invention relates to storing and querying data in relational databases. Background Traditional relational databases are formed of tables which are connected to one another through primary and foreign keys. A foreign key column in a first table references the rows in a second table via a primary key column. For example, a particular value of a Product ID from a foreign key column in a Sales table might reference a Product row within a Product table (e.g. a Sales row with Sales ID = 201, Date = 01 / 01 / 2010, Amount = £100, Product ID = 7 has a primary key Sales ID = 201 and a foreign key Product ID = 7, and references the row in Product table where the primary key of Product table is Product ID = 7). Typically, to query such a database, a query might be constructed in SQL, and to query the Product Name for a Sale, the Sales table has a LEFT JOIN to the Product table. Therefore, the query might look like SELECT Sales.Sales ID, Product.Product Name FROM Sales LEFT JOIN Product on Sales.Product ID=Product.Product ID. However, LEFT JOINs may be expensive from a computational and memory perspective and it can be seen that at least one JOIN is necessary for each query which obtains information from multiple tables. Furthermore, when tables are JOINed, if the user formulating the query does not understand the underlying structure of the database, queries comprising calculations on columns which contain measures can result in inaccurate information. For example, in the previous example, if the Product table included a column (Total) which totalled the number of that Product created, then a query to retrieve the total number of products sold as a proportion of products created would be incorrect because SELECT sum(Sales.Quantity) / sum(Product.Total) FROM Sales LEFT JOIN Product on Sales.Product ID=Product.Product ID would duplicate the Product.Totals for each Sales row referencing the same Product ID. This means that traditional relational databases and the typical means for accessing them by users are inherently unreliable. Numerous solutions have been built to attempt to solve some of these problems. In an attempt to solve the problem of JOINs being executed for each query, a super table can be constructed JOINing all tables into one. However, this table comprises a vast amount of duplicate information. In an attempt to solve the problem of inaccurate calculations, some database systems use computationally expensive processes which pre-process the data in an attempt to remove duplicate measures. Disadvantages of all of the solutions noted above is that they potentially lose data during JOINs if there is an orphan row in a table joined from the right side. For example, in the Sales / Products example if there is a Product_ID for which there have been no sales, it disappears from a query with a “Sales LEFT JOIN Product”. It is an object of the present invention to provide a method and system for storing and querying data in relational databases which overcomes the disadvantages of the prior art, or at least provides a useful alternative. Summary of Invention According to a first aspect of the invention there is provided a method of storing and querying data in a relational database including a plurality of original data tables, including: a) generating a new primary key column for each original table; b) creating a linking table with, at least, the following columns: a table name column and a new foreign key column corresponding to the new primary key column for each original table; and c) querying the database using the linking table; wherein the linking table defines links between the data tables using the new foreign key columns. According to another aspect of the invention there is provided a system for storing data in a relational database including a plurality of data tables, including: One or more processors configured for generating a new primary key column for each data table, creating a linking table with the following columns: table name column and a new foreign key column corresponding to the new primary key column for each table and querying the database using the linking table; and One or more memory configured for storing the relational database and the linking table; wherein the linking table define links between the data tables using the new foreign key columns Other aspects of the invention are described within the claims. Brief Description of the Drawings Embodiments of the invention will now be described, by way of example only, with reference to the accompanying drawings in which: Figure 1: shows a block diagram illustrating a system in accordance with an embodiment of the invention; Figure 2: shows a flow diagram illustrating a method in accordance with an embodiment of the invention; Figure 3: shows a flow diagram illustrating a method in accordance with an embodiment of the invention; Figure 4: shows a block diagram illustrating a distributed shard-style database system in accordance with an embodiment of the invention; Figure 5: shows a flow diagram illustrating a method for processing data within the system of Figure 4 in accordance with an embodiment of the invention; Figure 6: shows a flow diagram illustrating a method in accordance with an embodiment of the invention; Figure 7: shows a table where a linking table has been JOINed with tables from a relational database illustrating a method in accordance with an embodiment of the invention; Figures 8 to 9: show tables generated by prior art solutions; and Figures 10 to 11: show tables illustrating interim data processing using a method in accordance with an embodiment of the invention. Detailed Description of Preferred Embodiments The present invention provides a method and system for storing and querying data in a relational database. The inventor has discovered that constructing a specially configured linking table combining specific columns from original tables within a relational database and then using that linking table to query the database can solve numerous problems with existing relational databases. It will be understood that where the term relational databases are used, this also covers any system where the data is stored in a structured fashion comparable to tables where linkages corresponding to primary and foreign keys between the structured data exist. Such parallels can be found in flat files (Excel, CSV, etc.), hierarchical files (XML, JSON, etc.), and any system (MongoDB, Hadoop, Apache Hive, etc.) where the data can be transformed into tables equivalent to a relational database. In Figure 1, a system 100 for storing and querying data in a relational database in accordance with embodiments of the invention is shown. A server 101 is shown. The server 101 may comprise one or more processors 102. The server 100 may further comprise one or more memory 103 to interoperate with the one or more processors 102. The server 101 may further comprise one or more communication apparatuses 104 to interface with other devices or databases. A first database system 105 is shown. The first database system 105 may be configured for storing a relational database or databases. The relational database may comprise a plurality of tables. The tables may be interconnected via foreign keys referencing primary keys. The server 101 may be configured for processing the tables within the first database system 105. The server 101 may process the tables by transforming the tables (for example, by adding a new primary key column) and by creating stage tables for each transformed table comprising a table name column, a new foreign key column corresponding to the new primary key column, and foreign key columns referencing the new primary key columns of the other transformed tables. The server 101 may be configured for creating a linking table by binding the stage tables together (e.g. by a UNION). The server 101 may store the transformed tables, stage table and linking tables in either in the first database system 105, the one or more memory 103, and / or in a second database system 106. The second database system 106 is shown. The second database system 106 may be configured for storing transformed tables, stage tables, the linking table, and / or a query table formed by a JOIN of the linking tables and one or more transformed tables. The server 101 may be connected to the first and / or second database 105 and 106 systems via a networking system 107. In some embodiments, the first and / or second database system 105 and 106 may exist within the server 101. A requester apparatus 108 is shown. The requester apparatus 108 may be connected to the server 101 via the networking system 107. The requester apparatus 108 may be another server or a user device. The requester apparatus 108 may transmit a query to the server 101. The server 101 may be further configured to process the query by applying the query to the query table. In this example, the server 101 is shown as a single apparatus, but it will be appreciated by those skilled in the art that the server 101 may comprise multiple physical devices co-located or distributed and connected by a networking system 107. Referring to Figure 2, a method 200 for storing and querying data in a relational database in accordance with embodiments of the invention will be described. The relational database is initially comprised of a plurality of original tables. As is standard within relational databases, each original table comprises a primary key column, and one or more columns comprising data. Some original tables may further comprise one or more foreign key columns referencing the primary key columns of other of the original tables. Some of the data columns may comprise measures. A measure is a property upon which calculations can be made (e.g., sum, count, average, minimum, maximum). In step 201, a new primary key column is generated for each original table. To perform this, the original table may first be transformed to form a transformed table. The tables may first be loaded into a memory from storage to enable transformation of the tables. Advantages of creating a new primary key column are that embodiments can work with legacy databases with idiosyncratic naming conventions or no naming conventions. Furthermore, it eliminates duplicate column names used within databases constructed without duplicate column name constraints. This may be necessary for some embodiments in order that the linking table can be constructed. Furthermore, it may be advantageous to keep the old primary key column for redundancy and interoperation with other or legacy systems such as journaling systems. The name of the new primary key column may follow a defined naming convention. The naming convention may be configured to ensure that the name of the new primary key column is a unique name for a column across all the tables. For example, the naming convention may be predefined string + original table name. In embodiments, the new primary key column is defined as the first column in the transformed table. Each table may be further transformed by selecting columns within the table which contains measures. In one embodiment, all columns which are measures are selected. In another embodiment, the measures columns which are selected are only those where the table’s primary key is used as a foreign key in another table. In embodiments, the measure columns which are selected are those where the table’s primary key is used as a foreign key in a second table and where the measures are at risk of duplication. This occurs where that first table has a higher level of detail than the second table. The selected columns may be modified. In one embodiment, the selected columns may be modified by deleting the columns from the transformed table. In another embodiment, the selected columns are modified by renaming the selected columns. In some embodiments, the selected columns may be renamed or deleted in the transformed table after the stage table has been created from the transformed table. Advantages of modifying the measures columns for transformed tables may result in improved accuracy for calculations on measures columns. The problems of measures columns will be described later in this document. Accuracy improvements result in a more reliable data processing system. A stage table may be created for each of the transformed tables. The stage table may be created by creating a new column where each cell of the new column is the name of the transformed table. In embodiments, this new column is defined as the first column of the stage table. This new column may be called, for example, “Stage” for each stage table. The creation of the stage table may also include: a) copying the new primary key column from the transformed table to the stage table as a new foreign key column; b) copying one or more, or all, of the foreign key columns from the transformed table to the stage table. The foreign key columns may be renamed to the name of the new primary key column of the transformed data table for which the foreign key is the primary key; and / or c) copying selected columns which contain measures. Where the selected columns have been renamed in the corresponding transformed table, the selected columns may be renamed back to the original name. The columns which contain measures that are selected for copying may be those measure columns which are at risk of duplication. In some embodiments, all measure columns may be copied to the stage table. This may be particularly useful where the business intelligence tool administering the database and the tables created by the present invention is a system such as Google’s Looker which will perform unnecessary optimisations on the other tables unless all the measures are moved such that the linking table is the only table comprising measures. In step 202, a linking table is created. The linking table includes, at least, the following columns: a table name column and a copy of the new primary key column for each original table as new foreign key columns. The linking table may be created by the union (i.e. binding) of two or more of the new stage tables. In some embodiments, the linking table is created by the union of all of the new stage tables. In embodiments, the linking table is first created by defining a single column (corresponding to the first column of the stage tables, e.g. named “Stage”) with no rows before the union operation is performed. An “all data” table may be created by joining each of the transformed data tables to the linking table. The “all data” table may be persistent. In step 203, the relational database is queried using the linking table. The step of querying the database may include querying the “all data” table constructed from the linking table without the use of JOIN. Alternatively, the step of querying the database may include JOINing two or more transformed tables to the linking table. In some embodiments, all of the transformed tables may be JOINed to the linking table. The JOINs may be dynamic (i.e. when the query is made) or periodic. Referring to Figure 3, a method 300 for storing and querying data in a relational database in accordance with embodiments of the invention will be described. In this method, new columns may be created for the stage tables for derived keys. In step 301, the new primary key column for the original table is generated. The original table is transformed by the addition of this new primary key column. In step 302, a stage table is created for each transformed table. The stage table comprises, at least, a table name column (for the stage table’s name), the new foreign key column corresponding to the new primary key column, and any foreign key columns. In step 303, where a foreign key column in a first transformed table references a primary key column in a second transformed table, and that second transformed table includes a foreign key column which references a primary key column in a third transformed table, a new column for the stage table for the first transformed table is created which is a derived key column referencing the primary key column of the third transformed table. In step 304, the linking table is created by a UNION of two or more stage tables with at least the following columns: a stage table name column and the new foreign key column for each stage table. In step 305, the database is queried using the linking table. In embodiments, the method of Figure 3 also includes one or more of the additional features described in relation to the method of Figure 2. An example, illustrating step 302 above, is provided below: Given initial transformed tables shown below: Sales _PBK_Sales Sales Client Product S1 S1 C1 P1 S2 S2 C3 P1 Client _PBK_Client Client Country C1 C1 US C2 C2 MX C3 C3 MX Country _PBK_Country Country Country_Name US US United States MX MX Mexico Product _PBK_Product Product Factory P1 P1 F1 P2 P2 F2 Factory _PBK_Factory Factory Factory_Location Factory_Target F1 F1 Manchester 1000 F2 F2 Birmingham 2000 When the stage table for Sales is created, Sales_PBS, a new column for a derived key can be added to Sales_PBS named _PBK_Country based on the primary key column in Country table being referenced by a foreign key column in Client, and the primary key column in Client being referenced in Sales. Furthermore, a new column for a derived key can be added to Sales_PBS named _PBK_Factory based on the primary key column in Factory table being referenced by a foreign key column in Product, and the primary key column in Product being referenced in Sales. A stage table Sales_PBS with the new derived key columns is shown below: Sales_PBS Stage _PBK_ _PBK_Client _PBK_Product _PBK_Country _PBK_Factory Sales Sales S1 C1 P1 US F1 Sales S2 C3 P1 MX F1 Referring to Figure 4, a system 400 for storing and querying data in a relational database in accordance with embodiments of the invention is shown. In Figure 4, the relational database is distributed across different servers 401, 402, and 403 and databases 404, 405, and 406 located in different geographies. This type of architecture may be described as a shard database. Database software systems that provide shard architectures include Apache Hadoop. Hadoop provides a logical table to a user (or requester) and manages the distribution across the geographically distributed databases. For example, a Sales table might be split by rows into three different database servers. A server 406 may be connected to the different database servers 401, 402, and 403 via a networking system 407. The server 406 may perform the functions of the method 200 described in relation to Figure 2. A separate stage table may be created for each portion of the tables in the shard architecture. For example, a Sales 1 stage table, a Sales 2 stage table, and a Sales 3 stage table. The stage tables may be stored in their respective databases 404, 405, and 406. The stage tables may include a new column specifying the physical name of the table (i.e. “Sales 1”, “Sales 2”, “Sales 3”) in addition to the column specifying the logical names of the tables (i.e. “Sales” for all three). The database software system (e.g. Hadoop) providing the shard architecture will sew together the tables when the UNION for the linking table is requested. Referring to Figure 5, a method 500 for storing and querying data in a relational database which exists across the distributed architecture shown in Figure 4 in accordance with embodiments of the invention will be described. In step 501, the new primary key column for each original table is generated. In step 502, a stage table is created for each original table where a stage table is created for each physical original table. The stage table includes a column for the logical stage table name column and a column for the physical stage table name column. In step 503, the linking table is created with the logical stage table name column and new foreign key columns using a UNION of two or more stage tables within the distributed database software system. In step 504, the database is queried using the linking table. In embodiments, the method of Figure 5 includes one or more of the additional features described in relation to the method of Figure 2. Referring to Figure 6, a method 600 for storing and querying data in a relational database in accordance with embodiments of the invention will be described. A worked example will be described below to illustrate one embodiment of the invention. It will be appreciated that a skilled person would be understand that different examples could be formulated to illustrate the full range of alternative embodiments of the invention. The example will be described with reference to the following original tables within the database: Sales Sales Client Product S1 C1 P1 S2 C3 P1 Client Client Country C1 US C2 MX C3 MX Country Country Country_Name US United States MX Mexico Product Product Factory P1 F1 P2 F2 Factory Factory Factory_Location Factory_Target F1 Manchester 1000 F2 Birmingham 2000 In step 601, each original table is transformed into a transformed table. This process involves the following sub-steps: 601a : a new primary key column is generated for each original table using the prefixing of the following string to the original table name (_PBK_). 601b : each table may be further transformed by selecting columns within the table which contains measures which are at risk of duplication. The column Factory_Target is a measure at risk of duplication. This column is deleted. The transformed tables are shown below: Sales _PBK_Sales Sales Client Product S1 S1 C1 P1 S2 S2 C3 P1 Client _PBK_Client Client Country C1 C1 US C2 C2 MX C3 C3 MX Country _PBK_Country Country Country_Name US US United States MX MX Mexico Product _PBK_Product Product Factory P1 P1 F1 P2 P2 F2 Factory _PBK_Factory Factory Factory_Location F1 F1 Manchester F2 F2 Birmingham In step 602, a stage table may be created for each of the transformed tables. This process involves the following sub-steps: 602a : creating a table name column populated with the name of the original table; 602b : copying the new primary key column from the transformed table to the stage table to act as a new foreign key column; 602c : copying one or more, or all, of the foreign key columns from the transformed table to the stage table. The foreign key columns are renamed to the name of the new primary key column of the transformed data table for which the foreign key is the primary key; 602d : copying columns which contain measures that are at risk of duplication and 601e : when a foreign key column in a first transformed table references a primary key column in a second transformed table, and that second transformed table includes a foreign key column which references a primary key column in a third transformed table, a new column may be created for the stage table for that first transformed table which is a derived key column referencing the primary key column of the third transformed table. An example of code in R used to create a derived key column for the Sales_PBS stage table is shown below: Sales_join_Client_join_Product = Sales %>% left_join(., Client, by = c("Client" = "_PBK_Client")) %>% # Appending to sales all the columns from Client left_join(., Product, by = c("Product" = "_PBK_Product")) # Appending to sales all the columns from Product Sales_PBS = Sales_join_Client_join_Product[, c(1,3,4,6,8)] # KEYS - Getting from Sales_join_Client_join_Product only the PK and FK columns. This includes the derived keys Sales_PBS$Stage = "Sales" # STAGE - Adding the stage column Sales_PBS = Sales_PBS[, c(6, 1:5)] # REORDER - Moving the stage column to the very first position colnames(Sales_PBS) = c("Stage", "_PBK_Sales", "_PBK_Client", "_PBK_Product", "_PBK_Country", "_PBK_Factory") # RENAME - Giving the correct names The stage tables are shown below: Sales_PBS Stage _PBK_Sales _PBK_Client _PBK_Product _PBK_Country _PBK_Factory Sales S1 C1 P1 US F1 Sales S2 C3 P1 MX F1 Client_PBS Stage _PBK_Client _PBK_Country Client C1 US Client C2 MX Client C3 MX Country_PBS Stage _PBK_Country Country US Country MX Product_PBS Stage _PBK_Product _PBK_Factory Product P1 F1 Product P2 F2 Factory_PBS Stage _PBK_Factory Factory_Target Factory F1 1000 Factory F2 2000 In step 603, a linking table is created. The linking table includes the following columns: a table name column, the new foreign key column for each original table, and any measure columns in the stage tables. The linking table is created by the union of the stage tables. The linking table is shown below: Stage _PBK_Sales _PBK_Client _PBK_Product _PBK_Country _PBK_Factory Factory_Target Sales S1 C1 P1 US F1 Sales S2 C3 P1 MX F1 Client C1 US Client C2 MX Client C3 MX Country US Country MX Product P1 F1 Product P2 F2 Factory F1 1000 Factory F2 2000 In step 604, the relational database is queried using the linking table. The step of querying the database involves the all of the transformed tables being JOINed to the linking table before an SQL query is made. The JOINed table “Query_Table” is shown in Figure 7. Example SQL queries and the results are shown below: Obtain the total factory targets across all factories: SELECT SUM(Factory_Target) FROM Query_Table Result: 3000 Number of sales in the United States: SELECT COUNT(_PBK_Sales) FROM Query_Table WHERE Country_Name=”United States” Result: 1 Proportion of Sales Made for a Factory: SELECT Factory_Location, COUNT((_PBK_Sales) / SUM(Factory_Target) FROM Query_Table GROUP BY Factory Result: Manchester, 0.002 Birmingham, 0 Referring to Figures 8 to 11, embodiments of the present invention will be described. In the following description, these embodiments will be referred to as the Linking System and the linking table in these embodiments will be referred to as the Linking Table. It will be appreciated that this is an exemplary description only and that not all the features described are essential to the present invention. A simple Microsoft Excel data source will be used in this description and pseudo-code in the R language will be used to illustrate how embodiments of the invention may be constructed. It will be appreciated by those skilled in the art that any number of implementations and languages may be utilized. Some problems with existing solutions will now be illustrated: # The data is loaded setwd("C: / FP / Dropbox / _MyDataFP / Patent") # Setting the work folder, where the Excel file is located library(readxl) # Used for interacting with Excel library(dplyr) # Used for various functions of data transformation library(expss) # Used for various functions of data transformation # Load the table of Sales sales = read_excel("DataSource.xlsx", sheet="sales") # reading sales from Excel sales Sales Sales Sales Sales Sales Sales Sales Sales Date Client Country Product ProductLi Targ Sales Notes ID Amount ID ID ID ne ID et ID 1 2019-01-01 CL01 US PR01 C US-C 100 NA 2 2019-01-02 CL02 US PR02 C US-C 100 NA 3 2019-01-03 CL03 MX PR03 C MX-C 100 NA 4 2019-01-04 CL04 IT PR04 A IT-A 100 NA 5 2019-01-05 CL05 IT PR05 A IT-A 100 NA 6 2019-01-06 CL06 IT PR01 C IT-C 100 NA 7 2019-01-07 CL07 ES PR02 C ES-C 100 NA 8 2019-01-08 CL08 ES PR03 C ES-C 100 NA 9 2019-01-09 CL01 US PR04 A US-A 100 NA 10 2019-01-10 CL02 US PR05 A US-A 100 NA 11 2019-01-11 CL03 MX PR01 C MX-C 100 NA 12 2019-01-12 CL04 IT PR02 C IT-C 100 NA 13 2019-01-13 CL05 IT PR03 C IT-C 100 NA 14 2019-01-14 CL06 IT PR04 A IT-A 100 NA 15 2019-01-15 CL07 ES PR05 A ES-A 100 NA 16 2019-01-16 CL08 ES PR01 C ES-C 100 NA 17 2019-01-17 CL01 US PR02 C US-C 100 NA 18 2019-01-18 CL02 US PR03 C US-C 100 NA 19 2019-01-19 CL03 MX PR04 A MX-A 100 NA 20 2019-01-20 CL99 NA PR99 NA NA 100 This row of Sales has an unreferenced Client ID # Load the table of Targets: it represents "how much we aim to sell until the end of this year" targets = read_excel("DataSource.xlsx", sheet="targets") # reading targets from Excel targets Target Target Target Target Country Product Line Target Notes ID Amount ID ID 1 US-C US C 40000 NA 2 US-A US A 20000 NA 3 MX-C MX C 30000 NA 4 MX-A MX A 15000 NA 5 IT-C IT C 20000 NA 6 IT-A IT A 10000 NA 7 ES-C ES C 14000 NA 8 ES-A ES A 5000 NA This row of Targets has no associated C 9 PT-C PT 10000 Sales yet This row of Targets has no associated A 10 PT-A PT 1000 Sales yet This row of Targets has no associated X 11 PT-X PT 1000 Sales yet This row of Targets has no associated C 12 BR-C BR 10000 Sales yet This row of Targets has no associated A 13 BR-A BR 1000 Sales yet This row of Targets has no associated X 14 BR-X BR 1000 Sales yet For a calculation that involves data from two tables, a join is usually created. A join of two tables is a new table that has columns from both original tables 5 Joins may be easy to create, but they can be problematic when tables contain "measures". Measures are numbers that describe and quantify the business (in this 10 example, Sales_Amount and Target_Amount are measures). The tables that are joined, usually, do not have the same number of rows. When two tables are joined, the resulting table will have a number of rows that 15 usually differs from the two original tables. If a table contains measures, these measures may get duplicated or lost, causing incorrect totals. 20 In the prior art, incorrect totals are a frequent problem, as can be seen below. Here is a join between Sales and Targets: sales_full_join_targets = sales %>% 25full_join(., targets, by = c("Sales_Target_ID" = "Target_ID"))sales join targets Sales Sales Sales Sales Sales Target Target Sales Date Client Country product ProductLine Target Sales Sales Country Product Target Target ID ID ID ID ID Amount Notes ID Line ID Amount Notes 2019-01-01 CL01 US PR01 C US-C 100 NA US C 40000 NA 2019-01-02 CL02 US PR02 C US-C 100 NA US C 40000 NA 2019-01-03 CL03 MX PR03 C MX-C 100 NA MX C 30000 NA 2019-01-04 CL04 IT PR04 A IT-A 100 NA IT A 10000 NA 2019-01-05 CL05 IT PR05 A IT-A 100 NA IT A 10000 NA 2019-01-06 CL06 IT PR01 C IT-C 100 NA IT C 20000 NA 2019-01-07 CL07 ES PR02 C ES-C 100 NA ES C 14000 NA 2019-01-08 CL08 ES PR03 C ES-C 100 NA ES C 14000 NA 2019-01-09 CL01 US PR04 A US-A 100 NA US A 20000 NA 2019-01-10 CL02 US PR05 A US-A 100 NA US A 20000 NA 2019-01-11 CL03 MX PR01 C MX-C 100 NA MX C 30000 NA 2019-01-12 CL04 IT PR02 C IT-C 100 NA IT C 20000 NA 2019-01-13 CL05 IT PR03 C IT-C 100 NA IT C 20000 NA 2019-01-14 CL06 IT PR04 A IT-A 100 NA IT A 10000 NA 2019-01-15 CL07 ES PR05 A ES-A 100 NA ES A 5000 NA 2019-01-16 CL08 ES PR01 C ES-C 100 NA ES C 14000 NA 2019-01-17 CL01 US PR02 C US-C 100 NA US C 40000 NA 2019-01-18 CL02 US PR03 C US-C 100 NA US C 40000 NA 2019-01-19 CL03 MX PR04 A MX-A 100 NA MX A 15000 NA The original Sales table has 20 rows. The original Targets table has 14 rows. The join between these two tables, sales_join_targets, has 19 rows. 5 Some measures have been duplicated (e.g. Target Amount = 40000 now appears multiple times). Some other measures have been lost (e.g. Sales Amount = 100 on January 20th is now lost). The totals of sales_join_targets do not match the totals of the original tables. 0 This is a problem. The lost measures can be adjusted with the "full join" command. Here is a full join between Sales and Targets: 5 sales_full_join_targets = sales %>% full_join(., targets, by = c("Sales_Target_ID" = "Target_ID")) The output of the full join is shown in Figure 8. With the full join, the total Sales Amount is now correct, but the total Target Amount is still incorrect because of duplicates. Why does Target Amount have duplicates? Because of the different "level of detail": Targets is less detailed. A row of Targets is associated with multiple rows of Sales, and that's why there are duplicates. A typical prior art solution is to bring the two tables to the same level of detail. In this case, Sales is brought to the level of detail of Targets. This can be achieved by a standard operation, widely used today, called "AGGREGATION". AGGREGATION is the operation of merging multiple rows into one single row. But this comes with a price: aggregation is only possible if some columns are removed. For example, an aggregation of Sales would be impossible if Sales_ID is not removed. To have the same level of detail as Targets, most columns must be removed (Sales_Date, Sales_Client_ID, etc.). Sales aggregation is shown below: sales_aggr = sales %>% group_by(Sales_Target_ID) %>% summarize(Sales_Amount = sum(Sales_Amount, na.rm=T)) sales aggr Sales Target ID Sales Amount 1 ES-A 100 2 ES-C 300 3 IT-A 300 4 IT-C 300 5 MX-A 100 6 MX-C 200 7 US-A 200 8 US-C 400 9 NA 100 TOT = 2000 In this new table "sales_aggr", the grand total of Sales_Amount is correct: 2000 But, to achieve a level of detail compatible with Targets, several columns had to be removed. Now the two tables can be joined. Once the two tables are joined, it is possible to compare the measures (by ratio, difference, etc). Comparing Sales vs Targets: sales_vs_targets = sales_aggr %>% inner_join(., targets, by = c("Sales_Target_ID" = "Target_ID")) %>% mutate(Ratio = Sales_Amount / Target_Amount, Diff = Sales_Amount-Target_Amount) sales vs targets Target Target Sales Target Target Sales_Target_ID Country Product Ratio Diff Amount Amount Notes ID Line ID ES-A 100 ES A 5000 NA 0.020000000 -4900 ES-C 300 ES C 14000 NA 0.021428571 -13700 IT-A 300 IT A 10000 NA 0.030000000 -9700 IT-C 300 IT C 20000 NA 0.015000000 -19700 MX-A 100 MX A 15000 NA 0.006666667 -14900 MX-C 200 MX C 30000 NA 0.006666667 -29800 US-A 200 US A 20000 NA 0.010000000 -19800 US-C 400 US C 40000 NA 0.010000000 -39600 This solution, as it exists today, works but the resulting table sales_vs_targets has lost some detail. To extract a new report from this table, may not be possible. For example the "sales by client name" or "sales by product name", cannot be obtained by sales_vs_targets. However, this information can still be found in the original tables, by doing different combinations of aggregation and join. In the prior art, the way to combine the tables together always depends on the specific question that is to be answered. Here is an example of the code to get the "sales by product name": # Load the table of Products products = read_excel("DataSource.xlsx", sheet="products") # reading products from Excel products Product ID Product Name Product ProdLine ID Product Notes 1 PR01 Prod1 C NA 2 PR02 Prod2 C NA 3 PR03 Prod3 C NA 4 PR04 Prod4 A NA 5 PR05 Prod5 A NA This product 6 PR06 Prod6 A has no Sales # sales_join_products sales_join_products = sales %>% left_join(., products, by = c("Sales_Product_ID" = "Product_ID")) The output of the join above is shown in Figure 9. With the join, the columns coming from the Products table are appended to the right. Now the tables can be aggregated. # sales_by_product_name sales_by_product_name = sales_join_products %>% group_by(Product_Name) %>% summarize(Sales_Amount = sum(Sales_Amount, na.rm=T)) sales by product name Product Name Sales Amount 1 Prod1 400 2 Prod2 400 3 Prod3 400 4 Prod4 400 5 Prod5 300 6 NA 100 After the join, the aggregation produces the desired result: "sales by product name". This time the join was first, and the aggregation after. Instead, for sales_vs_targets the aggregation was first, and the join after. The steps of calculation must be decided each time by a human, on a case by case basis and cannot be automated in the prior art. If now "Sales by Client name" is required, you must start again from the original tables. Here is the code of "Sales by Client name": # Load the table of Clients clients = read_excel("DataSource.xlsx", sheet="Clients") # reading Clients from Excel clients Client Client Client Client Country ID Name Segment ID Client Notes 1 CL01 Client 01 Standard US NA 2 CL02 Client 02 Standard US NA 3 CL03 Client 03 Gold MX NA 4 CL04 Client 04 Gold IT NA 5 CL05 Client 05 Standard IT NA 6 CL06 Client 06 Gold IT NA 7 CL07 Client 07 Standard ES NA 8 CL08 Client 08 Gold ES NA 9 CL09 Client 09 Standard ES This Client has no Sales # sales_by_client_name sales_by_client_name = sales %>% left_join(., clients, by = c("Sales_Client_ID" = "Client_ID")) %>% group_by(Client_Name) %>% summarize(Sales_Amount = sum(Sales_Amount, na.rm=T)) sales by client name Client Name Sales Amount 1 Client 01 300 2 Client 02 300 3 Client 03 300 4 Client 04 200 5 Client 05 200 6 Client 06 200 7 Client 07 200 8 Client 08 200 9 Client 09 100 This is how reports are built today: for each new question, new code must be written. Embodiments of the present invention (termed the Linking System / LS) introduces an important innovation: the "universal query". The LS code may written only once, and may answer all the possible questions. The LS may connect all the tables together, regardless of the question. The LS may connect all the tables together, without losing information. The LS may connect all the tables together, following a standard process. The LS may always delivers correct measures (no losses, no duplicates). The LS is centered on a table called the "Linking Table". The steps on how the Linking Table are built (Steps 1-3) and how it may be used (Steps 4-6) will be described. STEP 1: Reading all the Excel data source tables, and transforming them into "Transformed Tables" Below are basic terminology used in the remainder of the description: Primary Key (PK): a unique identifier for the rows of a table. It is a column containing an ID that uniquely identifies a row of that table. Example: in the Clients table, Client_ID is a PK. Foreign Key (FK): a key referencing the PK of another table. Example: in the Sales table, Sales_Client_ID is a FK referencing the PK of Clients A "Transformed Table" is a table quite similar to the original but with some small transformations. The transformations are needed because the LS uses a strict "NAMING CONVENTION". The NAMING CONVENTION may be important because it simplifies the way how data connects. It consists of a set of rules to be followed (in this embodiment). Due to the naming convention, the end users do not need to be data experts. Rule 1: Each table has an additional copy of the PK column, with name: "_PBK_TableName" (e.g. _PBK_Sales, _PBK_Clients, etc) It will be appreciated that, aside from “_PBK_” , alternative prefixes may be used. When names are identical, most programming languages connect the tables automatically by those names. Rule 2: The "_PBK_TableName" column of each table is in the first position. This makes it easier to handle. Rule 3: In this embodiment, no other column names can have the prefix: "_PBK_" Rule 4: All column names are preferably understandable and non-ambiguous. Rule 5: The same column name cannot appear in multiple Transformed Tables in this embodiment. In other words, for each column name, it is possible to know exactly in what Transformed Table it can be found (i.e. Customer ZIPCODE and Supplier ZIPCODE columns). Rule 6: In this embodiment, the only possible repetition is with _PBK_ columns across multiple Stage Tables. For example, _PBK_Clients appears in clients_pbs but also in sales_pbs sales = read_excel("DataSource.xlsx", sheet="Sales") # reading Salesfrom Excel sales$`_PBK_Sales` = sales$`Sales_ID` # adding the _PBK_ column, with name _PBK_Sales sales = sales[, c(10, 1:9)] # moving the _PBK_ column to the first positionSales Sales Sales Sales Sales PBK Sales Sales Sales Sales Date Client Country Product ProductLine Sales Notes Sales ID Target ID Amount ID ID ID ID 1 1 2019-01-01 CL01 US PR01 C US-C 100 NA 2 2 2019-01-02 CL02 US PR02 C US-C 100 NA 3 3 2019-01-03 CL03 MX PR03 C MX-C 100 NA 4 4 2019-01-04 CL04 IT PR04 A IT-A 100 NA 5 5 2019-01-05 CL05 IT PR05 A IT-A 100 NA 6 6 2019-01-06 CL06 IT PR01 C IT-C 100 NA 7 7 2019-01-07 CL07 ES PR02 C ES-C 100 NA 8 8 2019-01-08 CL08 ES PR03 C ES-C 100 NA 9 9 2019-01-09 CL01 US PR04 A US-A 100 NA 10 102019-01-10 CL02 US PR05 A US-A 100 NA 11 112019-01-11 CL03 MX PR01 C MX-C 100 NA 12 122019-01-12 CL04 IT PR02 C IT-C 100 NA 13 132019-01-13 CL05 IT PR03 C IT-C 100 NA 14 142019-01-14 CL06 IT PR04 A IT-A 100 NA 15 152019-01-15 CL07 ES PR05 A ES-A 100 NA 16 162019-01-16 CL08 ES PR01 C ES-C 100 NA 17 172019-01-17 CL01 US PR02 C US-C 100 NA 18 182019-01-18 CL02 US PR03 C US-C 100 NA 19 192019-01-19 CL03 MX PR04 A MX-A 100 NA This row of Sales has an 20 202019-01-20 CL99 NA PR99 NA NA 100 unreferenced Client ID clients = read_excel("DataSource.xlsx", sheet="Clients") # as above, for all the other data source tables clients$`_PBK_Clients` = clients$`Client_ID` # as above, for all theother data source tables clients = clients[, c(6, 1:5)] # as above, for all the other data source tables clients PBK Client Client Client Client Client Notes Clients ID Name Segment Country ID 1 CL01 CL01 Client 01 Standard US NA 2 CL02 CL02 Client 02 Standard US NA 3 CL03 CL03 Client 03 Gold MX NA 4 CL04 CL04 Client 04 Gold IT NA 5 CL05 CL05 Client 05 Standard IT NA 6 CL06 CL06 Client 06 Gold IT NA 7 CL07 CL07 Client 07 Standard ES NA 8 CL08 CL08 Client 08 Gold ES NA This Client has no 9 CL09 CL09 Client 09 Standard ES Sales products = read_excel("DataSource.xlsx", sheet="Products") products$`_PBK_Products` = products$`Product_ID` products = products[, c(5, 1:4)] products PBK Product Product Product Products ID Name ProdLine ID Product Notes 1 PR01 PR01 Prod1 C NA 2 PR02 PR02 Prod2 C NA 3 PR03 PR03 Prod3 C NA 4 PR04 PR04 Prod4 A NA 5 PR05 PR05 Prod5 A NA 6 PR06 PR06 Prod6 A This product has no Sales countries = read_excel("DataSource.xlsx", sheet="Countries") countries$`_PBK_Countries` = countries$`Country_ID` countries = countries[, c(4, 1:3)] countries PBK Countries Country ID Country Name Country Notes 1 US US United States NA 2 MX MX Mexico NA 3 IT IT Italy NA 4 ES ES Spain NA There are no Clients from this 5 PT PT Portugal Country productlines = read_excel("DataSource.xlsx", sheet="ProductLines") productlines$`_PBK_ProductLines` = productlines$`Product_Line_ID` productlines = productlines[, c(4, 1:3)] productlines PBK ProductLines Product ProductLine Product Line Notes Line ID Name 1 C C Clothing NA 2 A A Accessories NA There are no Products with this 3 X X Special Category targets = read_excel("DataSource.xlsx", sheet="Targets") = targets Target Target PBK Target Country Product Target Targets ID ID Line IDAmount FanTarget Notes1 US-C US-C US C 40000 NA 2 US-A US-A US A 20000 NA 3 MX-C MX-C MX C 30000 NA 4 MX-A MX-A MX A 15000 NA 5 IT-C IT-C IT C 20000 NA 6 IT-A IT-A IT A 10000 NA 7 ES-C ES-C ES C 14000 NA 8 ES-A ES-A ES A 5000 NA This row of Targets has 9 PT-C PT-C PT C 10000 no associated Sales yet This row of Targets has 10 PT-A PT-A PT A 1000 no associated Sales yet 11 PT-X PT-X PT X 1000 This row of Targets has no associated Sales yet This row of Targets has 12 BR-C BR-C BR C 10000 no associated Sales yet This row of Targets has 13 BR-A BR-A BR A 1000 no associated Sales yet This row of Targets has 14 BR-X BR-X BR X 1000 no associated Sales yet STEP 2: Creating all the "Stage Tables" ("Linking Table Stage" Tables) The Stage Tables are the components of the Linking Table. They are tables containing only keys (and measures, if needed). Each Stage Table starts with a column called "Stage", which specifies "where the table originates from". Below illustrates the creation of the Stage Tables: # Creating the stage sales_pbs sales_pbs = sales[, c(1,4,5,6,7,8)] # KEYS - Getting from sales only the PK and FK columns. sales_pbs$Stage = "Sales" # STAGE - Adding the stage columnsales_pbs = sales_pbs[, c(7, 1:6)] # REORDER - Moving the stagecolumn to the very first position colnames(sales_pbs) = c("Stage", "_PBK_Sales", "_PBK_Clients", "_PBK_Countries", "_PBK_Products", "_PBK_ProductLines", "_PBK_Targets") # RENAME - Giving the correct names Sales_pbs PBK PBK PBK PBK PBK PBK Stage Sales Clients Countries Products ProductLines Targets 1 Sales 1 CL01 US PR01 C US-C 2 Sales 2 CL02 US PR02 C US-C 3 Sales 3 CL03 MX PR03 C MX-C 4 Sales 4 CL04 IT PR04 A IT-A 5 Sales 5 CL05 IT PR05 A IT-A 6 Sales 6 CL06 IT PR01 C IT-C 7 Sales 7 CL07 ES PR02 C ES-C 8 Sales 8 CL08 ES PR03 C ES-C 9 Sales 9 CL01 US PR04 A US-A 10 Sales 10 CL02 US PR05 A US-A 11 Sales 11 CL03 MX PR01 C MX-C 12 Sales 12 CL04 IT PR02 C IT-C 13 Sales 13 CL05 IT PR03 C IT-C 14 Sales 14 CL06 IT PR04 A IT-A 15 Sales 15 CL07 ES PR05 A ES-A 16 Sales 16 CL08 ES PR01 C ES-C 17 Sales 17 CL01 US PR02 C US-C 18 Sales 18 CL02 US PR03 C US-C 19 Sales 19 CL03 MX PR04 A MX-A 20 Sales 20 CL99 NA PR99 NA NA All the key columns are renamed to _PBK_TableName format. As can be seen, for each original table there is now a pair "TableName" and "TableName_pbs". For example, for Sales (original) there is now "sales" (adapted to naming convention) and "sales_pbs". The sales table is the "Transformed Table" and it contains the actual data. The sales_pbs, instead, contains the "connectors" (e.g. _PBK_columns). The _Stage Tables may also contain measures, when measures are at risk of duplication (see Target_Amount later). # Creating the stage clients_pbs clients_pbs = clients[, c(1,5)] # KEYS clients_pbs$Stage = "Clients" # STAGE clients_pbs = clients_pbs[, c(3, 1, 2)] # REORDER colnames(clients_pbs)[3] = "_PBK_Countries" # RENAME clients pbs Stage PBK Clients PBK Country 1 Clients CL01 US 2 Clients CL02 US 3 Clients CL03 MX 4 Clients CL04 IT 5 Clients CL05 IT 6 Clients CL06 IT 7 Clients CL07 ES 8 Clients CL08 ES 9 Clients CL09 ES # Creating the stage products_pbs products_pbs = products[, c(1,4)] # KEYS products_pbs$Stage = "Products" # STAGE products_pbs = products_pbs[, c(3, 1, 2)] # REORDER colnames(products_pbs)[3] = "_PBK_ProductLines" # RENAME Products_pbs Stage PBK Products PBK ProductLines 1 Products PR01 C 2 Products PR02 C 3 Products PR03 C 4 Products PR04 A 5 Products PR05 A 6 Products PR06 A # Creating the stage countries_pbs countries_pbs = countries[, c(1)] # KEYS countries_pbs$Stage = "Countries" # STAGE countries_pbs = countries_pbs[, c(2, 1)] # REORDER # No need for renaming here: there is only one _PBK_ column, and it already has the correct name countries pbs PBK Stage Countries 1 Countries US 2 Countries MX 3 Countries IT 4 Countries ES 5 Countries PT# Creating the stage productlines_pbsproductlines_pbs = productlines[, c(1)] # KEYS productlines_pbs$Stage = "ProductLines" # STAGE productlines_pbs = productlines_pbs[, c(2, 1)] # REORDER # No need for renaming here: there is only one _PBK_ column, and it already has the correct name productlines_pbs Stage PBK ProductLines 1 ProductLines C 2 ProductLines A 3 ProductLines X # Creating the stage targets_pbs targets_pbs = targets[, c(1,3,4,5)] # KEYS - Additionally, this timewe also copy "Target Amount"targets_pbs$Stage = "Targets" # STAGE targets_pbs = targets_pbs[, c(5, 1:4)] # REORDER colnames(targets_pbs) = c("Stage", "_PBK_Targets", "_PBK_Countries", "_PBK_ProductLines", "Target_Amount") # RENAME target pbs PBK Stage PBK Targets PBK Countries ProductLines Target Amount 1 Targets US-C US C 40000 2 Targets US-A US A 20000 3 Targets MX-C MX C 30000 4 Targets MX-A MX A 15000 5 Targets IT-C IT C 20000 6 Targets IT-A IT A 10000 7 Targets ES-C ES C 14000 8 Targets ES-A ES A 5000 9 Targets PT-C PT C 10000 10 Targets PT-A PT A 1000 11 Targets PT-X PT X 1000 12 Targets BR-C BR C 10000 13 Targets BR-A BR A 1000 14 Targets BR-X BR X 1000 There is only one measure in targets: the Target Amount (which we have previously renamed as "Target_Amount_Fan"). This measure is at risk of being duplicated because there is a stage table (sales_pbs) that has the key to targets, and an incompatible level of detail. When targets are joined to the Linking Table, the Sales stage will have duplicates of the Target Amount. In this examples, both instances of Target Amount are retained, with two different names, as follows: Target_Amount_Fan is a column of the targets table (the "Transformed Table"). This one will suffer from duplicates. Target_Amount is a column of the targets_Stage Table (The "Stage Table"). This one will only appear in the Targets stage, with no duplicates. STEP 3: Building the Linking Table Building the puppini_bridge_start. This is a table with a "Stage" column and no rows. All stages are merged to this one: puppini_bridge_start = data.frame(Stage=character()) Linking Table start Stage No data available in table puppini_bridge = puppini_bridge_start %>% bind_rows(., sales_pbs) %>% bind_rows(., clients_pbs) %>% bind_rows(., countries_pbs) %>% bind_rows(., products_pbs) %>% bind_rows(., productlines_pbs) %>% bind_rows(., targets_pbs)

[0002] sales pbs PBK PBK PBK PBK PBK PBK Target Stage Sales Clients Countries Products ProductLines Targets Amount 1 Sales 1 CL01 US PR01 C US-C NA 2 Sales 2 CL02 US PR02 C US-C NA 3 Sales 3 CL03 MX PR03 C MX-C NA 4 Sales 4 CL04 IT PR04 A IT-A NA 5 Sales 5 CL05 IT PR05 A IT-A NA 6 Sales 6 CL06 IT PR01 C IT-C NA 7 Sales 7 CL07 ES PR02 C ES-C NA 8 Sales 8 CL08 ES PR03 C ES-C NA 9 Sales 9 CL01 US PR04 A US-A NA 10 Sales 10 CL02 US PR05 A US-A NA 11 Sales 11 CL03 MX PR01 C MX-C NA 12 Sales 12 CL04 IT PR02 C IT-C NA 13 Sales 13 CL05 IT PR03 C IT-C NA 14 Sales 14 CL06 IT PR04 A IT-A NA 15 Sales 15 CL07 ES PR05 A ES-A NA 16 Sales 16 CL08 ES PR01 C ES-C NA 17 Sales 17 CL01 US PR02 C US-C NA 18 Sales 18 CL02 US PR03 C US-C NA 19 Sales 19 CL03 MX PR04 A MX-A NA 20 Sales 20 CL99 NA PR99 NA NA NA 21 Clients NA CL01 US NA NA NA NA 22 Clients NA CL02 US NA NA NA NA 23 Clients NA CL03 MX NA NA NA NA 24 Clients NA CL04 IT NA NA NA NA 25 Clients NA CL05 IT NA NA NA NA 26 Clients NA CL06 IT NA NA NA NA 27 Clients NA CL07 ES NA NA NA NA

[0003] Linking Table PBK PBK PBK PBK PBK PBK Target Stage Sales Clients Countries Products ProductionLines Targets Amount 27 Clients NA CL07 ES NA NA NA NA 28 Clients NA CL08 ES NA NA NA NA 29 Clients NA CL09 ES NA NA NA NA 30 Countries NA NA US NA NA NA NA 31 Countries NA NA MX NA NA NA NA 32 Countries NA NA IT NA NA NA NA 33 Countries NA NA ES NA NA NA NA 34 Countries NA NA PT NA NA NA NA 35 Products NA NA NA PR01 C NA NA 36 Products NA NA NA PR02 C NA NA 37 Products NA NA NA PR03 C NA NA 38 Products NA NA NA PR04 A NA NA 39 Products NA NA NA PR05 A NA NA 40 Products NA NA NA PR06 A NA NA 41 ProductsLines NA NA NA NA C NA NA 42 ProductsLines NA NA NA NA A NA NA 43 ProductsLines NA NA NA NA X NA NA 44 Targets NA NA US NA C US-C 40000 45 Targets NA NA US NA A US-A 20000 46 Targets NA NA MX NA C MX-C 30000 47 Targets NA NA MX NA A MX-A 15000 48 Targets NA NA IT NA C IT-C 20000 49 Targets NA NA IT NA A IT-A 10000 50 Targets NA NA ES NA C ES-C 14000 51 Targets NA NA ES NA A ES-A 5000 52 Targets NA NA PT NA C PT-C 10000 53 Targets NA NA PT NA A PT-A 1000 54 Targets NA NA PT NA X PT-X 1000 55 Targets NA NA BR NA C BR-C 10000 56 Targets NA NA BR NA A BR-A 1000 57 Targets NA NA BR NA X BR-X 1000 The table below illustrates which blocks are populated and which blocks are not: Stage\Key _KEY_Sales _KEY_Clients _KEY_Countries _KEY_Products _KEY_ProductLines _KEY_Targets Sales Populated Populated Populated Populated Populated Populated Clients NULL Populated Populated NULL NULL NULL Countries NULL NULL Populated NULL NULL NULL Products NULL NULL NULL Populated Populated NULL ProductLines NULL NULL NULL NULL Populated NULL Targets NULL NULL Populated NULL Populated Populated 5 STEP 4: Building the all_data table, where everything is merged together The all_data table contains the Linking Table joined with all the Transformed Tables 10 It all starts with the Linking Table: STEP 4: Building the all_data table, where everything is merged together 15 The all_data table contains the Linking Table joined with all the Transformed Tables It all starts with the Linking Table as shown in Figure 10. STEP 5: Creating queries against the all_data table In the Introduction, three different queries required three different ways to connect the tables. For sales_vs_targets, aggregation was performed first, and then the join. For sales_by_product_name, the join was first, and then aggregation. For sales_by_client_name, a different join was performed, and then a different aggregation. In each of these three examples, it was necessary to connect the tables based on the question to answer (i.e. based upon the query). The disadvantage of the prior art is that connecting tables require knowledge of the underlying data structure which results in increased difficulty in extracting information from the database. The all_data table shown above is an example of the Linking System which provides a solution to the disadvantages of the prior art. Every query can be resolved using that table. The solution is based on the Linking Table, which sews together all the Transformed Tables. Below is an illustration of how the three prior queries can be answered by the pre-connected table: Query 1: sales_vs_targets: sales_vs_targets = all_data[c(1:20,44:57),] %>% # Keeping only a subset of the table [grabbing a subset or rows, i.e. 1-20 and 44-57] group_by(Country_Name, ProductLine_Name) %>% summarize(Sales_Amount = sum(Sales_Amount, na.rm=T), Target_Amount=sum(Target_Amount,na.rm=T) ) %>% mutate(Ratio = Sales_Amount / Target_Amount, Diff = Sales_Amount-Target_Amount) sales vs targets Country ProductLine Sales Target Name Name Amount Amount Ratio Diff 1 Italy Accessories 300 100000.030000000 -9700 2 Italy Clothing 300 200000.015000000 -19700 3 Mexico Accessories 100 150000.006666667 -14900 4 Mexico Clothing 200 300000.006666667 -29800 5 Portugal Accessories 0 10000.000000000 -1000 6 Portugal Clothing 0 100000.000000000 -10000 7 Portugal Special 0 10000.000000000 -1000 8 Spain Accessories 100 50000.020000000 -4900 9 Spain Clothing 300 140000.021428571 -13700 10 United States Accessories 200 200000.010000000 -19800 11 United States Clothing 400 400000.010000000 -39600 12 NA Accessories 0 10000.000000000 -1000 13 NA Clothing 0 100000.000000000 -10000 14 NA Special 0 10000.000000000 -1000 15 NA NA 100 0 Inf 100 As can be seen the code above does not require any JOINs. Standard modern Business Intelligence tool can perform the above code with a simple and intuitive interface to the database. Therefore, users, without data expertise, can define queries to extract information from the pre-connected table. Query 2: sales_by_product_name: # sales_by_product_name sales_by_product_name = all_data %>% group_by(Product_Name) %>% summarize(Sales_Amount = sum(Sales_Amount, na.rm=T)) sales by product name Product Name Sales Amount 1 Prod1 400 2 Prod2 400 3 Prod3 400 4 Prod4 400 5 Prod5 300 6 Prod6 0 7 NA 100 As for above, no JOINs are necessary. Query 3: sales_by_client_name: sales_by_client_name = all_data %>% group_by summarize(Sales_Amount = sum(Sales_Amount, na.rm=T)) sales by client name Client Name Sales Amount 1 Client 01 300 2 Client 02 300 3 Client 03 300 4 Client 04 200 5 Client 05 200 6 Client 06 200 7 Client 07 200 8 Client 08 200 9 Client 09 0 10 NA 100 As for both the first and second queries, no JOINs are necessary. STEP 6: Creating lightweight queries using only the Stage Tables and Transformed Tables required to fulfil the query When the data set is too large, a table containing all the data may not be optimal. In these cases, in embodiments of the invention, light queries can be constructed, where only the required information is retrieved from the database. In STEP 2, the Stage Tables were created. Instead of sewing all the tables together (as was done in STEP 3), only the portion of data that is required can be sewn together. An advantage of the LS is that also in these cases the users of the database to not need to know "how to connect tables". This may be handled automatically by the "naming convention" of the LS. Once again, the three initial queries will be defined for this embodiment of the invention. puppini_bridge_start = data.frame(Stage=character()) In these explanation, query 2 and 3 will be described and then query 1. Query 2: sales_by_product_name_light: sales_by_product_name_light = puppini_bridge_start %>% bind_rows(., sales_pbs) %>% bind_rows(., products_pbs) %>% left_join(., sales) %>% left_join(., products) %>% group_by(Product_Name) %>% summarize(Sales_Amount = sum(Sales_Amount, na.rm=T)) The above query is "lightweight" because it only selects what is required. Each table comes in pairs (Stage + Transformed). The Stage Tables (containing the connectors) get "binded". The Transformed Tables (containing the actual data) get "joined". The difference between binded and joined is very simple. The "binded" tables "have the rows below each other". The "joined" tables "have the columns next to each other". Figure 11 shows two binded tables (1101 and 1102) and two joined tables (1103 and 1104). Please notice that the joined table of products has 4 columns, and they enrich both stages: the one above and the one below. Instead, the columns of Sales only enrich the stage above, and they are NULL in the one below. Embodiments of the invention described above perform the following steps: bind, join, and aggregate. The result of the three steps is the following: sales by product name light Product Name Sales Amount 1 Prod1 400 2 Prod2 400 3 Prod3 400 4 Prod4 400 5 Prod5 300 6 Prod6 0 7 NA 100 Query 3: sales_by_client_name_light: sales_by_client_name_light = puppini_bridge_start %>% bind_rows(., sales_pbs) %>% bind_rows(., clients_pbs) %>% left_join(., sales) %>% left_join(., clients) %>% group_by(Client_Name) %>% summarize(Sales_Amount = sum(Sales_Amount, na.rm=T)) sales by client name light Client Name Sales Amount 1 Client 01 300 2 Client 02 300 3 Client 03 300 4 Client 04 200 5 Client 05 200 6 Client 06 200 7 Client 07 200 8 Client 08 200 9 Client 09 0 10 NA 100 Query 1: sales_vs_targets_light: sales_vs_targets_light = puppini_bridge_start %>% bind_rows(., sales_pbs) %>% bind_rows(., targets_pbs) %>% left_join(., sales) %>% left_join(., targets) %>% left_join(., countries) %>% left_join(., productlines) %>% group_by(Country_Name, ProductLine_Name) %>% summarize(Sales_Amount = sum(Sales_Amount, na.rm=T), Target_Amount=sum(Target_Amount,na.rm=T) ) %>% mutate(Ratio = Sales_Amount / Target_Amount, Diff = Sales_Amount-Target_Amount) sales vs targets light ProductLine Sales Target Country Name Name Amount Amount Ratio Diff 1 Italy Accessories 300 10000 0.030000000 -9700 2 Italy Clothing 300 20000 0.015000000 -19700 3 Mexico Accessories 100 15000 0.006666667 -14900 4 Mexico Clothing 200 30000 0.006666667 -29800 5 Portugal Accessories 0 1000 0.000000000 -1000 6 Portugal Clothing 0 10000 0.000000000 -10000 7 Portugal Special 0 1000 0.000000000 -1000 8 Spain Accessories 100 5000 0.020000000 -4900 9 Spain Clothing 300 14000 0.021428571 -13700 10 United States Accessories 200 20000 0.010000000 -19800 11 United States Clothing 400 40000 0.010000000 -39600 12 NA Accessories 0 1000 0.000000000 -1000 13 NA Clothing 0 10000 0.000000000 -10000 14 NA Special 0 1000 0.000000000 -1000 15 NA NA 100 0 Inf 100 Potential advantages of some embodiments of the present invention include the following: a) The use of the linking table constructed in accordance with embodiments of the invention result in an improved database system where any JOINs applied result in smaller tables. This requires much lower computational effort and lower memory costs but results in the same accurate queries. b) Furthermore, the construction of a linking table results in an improved database system where JOINs can be utilised with less tables or reduced rows but retaining accurate calculations. This is useful for very large data structures. c) In addition, in some embodiments, the use of a linking table and the management of measure columns as described enables accurate calculations to be made. This results in a more reliable database system then prior art database systems. d) Users can construct queries for the database system without needed to understand the database structure and without the need to formulate a complex sequence of joins and aggregations. This results in simplified database development and simplified utilisation of databases within software applications. e) Lastly, the improvements described above can be deployed to distributed database architectures. While the present invention has been illustrated by the description of the embodiments thereof, and while the embodiments have been described in considerable detail, it is not the intention of the applicant to restrict or in any way limit the scope of the appended claims to such detail. Additional advantages and modifications will readily appear to those skilled in the art. Therefore, the invention in its broader aspects is not limited to the specific details, representative apparatus and method, and illustrative examples shown and described. Accordingly, departures may be made from such details without departure from the spirit or scope of applicant’s general inventive concept.

Claims

Claims 1. A method of storing and querying data in a relational database including a plurality of original data tables, including: a) generating a new primary key column for each original table; b) creating a linking table with, at least, the following columns: a table name column and a new foreign key column corresponding to the new primary key column for each original table; and c) querying the database using the linking table; wherein the linking table defines links between the data tables using the new foreign key columns.

2. A method as claimed in claim 1, further including loading each of a plurality of tables for the relational database into a memory.

3. A method as claimed in any one of claims 1 to 2, further including transforming the plurality of data tables.

4. A method as claimed in claim 3, wherein transforming the plurality of data tables includes generating the new primary key column for each table.

5. A method as claimed in claim 4, wherein the name of each new primary key column follows a defined naming convention.

6. A method as claimed in claim 5, wherein the name of each new primary key column is a unique name for a column across the plurality of data tables.

7. A method as claimed in any one of claims 4 to 6, wherein transforming the plurality of data tables further includes selecting at least some of the columns which contain measures.

8. A method as claimed in claim 7, wherein the selected columns are modified.

9. A method as claimed in claim 8, wherein the selected columns are modified by renaming.

10. A method as claimed in claim 8, wherein the selected columns are modified by deletion from the original data tables.

11. A method as claimed in any one of claims 7 to 10, wherein the selected columns reside within a table which has its primary key referenced by a foreign key within at least one other table.

12. A method as claimed in any one of claims 7 to 11, wherein all the columns which contain measures are selected.

13. A method as claimed in any one of claims 3 to 12, further including creating a new stage table for each of the transformed data tables.

14. A method as claimed in claim 13, wherein each new stage table is created by creating a new stage column where each cell of the stage column is the name of the transformed data table, and copying the new primary key column from the transformed data table to act as the new foreign key column.

15. A method as claimed in claim 14, wherein copying one or more of the columns from the transformed data table which are foreign keys columns or selected columns which contain measures.

16. A method as claimed in claim 15, further including the step of renaming the foreign key column to the name of the new primary key column of the transformed data table for which the foreign key is the primary key.

17. A method as claimed in any one of claims 14 to 16, wherein the linking table is created by union of two or more of the new stage tables.

18. A method as claimed in claim 17, wherein the linking table is created by union of all of the new stage tables.

19. A method as claimed in claim 18, further including creating an all data table by joining each of the transformed data tables to the linking table.

20. A method as claimed in claim 19, wherein the all data table is persistent.

21. A method as claimed in any of claims 19 to 20, wherein querying the database includes the step of querying the all data table without the use of JOINs.

22. A method as claimed in any one of claims 3 to 21, wherein querying the database includes joining two or more transformed tables to the linking table.

23. A method as claimed in claim 22, wherein querying the database includes joining all of the transformed tables to the linking table.

24. A method as claimed in any one of the preceding claims when dependent on claim 13, further including creating one or more new columns within a stage table for each of one or more transformed tables within a chain of transformed tables where a preceding transformed table is connected to a succeeding transformed table via aforeign key of the preceding transformed table to the primary key of the succeeding transformed table, wherein each new column is a derived key which is obtained from the primary key of a transformed table two or more transformed tables along from the beginning of the chain.

25. A method as claimed in claim 24, wherein a new column is created for the stage table being a derived key obtained from the primary key of a transformed table for every transformed table in the chain at least two transformed tables along from the location of the transformed table which relates to the stage table.

26. A method as claimed in claim 25, wherein the chain is a branched chain such that one or more preceding transformed tables in the chain is connected to a plurality of succeeding transformed tables.

27. A method as claimed in any one of claims 24 to 26, wherein one or more new columns are created for a stage table for every transformed table within the chain up to the last two transformed tables within the chain.

28. A method as claimed in any one of the preceding claims, wherein at least one of the tables exists split by row across a plurality of servers into a table portion on each server.

29. A method as claimed in claim 28 when dependent on claim 3, wherein a transformed table is created for each table portion on its server.

30. A method as claimed in claim 29 when dependent on claim 13, wherein a stage table is created for each transformed table on its server.

31. A method as claimed in claim 30, wherein a first new column is created within the stage table wherein each cell of the first new stage column isa name related to the transformed table and wherein a second new column is created within the stage table wherein each cell of the second new stage column is the name of the split table.

32. A system for storing data in a relational database including a plurality of data tables, including: One or more processors configured for generating a new primary key column for each data table, creating a linking table with the following columns: table name column and a new foreign key column corresponding to the new primary key column for each table and querying the database using the linking table; and One or more memory configured for storing the relational database and the linking table; wherein the linking table defines links between the data tables using the new foreign key columns.

33. Software configured for performing the method of any one of claims 1 to 31.