TMQL tutorial - part 8

Post on 19-May-2015

873 views 0 download

Tags:

Transcript of TMQL tutorial - part 8

Einführung in Topic Maps

topicmapslab.de

Topic Maps Query Language

Sven Krosse M. Sc.

Topic Maps Lab an der Universität Leipzig

krosse@informatik.uni-leipzig.de

Session 8

Einführung in Topic Maps

topicmapslab.de

Review – Session 7

Useful TMQL-Expressions

TMQL Part-2

1. Delete-Expression

2. Insert-Expression

3. Merge-Expression

Einführung in Topic Maps

topicmapslab.de

Agenda

TMQL Part-2

1. Update-Expression

a) Context-independent

b) Context-dependent

Einführung in Topic Maps

topicmapslab.de

SprachbestandteileUpdate Expression

Einführung in Topic Maps

topicmapslab.de5

Update-Expression

● Änderungen der Topic Map

● atomare Änderungen an Konstrukten der Topic Map

● mehrere Änderungen am selben Kontext möglich

● aber: alle Änderungen am selben Kontext!

● Änderungen können neue Daten hinzufügen oder Werte

modifizieren!

Einführung in Topic Maps

topicmapslab.de6

Update-Expression

● Grammatik:

update-ex ::= UPDATE < update-clause > { where-clause }

update-clause ::= anchor { param } ( SET | ADD ) value-ex

● Anchor: Schlüsselwort zur Definition der Änderung

● Param: optionales Argument

● Value-Ex: neuer Wert der Änderung

Einführung in Topic Maps

topicmapslab.de7

Update-Expression

● kontextfreie Änderungen ( Kontext ist Topic Map! )

● Hinzufügen neuer Topics

● Hinzufügen neuer Assoziation

→ ohne CTM

Einführung in Topic Maps

topicmapslab.de8

Neues Topic anlegen

● Schlüsselwort: topics

● Definition über Identifier

● Identifier bereits in Benutzung? → keine Änderungen

UPDATE topics ADD „http://psi.example.org/topic“

→ kein Identifier-Typ definiert (Standard: Subject-Identifier)

Einführung in Topic Maps

topicmapslab.de9

Topic mit Subject-Identifier anlegen

UPDATE topics ADD „http://psi.example.org/topic“

UPDATE topics ADD „http://psi.example.org/topic“ ~

UPDATE topics ADD „http://psi.example.org/topic“ << indicators

→ neues Topic mit dem Subject-Identifier

Einführung in Topic Maps

topicmapslab.de10

Topic mit Item-Identifier anlegen

UPDATE topics ADD „http://psi.example.org/topic“ !

UPDATE topics ADD „http://psi.example.org/topic“ << item

→ neues Topic mit dem Item-Identifier

Einführung in Topic Maps

topicmapslab.de11

Topic mit Subject-Locator anlegen

UPDATE topics ADD „http://psi.example.org/topic“ =

UPDATE topics ADD „http://psi.example.org/topic“ << locators

→ neues Topic mit dem Subject-Locator

Einführung in Topic Maps

topicmapslab.de12

Neue Assoziation anlegen

● Schlüsselwort: associations

● Definition über Association-Definition ( keine Ellipse )

● tm:subject verboten!

UPDATE associations ADD association-type ( role-type : player )

→ erzeugt neue Assoziation mit einer Rolle

→ alle Topics werden bei nicht Existenz erzeugt

Einführung in Topic Maps

topicmapslab.de13

Neue Assoziation anlegen

● Variablen können durch Where-Klausel gebunden werden

UPDATE associations ADD association-type ( role-type : $c )

WHERE $c ISA composer

→ erzeugt für jeden Komponist eine neue Assoziation vom Typ

association-type

Einführung in Topic Maps

topicmapslab.de14

Update-Expression

● kontextsensitive Änderungen ( Kontext über Where-Klausel )

Einführung in Topic Maps

topicmapslab.de15

Neuer Subject-Identifier

● Schlüsselwort: indicators

● Optional: keiner

● Kontext: Topic

UPDATE indicators ADD „http://psi.example.org/indicators“

WHERE http://en.wikipedia.org/wiki/Puccini

Einführung in Topic Maps

topicmapslab.de16

Neuer Subject-Locator

● Schlüsselwort: locators

● Optional: keiner

● Kontext: Topic

UPDATE locators ADD „http://psi.example.org/locator“

WHERE http://en.wikipedia.org/wiki/Puccini

Einführung in Topic Maps

topicmapslab.de17

Neuer Item-Identifier

● Schlüsselwort: item

● Optional: keiner

● Kontext: Topic

UPDATE item ADD „http://psi.example.org/item“

WHERE http://en.wikipedia.org/wiki/Puccini

Einführung in Topic Maps

topicmapslab.de18

Neuen Name anlegen

● Schlüsselwort: names

● Optional: Namenstyp

● Kontext: Topic

