Open topic with navigation

# SQL Fact Store Example

The following section describes an example of setting up a SQL backend Fact Bank.

A company wants to make its exports data available for question answering. It exports two products, Psi and Omega, to two countries, Germany and France.

In 2015, Psi cost €5 and Omega cost €20. The company exported:

- 50 units of Psi and 20 units of Omega to Germany.
- 10 units of Psi and 30 units of Omega to France.

In 2016, Psi cost €7 and Omega cost €18. Sales increased, and the company exported:

- 80 units of Psi and 100 units of Omega to Germany.
- 40 units of Psi and 50 units of Omega to France.

The following tables show the Fact Bank Facts and Qualifiers table for this information.

Facts Table
entity_code | property_code | property_value | qualifier_combination
--- | --- | --- | ---
`QPSI` | `REXPORTS` | 50 | 0
`QPSI` | `REXPORTS` | 10 | 1
`QPSI` | `REXPORTS` | 80 | 2
`QPSI` | `REXPORTS` | 40 | 3
`QOMEGA` | `REXPORTS` | 20 | 0
`QOMEGA` | `REXPORTS` | 10 | 1
`QOMEGA` | `REXPORTS` | 80 | 2
`QOMEGA` | `REXPORTS` | 40 | 3
`QPSI` | `RPRICE` | 5 | 4
`QOMEGA` | `RPRICE` | 20 | 4
`QPSI` | `RPRICE` | 7 | 5
`QOMEGA` | `RPRICE` | 18 | 5

Qualifiers Table
qualifier_combination | qualifier_code | qualifier_value
--- | --- | ---
0 | `S.COUNTRY` | Germany
0 | `S.YEAR` | 2015
1 | `S.COUNTRY` | France
1 | `S.YEAR` | 2015
2 | `S.COUNTRY` | Germany
2 | `S.YEAR` | 2016
3 | `S.COUNTRY` | France
3 | `S.YEAR` | 2016
4 | `S.YEAR` | 2015
5 | `S.YEAR` | 2016

The following example shows the entity code values in the `code_to_entity.txt` file:

    QPSI=Psi
    QOMEGA=Omega

The following example shows the property code values in the `code_to_property.txt` file:

    S.YEAR=Year,string
    S.COUNTRY=Country,string
    RPRICE=Price,string
    REXPORTS=Exports,string

You can use this Fact Bank setup to answer questions such as:

- What were the 2015 exports of Psi?
- How many Omega were exported to Germany?
- What is the average price of Omega?

Your Answer Server installation includes example files that allow you to test this setup. The example files are included in the `sql_example` directory.

To use this example, you must have a PostgreSQL instance (running on `PostgresHost` and `PostgresPort`, with a user who has access to a `factbank_example` database.

To set up the example

1. Restore the database from the factback_example.pgdump file into your PostgreSQL instance, by using a command of the following form:

       psql -h PostgresHost -p PostgresPort -U UserName factbank_example < factbank_example.pgdump

2. In your Answer Server configuration file, configure a Fact Bank system to use the plain text coding files provided in the example, by setting the `CodingsPath` parameter to point to the example coding files. For example:

       [MyExampleFactBank]
       Type=factbank
       CodingsPath=C:\AnswerServer\sql_example
       ...

3. In the Fact Bank system configuration, set the `ConnectionString` to the appropriate connection string for your example database.
4. In the Fact Bank system configuration, set the `EductionQuestionGrammars` parameters to the location of your `FactBankEductionGrammar.ecr`, which is distributed with Answer Server.
5. Save and close the configuration file.
6. Start all the Answer Server components.

You can now use the `Ask` action to ask the questions listed above and to check the responses.

© 2015-2018 Micro Focus or one of its affiliates | Send documentation feedback to Micro Focus Close Send documentation feedback To open the configured email client on this computer, open an email window. Otherwise, copy the information below to a web mail client, and send this email to swpdl.idoldocsfeedback@microfocus.com. We appreciate your feedback! Product: Topic Title: Help Topic: Feedback:

_FT_HTML5_bannerTitle.htm