Semantic MediaWiki/data/smw di time

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
< Semantic MediaWiki‎ | data
Revision as of 21:16, 9 July 2020 by Woozle (talk | contribs) (→‎Example: slightly improved query)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

About

  • Purpose: specifications for all SMW Objects that are dates
  • Refers to: smw_object_ids

Fields

  • o_serialized date value in a slash-separated format: 1/year/month/day/hour/minute/second, e.g. "1/2012/3/21/14/15/0"
    • The "1/" might be 0 for BC, but not sure how to test this.

SQL

Definition

CREATE TABLE `smw_di_time` (
  `s_id` int(8) unsigned NOT NULL,
  `p_id` int(8) unsigned NOT NULL,
  `o_serialized` varbinary(255) DEFAULT NULL,
  `o_sortkey` double DEFAULT NULL,
  KEY `s_id` (`s_id`,`p_id`),
  KEY `p_id` (`p_id`,`o_sortkey`)
) ENGINE=InnoDB DEFAULT CHARSET=binary;

Example

SELECT 
    s_id,
    CAST(s.smw_title AS CHAR) AS s_title,
    p_id,
    CAST(p.smw_title AS CHAR) AS p_title,
    CAST(o_serialized AS CHAR) AS value
FROM
    (smw_di_time AS t
    LEFT JOIN smw_object_ids AS s ON t.s_id = s.smw_id)
        LEFT JOIN
    smw_object_ids AS p ON t.p_id = p.smw_id