UPDATE names name-type ADD „name“

WHERE http://en.wikipedia.org/wiki/Puccini

Einführung in Topic Maps

topicmapslab.de19

Name ändern

● Schlüsselwort: names

● Optional: kein

● Kontext: Topic Name

UPDATE names SET „name“

WHERE http://en.wikipedia.org/wiki/Puccini >> characteristics

tm:name @short-name

Einführung in Topic Maps

topicmapslab.de20

Neue Occurrence anlegen

● Schlüsselwort: occurrences

● Optional: Occurrence-Typ

● Kontext: Topic

UPDATE occurrences occ-type ADD „1“^^xsd:integer

WHERE http://en.wikipedia.org/wiki/Puccini

Einführung in Topic Maps

topicmapslab.de21

Occurrence ändern

● Schlüsselwort: occurrences

● Optional: kein

● Kontext: Occurrence

UPDATE occurrences SET „1“^^xsd:integer

WHERE http://en.wikipedia.org/wiki/Puccini >> characteristics

tm:occurrence @web

Einführung in Topic Maps

topicmapslab.de22

Neues Theme hinzufügen

● Schlüsselwort: scope

● Optional: kein

● Kontext: Assoziation, Name, Occurrence

UPDATE scope ADD http://psi.example.org/deprecated

WHERE http://en.wikipedia.org/wiki/Puccini << players

Einführung in Topic Maps

topicmapslab.de23

Neuen Typ hinzufügen

● Schlüsselwort: types

● Optional: kein

● Kontext: Topic

UPDATE types ADD http://psi.example.org/type

WHERE http://en.wikipedia.org/wiki/Puccini

Einführung in Topic Maps

topicmapslab.de24

Typ ändern

● Schlüsselwort: types

● Optional: kein

● Kontext: Assoziation, Name, Occurrence

UPDATE types SET http://psi.example.org/type

WHERE http://en.wikipedia.org/wiki/Puccini >> characteristics

tm:occurrence @web

Einführung in Topic Maps

topicmapslab.de25

Neue Instanz hinzufügen

● Schlüsselwort: instances

● Optional: kein

● Kontext: Topic

UPDATE instances ADD http://en.wikipedia.org/wiki/Puccini

WHERE http://psi.example.org/type

Einführung in Topic Maps

topicmapslab.de26

Neuen Supertyp hinzufügen

● Schlüsselwort: supertypes

● Optional: kein

● Kontext: Topic

UPDATE supertypes ADD http://psi.example.org/type

WHERE http://en.wikipedia.org/wiki/Puccini

Einführung in Topic Maps

topicmapslab.de27

Neuen Subtyp hinzufügen

● Schlüsselwort: subtypes

● Optional: kein

● Kontext: Topic

UPDATE subtypes ADD http://en.wikipedia.org/wiki/Puccini

WHERE http://psi.example.org/type

Einführung in Topic Maps

topicmapslab.de28

Spieler ändern

● Schlüsselwort: players

● Optional: Rollentyp ( Standard: alle Rollen!!! )

● Kontext: Assoziation

UPDATE players composer SET http://psi.example.org/me

WHERE http://en.wikipedia.org/wiki/Puccini << players

Einführung in Topic Maps

topicmapslab.de29

Rolle hinzufügen

● Schlüsselwort: roles

● Optional: Topic ( Spieler )

● Kontext: Assoziation

UPDATE roles http://psi.example.org/me

ADD http://psi.example.org/roleType

WHERE http://en.wikipedia.org/wiki/Puccini << players

Einführung in Topic Maps

topicmapslab.de30

Reifier ändern

● Schlüsselwort: reifier

● Optional: kein

● Kontext: Assoziation, Name, Occurrence, Topic

UPDATE reifier SET http://psi.example.org/reifier

WHERE http://en.wikipedia.org/wiki/Puccini >> characteristics

tm:occurrence @web

Einführung in Topic Maps

topicmapslab.de31

Reifier ändern

● Schlüsselwort: reifier

● Optional: kein

● Kontext: Assoziation, Name, Occurrence, Topic

UPDATE reifier

SET http://en.wikipedia.org/wiki/Puccini >> characteristics

tm:occurrence @web

WHERE http://psi.example.org/reifier

Einführung in Topic Maps

topicmapslab.de

Ausblick!

Einführung in Topic Maps

topicmapslab.de33

Geplante Features

● Transaktionen ( Engine-Funktion nutzen )

● Aktuelle Engines mit Transaktionssupport

– TM2JDBC ( nur DB )

– Ontopia ( nur DB )

– MaJorToM

Einführung in Topic Maps

topicmapslab.de34

Geplante Features

● Spracherweiterung

● UPDATE mit Assoziation-Definition ( als Bedingung )

● Assoziation-Definition für FLW(O)R, SELECT, PATH, DELETE

● neue Content-Typen (JSON, LTM, …)

Einführung in Topic Maps

topicmapslab.de

ENDE