Query with tags and boolean operators

I have a database of fruits and vegetables and they have the following tags:

item tags
apple fruit, healthy
cucumber vegetable
orange fruit, citrus
pineapple fruit, citrus, expensive
watermelon fruit, large
spinach vegetable, leafy

Can I write a query that will return results if the following conditions are met:

ONLY fruits are allowed AND
citrus fruits are NOT allowed, UNLESS they are also expensive

So for the above example it should return apple, pineapple and watermelon

Have you looked at Smart Groups?

I have looked at them. But I do need to form a query first that gives the results I want.

Where I am stuck is in this part:

citrus fruits are NOT allowed, UNLESS they are also expensive

(Not citrus) or (Citrus and expensive)

Or is “any” in DT, and is “all”

But a pineapple is not a citrus. So, you can’t get the result you want anyway :winking_face_with_tongue:

What you’re trying to do screams for a relational database. And for a proper data model. Loudly.

2 Likes

Welcome @easterbunny
Per your specific example…

1 Like

This works perfectly. Thanks!

1 Like

What you’re trying to do screams for a relational database. And for a proper data model. Loudly.

I think so haha. I just downloaded the app, read the books and started importing my stuff. I have no clue what I am doing as of now, but slowly getting a hang of it.

What are you specifically trying to do?

DT is not a relational database. If you’re trying to solve problems like the one you described, it might not be the right tool.

Especially, since it can’t force you to structure your data in a sensible way. For example, it can’t force you to select exactly one of “vegetable” or “fruit” for a tag. You could create smart rules that select all records which have neither of those set, but that’s just a workaround. As @bluefrog said:

What are you specifically trying to do?

2 Likes

Just filing all the documents I’ve received over the last 10 years in a single place, for a start.
Invoices, receipts, tax returns, etc. So I can retrieve them later if I would need to.

Once I am comfortable enough with the UI/features I feel I can use it for managing current information as well.

1 Like

Good to know. I’m just exploring at the moment, and of course knowing what the limitations are would be the best. I’m avoiding creating too many tags/groups/hierarchies since that (for me) makes it difficult to import information (forgetting to tag things correctly, putting them in the wrong group), So I wanted to check how crazy I can get with the queries, and if a complex query can be a substitute for very specific tags.

I think many people search by content, not by tags. Because the content is there even if you forgot to use (the correct) tags.

2 Likes

You are right @chrillek because it’s DVTk.
The tags are difficult to manage: auto creation , one system by DDB , caps , very tricky .

If you were in Evernote it’s more stable (was blocked in its private system for years :smiling_face_with_sunglasses:) you have central management of Tags , also Obsidian

But in DVTk you have the folders and search system powerfully , you can downsize the number of tags
I decide to keep only tags for status like PARA and Mark Sparky’s method
And to replicate the tags in metadata MD . It’s not perfect but it’s works

Well, automatic creation of tags can be en/disabled in Settings > Files > Import and Settings > RSS and likewise case insensitive tagging can be en/disabled in Files > Database Properties.

And if you were in a relational database system, everything would also be very different. DT’s tags are what they are. And they are, IMO, not an appropriate approach to handle required or mutually exclusive attributes.

@easterbunny
@chrillek is almost always right. Regardless of this, I also believe that searching by content (words, without tags), has advantages. DT in particular can really do a lot in this area.

Without going into detail, there are a few things you need to know that may be different in other similar apps.

“police” does not automatically find “policeman” and “room” does not find “bedroom”.

It needs a * before and/or after the word.

This is certainly in the manual, where it also says how to exclude words from the search (very useful) and much more, but if, like me, you come from an app that always searches for word components, you might overlook this.

1 Like