A store that holds statements in an SQL database.
|
This class is abstract and is inherited by classes for particular database backends. Backends are provided for MySQL and SQLite in separate assemblies. Rather than referencing those assemblies and using their constructors to create stores for those databases, it is easier to use SemWeb.Store.CreateForInput(string) or SemWeb.Store.CreateForOutput(string). Both methods return SQLStores that can be used for both reading and writing.
The SQLStore uses three tables, one containing the statement triples (actually quadruples with meta information) using numeric identifiers for each resource, one mapping entity identifiers to URIs, and the last mapping literal identifiers to string/language/datatype triples. The CREATE statements for the tables, which are automatically executed by the SQLStore when needed, are:
SQL Example |
CREATE TABLE TABLEPREFIX_statements (subject int UNSIGNED NOT NULL, predicate int UNSIGNED NOT NULL, objecttype int NOT NULL, object int UNSIGNED NOT NULL, meta int UNSIGNED NOT NULL); CREATE TABLE TABLEPREFIX_entities (id INT NOT NULL, value BLOB NOT NULL, PRIMARY KEY(id)); CREATE TABLE TABLEPREFIX_literals (id INT NOT NULL, value BLOB NOT NULL, language TEXT, datatype TEXT, PRIMARY KEY(id)); |
Indexes are created on the subject, predicate, and object/objecttype columns in the statements table, and on the value columns in the entities and literals table. Because MySQL before version 4.1.2 supported text indexes of length up to 255 bytes, URIs in the SQLStore are limited to this length.
Each resource stored in the tables is given an ID starting at 1 which is used as the value of the subject, predicate, object, and meta columns when the entity appears in a statement. The value 0 is used for statements with no meta information. When the object of a statement is an entity, objecttype is 0 and object contains the ID of the entity. When the object of a statement is a literal, objecttype is 1 and the object column contains the value of the id column in the literals table for the literal value. Literals in the literals table can be referenced by more than one statement.
Anonymous entities (blank nodes) are simply those entities mentioned in the statements table that have no entry giving their URI in the entities table.
Note:
While it is safe to use many SQLStores to read from the same store, it is not safe to use multiple SQLStores to write to the same store concurrently.
Inheritors must implement SemWeb.Stores.SQLStore.RunCommand(string), SemWeb.Stores.SQLStore.RunReader(string), and SemWeb.Stores.SQLStore.RunScalar(string).
See Also: Inherited members from object.
Distinct [read-only] | bool . To be added. |
StatementCount [read-only] | int . To be added. |
HasUniqueStatementsConstraint
[read-only]
abstract |
bool . To be added. |
InsertIgnoreCommand
[read-only]
abstract |
string . To be added. |
MaximumUriLength [read-only] | int . To be added. |
SupportsInsertCombined
[read-only]
abstract |
bool . Implemented by inheritors to indicate whether the backend supports inserting mutliple rows at once in a single INSERT command. |
SupportsSubquery
[read-only]
abstract |
bool . To be added. |
SupportsViews [read-only] | bool . To be added. |
TableName [read-only] | string . Gets the table prefix passed to the constructor. |
BeginTransaction
() Called at the start of SemWeb.Store.Import(SemWeb.RdfReader). |
|
CreateEntityPrefixTest
(string, string, System.Text.StringBuilder) To be added. |
|
CreateIndexes
() Creates the indexes on the tables. |
|
abstract |
CreateLikeTest
(string, string, int, System.Text.StringBuilder) To be added. |
abstract |
CreateNullTest
(string, System.Text.StringBuilder) To be added. |
CreateTable
() Creates the tables needed by the SQLStore. |
|
EndTransaction
() Called at the end of SemWeb.Store.Import(SemWeb.RdfReader). |
|
EscapedAppend
(System.Text.StringBuilder, string) To be added. |
|
EscapedAppend
(System.Text.StringBuilder, string, bool, bool) To be added. |
|
GetQuoteChar
() Implemented by inheritors to provide the character used to surround strings in a SQL query. |
|
abstract |
RunCommand
(string) Executes an SQL statement without a return value. |
abstract |
RunReader
(string) Executes an SQL statement that returns a table. |
abstract |
RunScalar
(string) Executes an SQL statement that returns a scalar value. |
Executes an SQL statement without a return value.
Executes an SQL statement that returns a scalar value.
Executes an SQL statement that returns a table.
Creates the tables needed by the SQLStore.
Creates the indexes on the tables.
Called at the start of SemWeb.Store.Import(SemWeb.RdfReader).
Called at the end of SemWeb.Store.Import(SemWeb.RdfReader).
Gets the table prefix passed to the constructor.
The protected constructor used by inherited classes.
To be added.
Implemented by inheritors to indicate whether the backend supports inserting mutliple rows at once in a single INSERT command.
Implemented by inheritors to provide the character used to surround strings in a SQL query.
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.
To be added.