How to model relationships between tiddlers

166 views
Skip to first unread message

Michael McDermott

unread,
Feb 3, 2020, 7:03:51 PM2/3/20
to TiddlyWiki
I make fairly heavy use of tags in TiddlyWiki and that works very well for broad categories. Is there a way to semantically model some relationship between two tiddlers?

For example, in a graph database, you might create a relationship like this:

[Leonardo da Vinci]   ----Painted--->    [The Mona Lisa]

It's pretty easy to see creating tiddlers for The Mona Lisa and Leonardo da Vinci, but the only real way to link them is either tags or hyperlinks, but I don't see a good way to model that relationship. The closest I've seen is the TiddlyMap plugin, but that stores all of the relationships as JSON content, which can only really be manipulated through the map plugin itself.

Is there a good option in TiddlyWiki I've missed?

Eric Shulman

unread,
Feb 3, 2020, 8:20:31 PM2/3/20
to TiddlyWiki
On Monday, February 3, 2020 at 4:03:51 PM UTC-8, Michael McDermott wrote:
Is there a way to semantically model some relationship between two tiddlers?
For example, in a graph database, you might create a relationship like this:
[Leonardo da Vinci]   ----Painted--->    [The Mona Lisa]
Is there a good option in TiddlyWiki I've missed?

You can create any "custom" fields you like on a tiddler.

To represent a one-to-one relationship between painting and painter, you could define
a "paintedby" field for a painting, the value of which would be the title of a "painter" tiddler.

e.g., [[The Mona Lisa]] tiddler would have a "paintedby" field containing: "Leonardo Da Vinci".

Conversely, to represent one-to-many relationships, you could define a "painted" tiddler for
an artist, the value of which would be a space-separated list of titles of paintings.

e.g., [[Leonardo Da Vinci]] tiddler would have a "painted" field containing: [[The Mona Lisa]] [[The Last Supper]] [[Salvator Mundi]]

Then, to display a list of all his works, you can write in the [[Leonardo Da Vinci]] tiddler:
<$list filter="[list[!!painted]]"><$link /><br></$list>

Alternatively, if not all paintings by Da Vinci are entered into the "painted' field, you can still list all his paintings using a filter that looks for his name in the "paintedby" field of other tiddlers, like this:
<$list filter="[all[tiddlers]paintedby<currentTiddler>]">...</$list>

For a more complex example, let's suppose that each artist tiddler is tagged with "artist".  Then, you could create a list of all paintings in the document, grouped by artists, using something like:
<$list filter="[tag[artist]]">
   <$link />
   
<blockquote>
     
<$list filter="[all[tiddlers]paintedby<currentTiddler>]"><$link /><br></$list>
   </blockquote>
</$list>
The outer $list finds all artist tiddlers and displays their titles, while the inner $list shows all the tiddlers for the current artist (inside a blockquote for nicer formatting

enjoy,
-e





CJ Veniot

unread,
Feb 4, 2020, 12:05:21 AM2/4/20
to TiddlyWiki
I'm a pretty big fan of Tidgraph.  Give it a peek and see what you think:  http://ihm4u.github.io/tw5plugs/

Cheers !

bimlas

unread,
Feb 10, 2020, 9:10:40 AM2/10/20
to TiddlyWiki
Michael McDermott,


I make fairly heavy use of tags in TiddlyWiki and that works very well for broad categories. Is there a way to semantically model some relationship between two tiddlers?

Michael McDermott

unread,
Feb 12, 2020, 3:50:04 PM2/12/20
to TiddlyWiki
I've been tinkering with this approach and it fills the need pretty well. I hadn't really thought of using title lists in fields before, so using that + the list macro + transclusion has helped a great deal.

The only thing that has felt a little awkward has been having to create strings of tiddlers connected by fields to model some of the more sophisticated relationships.

Thanks for the pointers!
Reply all
Reply to author
Forward
0 new messages