Difference between revisions of "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
Jump to navigation Jump to search
(Created page with "==About== * '''Purpose''': specifications for all SMW Objects that are dates * '''Refers to''': {{l/same|smw_object_ids}} ==Fields== * '''o_serialized''' date value in a slash...")
 
(→‎Example: slightly improved query)
 
Line 18: Line 18:
 
</syntaxhighlight>
 
</syntaxhighlight>
 
===Example===
 
===Example===
<syntaxhighlight lang=mysql>
+
<source lang=mysql>
 
SELECT  
 
SELECT  
 
     s_id,
 
     s_id,
 +
    CAST(s.smw_title AS CHAR) AS s_title,
 
     p_id,
 
     p_id,
    CAST(s.smw_title AS CHAR) AS s_title,
 
 
     CAST(p.smw_title AS CHAR) AS p_title,
 
     CAST(p.smw_title AS CHAR) AS p_title,
 
     CAST(o_serialized AS CHAR) AS value
 
     CAST(o_serialized AS CHAR) AS value
Line 30: Line 30:
 
         LEFT JOIN
 
         LEFT JOIN
 
     smw_object_ids AS p ON t.p_id = p.smw_id
 
     smw_object_ids AS p ON t.p_id = p.smw_id
</syntaxhighlight>
+
</source>

Latest revision as of 21:16, 9 July 2020

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