Modelling: Difference between revisions

 
(18 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Page under which Object modelling descriptions will be hosted:
{{Modelling navigation}}
 
==Basic ontology==
On the top of the Metabase ontology is the following item:
* {{Q|Q3}}
 
Which has the immediate sub-item:
* {{Q|10}}
 
Query to find all items that are {{P|P5}} or one or the other:
<SPARQL tryit="1">
PREFIX wd: <https://metabase.wikibase.cloud/entity/>
PREFIX wdt: <https://metabase.wikibase.cloud/prop/direct/>
 
SELECT ?item ?wikidata_iri ?itemLabelEN ?itemLabelSV ?itemDescEN ?itemDescSV
WHERE
{
  {?item wdt:P5 wd:Q3.}
  UNION
  {?item wdt:P5 wd:Q10.}
  OPTIONAL {?item wdt:P1 ?wikidataQ}
  BIND(URI(concat("http://www.wikidata.org/entity/", ?wikidataQ)) AS ?wikidata_iri)
  OPTIONAL {?item rdfs:label ?itemLabelEN filter (lang(?itemLabelEN) = "en")}.
  OPTIONAL {?item rdfs:label ?itemLabelSV filter (lang(?itemLabelSV) = "sv")}.
  OPTIONAL {?item schema:description ?itemDescEN filter (lang(?itemDescEN) = "en")}.
  OPTIONAL {?item schema:description ?itemDescSV filter (lang(?itemDescSV) = "sv")}.
}
</SPARQL>
 
==Properties==
Whenever possible, we aim to create properties whose scope duplicates that of properties in Wikidata. By using {{P|P1}}, we then link to the equivalent Wikidata property. This lowers the threshold for Wikidata editors to start participating.
 
For example: {{Q|P14}}, {{Q|P20}}, {{Q|P28}}.
===Metabase internal properties===
We sometimes have a need for properties that do not have direct equivalents on Wikidata. For example when we need to describe the activities of the Wikimedia movement in more detail than what's relevant for Wikidata.
 
These properties shall have {{P|P5}} → {{Q|Q24}}.
 
For example: {{P|P9}}, {{P|13}}, {{P|10}}.
 
====Temporary free text fields====
Occasionally, we might need to temporarily store a piece of information in free text format, e.g. if we're unsure what item to use or if it does not exist yet.
 
We use the property {{P|P38}} for this. It should be accompanied by the qualifier {{P|P41}} that states what property should replace it.
 
Compare the property [https://www.wikidata.org/wiki/Property:P2093|Author name string] on Wikidata.
 
====SPARQL====
Query to find all internal properties:
<SPARQL tryit="1">
PREFIX wd: <https://metabase.wikibase.cloud/entity/>
PREFIX wdt: <https://metabase.wikibase.cloud/prop/direct/>
 
SELECT ?item ?itemLabelEN ?itemLabelSV ?itemDescEN ?itemDescSV
WHERE
{
  ?item wdt:P5 wd:Q24.
  OPTIONAL {?item rdfs:label ?itemLabelEN filter (lang(?itemLabelEN) = "en")}.
  OPTIONAL {?item rdfs:label ?itemLabelSV filter (lang(?itemLabelSV) = "sv")}.
  OPTIONAL {?item schema:description ?itemDescEN filter (lang(?itemDescEN) = "en")}.
  OPTIONAL {?item schema:description ?itemDescSV filter (lang(?itemDescSV) = "sv")}.
}
</SPARQL>
 
Query to find all temporary free text fields:
<SPARQL tryit="1">
PREFIX wb: <https://metabase.wikibase.cloud/entity/>
PREFIX wbt: <https://metabase.wikibase.cloud/prop/direct/>
PREFIX wbp: <https://metabase.wikibase.cloud/prop/>
PREFIX wbpq: <https://metabase.wikibase.cloud/prop/qualifier/>
SELECT DISTINCT ?item ?itemLabel ?val ?qual ?qualLabel
WHERE
{
?item wbt:P38 ?val.
OPTIONAL {?item wbp:P38 ?statement.
?statement wbpq:P41 ?qual .}
   
SERVICE wikibase:label { bd:serviceParam wikibase:language "sv,en". }
}
</SPARQL>


==Metabase vs. Wikidata==
==Metabase vs. Wikidata==
As we do not aim to duplicate the information on Wikidata, there's a number of item types that '''only''' contain a Wikidata QID, using {{P|P1}}. These are:
As we do not aim to duplicate the information on Wikidata, there's a number of item types that '''only''' contain a Wikidata QID, using {{P|P1}}. These are:
* {{Q|Q8}} and {{Q|Q40}}
** Example: {{Q|Q51}}
* {{Q|Q12}}
* {{Q|Q12}}
** Example: {{Q|Q39}}
* {{Q|Q13}}
* {{Q|Q13}}
** Example: {{Q|Q50}}
* {{Q|Q22}}
* {{Q|Q22}}
** Example: {{Q|Q26}}
* {{Q|Q23}}
* {{Q|Q23}}
** Example: {{Q|Q85}}
* {{Q|Q66}}
* {{Q|Q66}}
** Example: {{Q|Q83}}


By using [[:mw:Wikibase/Federation|federated queries]], we can still access information about these types of entities from Wikidata, without hosting the data ourselves.
By using [[:mw:Wikibase/Federation|federated queries]], we can still access information about these types of entities from Wikidata, without hosting the data ourselves.


See some [[Project:SPARQL/examples#Federated_queries|examples of federated queries]]..
See some [[Project:SPARQL/examples#Federated_queries|examples of federated queries]].
 
===Index terms===
===Index terms===
An {{Q|Q12}} is a keyword that we use to describe e.g. the topic of a document or the focus area of a project.
An {{Q|Q12}} is a keyword that we use to describe e.g. the topic of a document or the focus area of a project.


For example: {{Q|Q18}}, {{Q|Q39}}, {{Q|Q17}}.
For example: {{Q|Q18}}, {{Q|Q39}}, {{Q|Q17}}.
===Organizations===
===Organizations===
An {{Q|Q13}} could be a Wikimedia chapter, a GLAM or any other organized social entity.
An {{Q|Q13}} could be a Wikimedia chapter, a GLAM or any other organized social entity.
Line 21: Line 109:
For example: {{Q|Q50}}, {{Q|Q9}}, {{Q|Q15}}.
For example: {{Q|Q50}}, {{Q|Q9}}, {{Q|Q15}}.


==Metabase-specific items==
=== Humans ===
===Projects===
We only create items about people when these are needed to describe authorship/speaker/event or project responsibility. And only when this information is already publicly available, any affiliation would also need to have been publicly communicated. Since the main affiliation might not always apply, it can be superseded by a qualifier on an item-by-item basis.
===Documents===
===Activities and events===


For example: {{Q|Q46}}, {{Q|Q30}}.


==Item types primarily offloaded on Wikidata==
For the following item types we expect little or no information on Metabase. Required are only {{P|P1}} and {{P|P5}} if they exist on Wikidata.


* '''Organizations'''
** If not on Wikidata, consider if it might anyway be relevant for Wikidata. Else add a Label and an additional {{P|P5}} statement to an [[Modelling/Index term|index term]] describing the type of organisation.
* '''Locations''': It is enough to stay at a town level of granularity, e.g. {{Q|Q78}} rather than ''Norrsken House''. This is enough to  get an insight about the geographical spread of activities.
* '''Humans'''
** If not on Wikidata, see [[Modelling/Humans|humans]] for allowed modelling.


* [[Modelling/Projects|Projects]]
==Metabase-specific items==
** {{Q|Q14}}
===Projects===
** '''SPARQL''': [https://metabase.wikibase.cloud/query/#PREFIX%20wd%3A%20%3Chttps%3A%2F%2Fmetabase.wikibase.cloud%2Fentity%2F%3E%0APREFIX%20wdt%3A%20%3Chttps%3A%2F%2Fmetabase.wikibase.cloud%2Fprop%2Fdirect%2F%3E%0A%0ASELECT%20%3Fitem%20%3FitemLabel%20%3Fstart%20%3Fend%20%28GROUP_CONCAT%28DISTINCT%20%3FmainsubjectLabel%3B%20SEPARATOR%20%3D%20%22%2C%20%22%29%20AS%20%3Ftopics%29%20%28GROUP_CONCAT%28DISTINCT%20%3ForganizerLabel%3B%20SEPARATOR%20%3D%20%22%2C%20%22%29%20AS%20%3Forganizers%29%0AWHERE%0A%7B%0A%20%20%3Fitem%20wdt%3AP5%20wd%3AQ2%20.%0A%20%20OPTIONAL%20%7B%20%20%3Fitem%20wdt%3AP6%20%3Fstart.%7D%0A%20%20OPTIONAL%20%7B%20%3Fitem%20wdt%3AP7%20%3Fend.%7D%0A%20%20OPTIONAL%20%7B%20%3Fitem%20wdt%3AP15%20%3Fmainsubject.%7D%0A%20%20OPTIONAL%20%7B%20%3Fitem%20wdt%3AP14%20%3Forganizer.%7D%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%0A%20%20%20%20bd%3AserviceParam%20wikibase%3Alanguage%20%22sv%22.%0A%20%20%20%20%3Fitem%20rdfs%3Alabel%20%3FitemLabel.%0A%20%20%20%20%3Fmainsubject%20rdfs%3Alabel%20%3FmainsubjectLabel.%0A%20%20%20%20%3Forganizer%20rdfs%3Alabel%20%3ForganizerLabel%0A%20%20%7D%0A%7D%0AGROUP%20BY%20%3Fitem%20%3FitemLabel%20%3Fstart%20%3Fend%0AORDER%20BY%20%3FitemLabel All projects]
A ''project'' could be:
* a formal one officially implemented by an organization (a Wikimedia chapter, a GLAM, or other)
* an informal one implemented by a self-organized group (such as participants in a Wikiproject), or an individual (a volunteer Wikimedian)


See the following:
* [[Modelling/Projects|Modelling of projects in Metabase]]
* Generic project [[EntitySchema:E3|entity schema]] and [https://metabase.wikibase.cloud/tools/cradle/?#/shex/E3 Cradle]
* Wikimedia Sverige project [[EntitySchema:E2|entity schema]] and [https://metabase.wikibase.cloud/tools/cradle/?#/shex/E2 Cradle]


* [[Modelling/Events|Events]]
===Documents===
** {{Q|Q36}}
See the following:
* ...
* [[Modelling/Documents|Modelling of documents in Metabase]]
* Document [[EntitySchema:E4|entity schema]] and [https://metabase.wikibase.cloud/tools/cradle/?#/shex/E4 Cradle]


===Activities and events===
See the following:
* [[Modelling/Events and activities|Modelling of events in Metabase]]
* Event [[EntitySchema:E5|entity schema]] and [https://metabase.wikibase.cloud/tools/cradle/?#/shex/E5 Cradle]


* [[Modelling/Documents|Documents]]
==See also==
** {{Q|Q35}}
* Since wikibase.cloud does not support [https://www.mediawiki.org/wiki/Extension:WikibaseQualityConstraints Constraints], these are instead listed on [[Template:Rules|Rules]] and displayed on the talk page of the concerned Properties and items.
** '''SPARQL''': [https://metabase.wikibase.cloud/query/#PREFIX%20wd%3A%20%3Chttps%3A%2F%2Fmetabase.wikibase.cloud%2Fentity%2F%3E%0APREFIX%20wdt%3A%20%3Chttps%3A%2F%2Fmetabase.wikibase.cloud%2Fprop%2Fdirect%2F%3E%0A%0ASELECT%20%3Fitem%20%3FitemLabel%20%3Ftype%20%3FtypeLabel%20%3Ftopic%20%3FtopicLabel%0AWHERE%0A%7B%0A%20%20%3Fitem%20wdt%3AP5%2Fwdt%3AP4%2a%20wd%3AQ21.%0A%20%20%3Fitem%20wdt%3AP5%20%3Ftype.%0A%20%20OPTIONAL%20%7B%3Fitem%20wdt%3AP15%20%3Ftopic.%7D%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22sv%2Cen%22.%20%7D%0A%7D All documents]
**'''SPARQL''': [https://metabase.wikibase.cloud/query/#PREFIX%20wd%3A%20%3Chttps%3A%2F%2Fmetabase.wikibase.cloud%2Fentity%2F%3E%0APREFIX%20wdt%3A%20%3Chttps%3A%2F%2Fmetabase.wikibase.cloud%2Fprop%2Fdirect%2F%3E%0A%23%20all%20available%20types%20of%20documents%0ASELECT%20%3Fitem%20%3FitemLabel%0AWHERE%0A%7B%0A%20%20%3Fitem%20wdt%3AP4%2a%20wd%3AQ21%20.%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22sv%2Cen%22.%20%7D%0A%7D All types of documents]


* [[Modelling/Index terms|Index terms]]
** {{Q|Q18}}
**'''SPARQL''': [https://metabase.wikibase.cloud/query/#PREFIX%20wd%3A%20%3Chttps%3A%2F%2Fmetabase.wikibase.cloud%2Fentity%2F%3E%0APREFIX%20wdt%3A%20%3Chttps%3A%2F%2Fmetabase.wikibase.cloud%2Fprop%2Fdirect%2F%3E%0A%0ASELECT%20%3Fitem%20%3FitemLabelEN%20%3FitemLabelSV%0AWHERE%0A%7B%0A%20%20%20%20%3Fitem%20wdt%3AP5%20wd%3AQ12%20.%0A%20%20%20%20OPTIONAL%20%7B%3Fitem%20rdfs%3Alabel%20%3FitemLabelEN%20filter%20%28lang%28%3FitemLabelEN%29%20%3D%20%22en%22%29%7D.%0A%20%20%20%20OPTIONAL%20%7B%3Fitem%20rdfs%3Alabel%20%3FitemLabelSV%20filter%20%28lang%28%3FitemLabelSV%29%20%3D%20%22sv%22%29%7D.%0A%7D All index terms]




[[Category:Documentation]]
[[Category:Documentation|*]]