Difference between revisions of "Semantic MediaWiki/data/smw di blob"
< Semantic MediaWiki | data
Jump to navigation
Jump to search
(Created page with "==About== * '''Purpose''': specifications for all SMW Objects that are text-blobs (i.e. long text which cannot be associated with a wiki page) * '''Refers to''': {{l/same|smw_...") |
(another useful query) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
* '''Purpose''': specifications for all SMW Objects that are text-blobs (i.e. long text which cannot be associated with a wiki page) | * '''Purpose''': specifications for all SMW Objects that are text-blobs (i.e. long text which cannot be associated with a wiki page) | ||
* '''Refers to''': {{l/same|smw_object_ids}} | * '''Refers to''': {{l/same|smw_object_ids}} | ||
+ | ==Fields== | ||
+ | * '''s_id''': ID of wiki page on which the property appears | ||
+ | * '''p_id''': ID of wiki page for the property name | ||
+ | * '''o_blob''': value when text is too long for <code>o_hash</code>; otherwise NULL | ||
+ | * '''o_hash''': exact value of text if <code>o_blob</code> is null; otherwise, truncated value with hash appended (purpose unclear) | ||
==SQL== | ==SQL== | ||
− | <mysql> | + | <syntaxhighlight lang=mysql> |
− | |||
− | |||
CREATE TABLE `smw_di_blob` ( | CREATE TABLE `smw_di_blob` ( | ||
`s_id` int(8) unsigned NOT NULL, | `s_id` int(8) unsigned NOT NULL, | ||
Line 13: | Line 16: | ||
KEY `s_id` (`s_id`,`p_id`), | KEY `s_id` (`s_id`,`p_id`), | ||
KEY `p_id` (`p_id`,`o_hash`) | KEY `p_id` (`p_id`,`o_hash`) | ||
− | ) ENGINE=InnoDB DEFAULT CHARSET=binary | + | ) ENGINE=InnoDB DEFAULT CHARSET=binary |
− | </ | + | </syntaxhighlight> |
===Example=== | ===Example=== | ||
− | <mysql> | + | ====titles==== |
+ | <syntaxhighlight lang=mysql> | ||
+ | SELECT | ||
+ | s_id, | ||
+ | s.smw_namespace AS s_namespace, | ||
+ | CAST(s.smw_title AS CHAR) AS s_title | ||
+ | FROM | ||
+ | (smw_di_blob AS r | ||
+ | LEFT JOIN smw_object_ids AS s ON r.s_id = s.smw_id) | ||
+ | </syntaxhighlight> | ||
+ | * Filter for <code>p_id</code> to get pages that use a specific property. | ||
+ | * Filter for <code>p_id</code> and <code>o_hash</code> to find pages where a specific property has a specific text value. | ||
+ | * Note that this table only applies to property values that do not link to wiki pages; see {{l/same|smw_di_wikipage}} for those that do. | ||
+ | ====relations==== | ||
+ | <syntaxhighlight lang=mysql> | ||
SELECT s_id, p_id | SELECT s_id, p_id | ||
, s.smw_namespace AS s_namespace | , s.smw_namespace AS s_namespace | ||
Line 29: | Line 46: | ||
LEFT JOIN smw_object_ids AS p ON r.p_id=p.smw_id | LEFT JOIN smw_object_ids AS p ON r.p_id=p.smw_id | ||
ORDER BY s_id | ORDER BY s_id | ||
− | </ | + | </syntaxhighlight> |
* p_namespace will probably always be the "property:" namespace, which defaults to 102 (unless there's some way to use a page outside that namespace as a property) | * p_namespace will probably always be the "property:" namespace, which defaults to 102 (unless there's some way to use a page outside that namespace as a property) |
Latest revision as of 12:04, 2 February 2018
About
- Purpose: specifications for all SMW Objects that are text-blobs (i.e. long text which cannot be associated with a wiki page)
- Refers to: smw_object_ids
Fields
- s_id: ID of wiki page on which the property appears
- p_id: ID of wiki page for the property name
- o_blob: value when text is too long for
o_hash
; otherwise NULL - o_hash: exact value of text if
o_blob
is null; otherwise, truncated value with hash appended (purpose unclear)
SQL
CREATE TABLE `smw_di_blob` (
`s_id` int(8) unsigned NOT NULL,
`p_id` int(8) unsigned NOT NULL,
`o_blob` mediumblob,
`o_hash` varbinary(255) DEFAULT NULL,
KEY `s_id` (`s_id`,`p_id`),
KEY `p_id` (`p_id`,`o_hash`)
) ENGINE=InnoDB DEFAULT CHARSET=binary
Example
titles
SELECT
s_id,
s.smw_namespace AS s_namespace,
CAST(s.smw_title AS CHAR) AS s_title
FROM
(smw_di_blob AS r
LEFT JOIN smw_object_ids AS s ON r.s_id = s.smw_id)
- Filter for
p_id
to get pages that use a specific property. - Filter for
p_id
ando_hash
to find pages where a specific property has a specific text value. - Note that this table only applies to property values that do not link to wiki pages; see smw_di_wikipage for those that do.
relations
SELECT s_id, p_id
, s.smw_namespace AS s_namespace
, CAST(s.smw_title AS char) AS s_title
, p.smw_namespace AS p_namespace
, CAST(p.smw_title AS char) AS p_title
, CAST(o_blob AS CHAR) as text
, CAST(o_hash AS CHAR) as hash
FROM
(smw_di_blob AS r
LEFT JOIN smw_object_ids AS s ON r.s_id=s.smw_id)
LEFT JOIN smw_object_ids AS p ON r.p_id=p.smw_id
ORDER BY s_id
- p_namespace will probably always be the "property:" namespace, which defaults to 102 (unless there's some way to use a page outside that namespace as a property)