FAKTS software and database installation guide

advertisement
– FAKTS DATABASE INTERROGATION GUIDE –
February 2011
Luca Colombera – eelc@leeds.ac.uk
Contents
MYSQL installation ................................................................................................................................. 1
HeidiSQL installation.............................................................................................................................. 1
Loading FAKTS through HeidiSQL ....................................................................................................... 1
Loading FAKTS template queries through HeidiSQL ............................................................................ 5
Editing FAKTS queries through HeidiSQL ............................................................................................ 6
Exporting FAKTS data and query results from HeidiSQL to spreadsheets ............................................ 7
MYSQL installation
The FAKTS database runs on MySQL database management system. This software must be installed
on the machine in order to be able to load the FAKTS database.
MySQL Community Server 5.5 for Microsoft Windows environment is freely downloadable, after
registration, from http://dev.mysql.com/downloads/mysql/. 64-bit and 32-bit Windows versions can
be installed from the executable files mysql-5.5.9-winx64.exe and mysql-5.5.9-win32.exe included in
the FAKTS pack folder.
A reference manual of MySQL 5.5 is available at http://dev.mysql.com/doc/refman/5.5/en/; in
particular, guidance for installation can be found at http://dev.mysql.com/doc/refman/5.5/en/windowsinstallation.html.
A ‘developer machine’-‘multifunctional database’-‘decision support’ configuration is suggested on
installation.
IMPORTANT: during the installation process a root password can be set; this will be used for
database access through any front-end software.
HeidiSQL installation
The MySQL back-end can be accessed through a number of front-end tools. For FAKTS database
interrogation we suggest to employ the same GUI interface that is used by the FRG for managing data
entry, editing, query and export. This software is called HeidiSQL, and is freely downloadable (v. 6.0)
from here: http://www.heidisql.com/download.php. Alternatively, it can be installed from the
executable file HeidiSQL_6.0_Setup.exe included in the FAKTS pack folder. Periodic revisions of the
software can be downloaded from http://www.heidisql.com/download.php as executable files;
heidisql.r3700.exe, included in the FAKTS pack folder, is the revision 3700 of the software: it
comprises some updates to the installed v. 3603: just move this file to the HeidiSQL installation folder
and use it for accessing the FAKTS database.
Loading FAKTS through HeidiSQL
Launch HeidiSQL, a panel like the one in the following picture will appear.
To connect to a MySQL server, a session must be created: give a name to the local session (e.g.
FAKTS@local in the picture) and get local root access to it (User: root; Password: the password
chosen during MySQL installation).
1
After accessing the MySQL server, you should be able to see on the left a panel displaying all
the databases included.
Now you can load the FAKTS database from one of its SQL dump files. Choose Load SQL
file… from the Import menu.
2
Choose a FAKTS_ddmmyy SQL file (containing the database schema and data updated at the
date stated in the file name) and open it. A query window containing the SQL instruction will
be loaded; to execute it just click the blue arrow or press F9.
3
The FAKTS database is now loaded, to visualize it on the left-hand panel press the refresh
button or press F5.
The FAKTS database will appear under the name fluvial_db, and all the tables it includes will
be also displayed in the left-hand panel.
Now, it is possible to access the content of each table by clicking on them and selecting, in
the right-end panel, the Data tab.
4
Loading FAKTS template queries through HeidiSQL
After having loaded and selected the fluvial_db database in HeidiSQL, it is possible to load
the example queries provided as templates for database interrogation. Click on Load SQL
file… or press Ctrl + O.
Here it is possible to select the template query you want to run.
Once opened, the SQL instructions will be visualized in a tab on the right-hand panel.
To execute the query click the blue arrow or press F9; the results of the query will be shown
in a tab below the SQL tab.
5
Some queries generate results in form of tables; these tables can be shown within the
fluvial_db database by refreshing the left-hand panel (F5); click on the tables and select the
Data tab to visualize the results of the query.
The significance of each template query is clarified in the Template queries document.
Editing FAKTS queries through HeidiSQL
After being loaded, the SQL scripts can be edited in the same SQL text-tab on the right-hand
panel.
For example, you can load the template query tl_08:
SELECT b_subsets.subset_ID, b_subsets.relative_distality,
original_facies_type, facies_type, g_3_facies.thickness
FROM a_source_data
JOIN b_subsets ON a_source_data.case_ID = b_subsets.case_ID
JOIN c_1_depositional_elements ON b_subsets.subset_ID =
c_1_depositional_elements.subset_ID
JOIN e_2_architectural_elements ON c_1_depositional_elements.dep_el_ID =
e_2_architectural_elements.dep_el_ID
JOIN g_3_facies ON e_2_architectural_elements.arch_el_ID =
g_3_facies.arch_el_ID
WHERE a_source_data.case_ID = 23;
and change the case study unique identifier in the last line, in order to retrieve data about
another case history, e.g. case study ID nr. 11:
SELECT b_subsets.subset_ID, b_subsets.relative_distality,
original_facies_type, facies_type, g_3_facies.thickness
FROM a_source_data
JOIN b_subsets ON a_source_data.case_ID = b_subsets.case_ID
JOIN c_1_depositional_elements ON b_subsets.subset_ID =
c_1_depositional_elements.subset_ID
JOIN e_2_architectural_elements ON c_1_depositional_elements.dep_el_ID =
e_2_architectural_elements.dep_el_ID
JOIN g_3_facies ON e_2_architectural_elements.arch_el_ID =
g_3_facies.arch_el_ID
WHERE a_source_data.case_ID = 11;
6
Once the query has been modified, it can be executed by clicking on the blue arrow or
pressing F9.
An online manual to SQL syntax for MySQL
http://dev.mysql.com/doc/refman/5.0/en/sql-syntax.html.
can
be
found
at
Some queries involve the creation of temporary tables; to re-run the query the temporary
tables should be deleted (http://dev.mysql.com/doc/refman/5.5/en/drop-table.html), or the
session should be re-accessed. If non-temporary tables are created, these must be necessarily
dropped to re-run the query.
Exporting FAKTS data and query results from HeidiSQL to spreadsheets
The result of a query (either within the query result tab or in form of a generated table), as
well as all the data included in the FAKTS data tables, can be exported in .csv format simply
by selecting the data, right-clicking on it, then choosing Copy data and Copy selected rows as
CSV.
7
Then the result can be pasted, for example, in .txt files, that can be loaded into a Microsoft
Excel spreadsheet, for data analysis (N.B. semicolon used as a separator between columns).
8
9
Download