Archive:Semantic MediaWiki database tables

THIS PAGE IS DEPRECATED AND REFERS TO AN OLD VERSION OF THE DATABASE.

In general, do not work on the DB directly, but always use the Store API instead. An SMW instance does not require to have a SMW SQL Store! It may use different stores instead. The Store API abstracts from that. Therefore this page is not only deprecated, but also not that much needed anymore, if you do not want to work on the SMW SQL Store.

Looking at SMW SQL statements
To see the SQL statements made during a page request, add the following variables to LocalSettings.php:

$wgDebugLogFile = "/path/to/log/file/debug.log"; $wgDebugDumpSql = true;

And you will be able to see them in the log file you specified in. You shouldn't have the debug file in a location accessible from the web.

Some SQL statements SMW makes get truncated in the log file. To fix this, change the number 500 to something larger, like 5000, in the file. It's also convenient to add a ";" to the end of the wfDegug string before the "\n", so that SQL statements can be directly copied from the logs and tested out in MySQL.

Before (line #s from MediaWiki 1.11):

751                if ( $this->debug ) { 752                        $sqlx = substr( $commentedSql, 0, 500 ); 753                        $sqlx = strtr( $sqlx, "\t\n", '  ' ); 754                        wfDebug( "SQL: $sqlx\n" ); 755                }

After:

751                if ( $this->debug ) { 752                        $sqlx = substr( $commentedSql, 0, 5000 ); 753                        $sqlx = strtr( $sqlx, "\t\n", '  ' ); 754                        wfDebug( "SQL: $sqlx;\n" ); 755                }

Looking at SMW database code
The SQL code is nearly all restricted to the file includes/storage/SMW_SQLStore.php. All or nearly all of the update and querying is through abstract functions defined by class SMWStore, such as  and , which class SMWSQLStore implements.

=Tables added by Semantic MediaWiki=

smw_attributes
This table was present in SMW 0.7.

The subject page is marked as having an attribute with a given value.

smw_longstrings
This table was added in SMW 1.0.

smw_nary
This table was added in SMW 1.0.

smw_nary_attributes
This table was added in SMW 1.0.

smw_nary_longstrings
This table was added in SMW 1.0.

smw_nary_relations
This table was added in SMW 1.0.

smw_relations
This table was present in SMW 0.7.

The subject is the page the annotation takes place on, and the object is annotated as having a given relation to it.

smw_specialprops
This table was present in SMW 0.7.

smw_subprops
This table was present in SMW 0.7.

= SMW Temporary Tables =

These describe temporary tables made during searches. They are all made in memory.

cat
Contains the lower closure of the given category with respect to the category table. Made by getCategoryTable in the class SMWSQLStore.

prop
Contains the lower closure of the given property with respect to the subproperty relation. Made by getPropertyTable in the class SMWSQLStore.

smw_res
=Tables SMW uses from the main MediaWiki database=

These tables weren't made by Semantic MediaWiki, but Semantic MediaWiki refers to them and uses them in SQL statements.