- The problem with the practice
of Building a Second Brain is that it comes with the connotation that the second brain is going
to be a replica of the first, but our first brains are
already not good at everything. They might be good at
making intuitive leaps but they're pretty terrible at things like data storage and retrieval. So what if we made a database
instead of a replica? That way our first brains would
be free to make connections unhindered by the
necessity of also storing and retrieving data that we
may not even need every day. In this video, I'm gonna talk about the Obsidian Dataview
Plugin, how to use it and why it's essential for
building a bottom up approach to note taking and learning. What is Dataview? Dataview is an Obsidian community plugin that turns all of your notes in Obsidian, your entire vault, into a database. I go a little bit into the
philosophy behind Dataview in this video about
Notion versus Obsidian. So check that out if you want a refresher. The thing to note about Dataview is it can quickly get
complicated and very daunting. So, before you jump in and decide to completely reorganize your notes based on Dataview metadata, just remember that it only needs to be as complicated as you want it to be. Here's how to install Dataview. This is my test vault here. You just have to click on Settings, turn off safe mode if you haven't already, click Browse on Community Plugins and then go ahead and type Dataview and we click on it, click install and it'll install it, you'll see this note here that says successfully installed Dataview and then go ahead and enable it as well. There are two steps to using Dataview. The first is annotating your notes and the second is querying those notes. Annotating just means describing a note with fields that you specify. So let's just dive into a use case here and let's go into the
page for a person, Kieran. I've got this page for Kieran here, and there are two ways that
I can start to annotate it. First, I can put it in the note here, so I could say for example that I want to say that the type
of note this is is a person. I could also say something like location and let's say that's Singapore. The advantage of using this
method, the double colons, is that it's right there
in the body of the note but there might be times when maybe you have a lot of things here that you don't really
want to see normally, so in that case what
you could do is hide it behind the YAML front matter syntax. So that's just three dashes and then you close it
with three dashes again, and then within that
you put the parameters. So maybe I could say
something like date_met, and I'll say it was today. I could also add extra tags, I know that Kieran plays D&D so maybe I'll tag it with D&D. Maybe he's a work colleague and I know that he's
assigned to Project X, so I could add project
as a parameter as well. The advantage of annotating
a note in this way is that when we go over
to the preview mode, those parameters aren't going
to show up in the note itself so we can only see the
type and location here and not the tags and such
that we added for Kieran. It's really personal preference, they're going to be treated
in exactly the same way, so it's up to you. Now onto the second part which is actually querying that data. You can think of a Dataview
query as a more powerful search. A query always begins and
ends with three backticks. This is what's known as a code block. Next, just after the
first set of backticks, you can type the kind of code you're going to use in this block. For Dataview, it's going to be either Dataview or Dataview JS. Dataview refers to the
Dataview Query Language or DQL and that's what I'd
recommend you start with. The rest of the Dataview code block will consist of the query itself. A query begins with a
type of view you want. Right now, Dataview supports lists, tables, tasks, and calendars. After that, you can put in the parameters that you want displayed which is what's to the left of the colons in the data annotation
example, like project or tags. Then you may wanna specify where Dataview should look for the results. You can add a folder
like `FROM "Meetings"` or you can instruct it
to look for only notes with a certain tag, like `FROM #meeting`. Which one you use is up to you and how you've chosen
to structure your data. For simple queries, you
can leave it at that. But you'll probably need
to narrow down your query in some way so that you don't
get too many results returned. For that, use the `WHERE`
keyword to denote criteria. What do you use as criteria? Parameters, mostly-- those that you define while annotating the data. An optional part of the query is `SORT` which you can add if you
want to specify the order in which the results should be displayed. Most of the time though, you'll probably need `SORT
file.name ASC` or ascending, which will sort results alphabetically. So let's create a note for Project X. So I just opened it up on the side here and I'll go ahead and title that. And let's say, I want a list of all the people that
are assigned to Project X. Then we can create a Dataview query. To do that, type out three backticks and then we'll put `dataview` in there. Let's say I want a list. So I'm going to type out list and maybe in addition to Kieran's page, I also want to specify the location. So that's this parameter here. So the problem is that
if I exit out of that by just moving the cursor away from it, it's actually bringing up every
single note that I've got. And that's because I didn't
really specify any criteria for what I'm searching for. I just said list everything
and the location of that thing. So I'm going to attempt to
specify by adding a WHERE clause. So I'll say WHERE type is person. And if I exit out of that, you'll see that there are two results now that are coming up, there's one for Kieran and one for Alice, apparently like if I bring Alice up, I already have this type: person here. And you can see that with the Kieran note, I have it listed here
in the body of the note and on the Alice note, I have
it listed in the front matter. But wait, Alice isn't
working on project X, so we really need to
specify this query further. So, I'm going to add AND
project = "Project X". Let's try that. Now we're talking, now it's only Kieran that's going to be shown in the results list. So going back into that Dataview query and I'm going to copy that, but instead of list, I now want a table. And now that's showing
the same results (Kieran), but there are now two
columns: File and Location. If we want this location
to maybe be a country but we don't really want to go back and change this location tag here, what we can do is add TABLE
location as "Country". And that's kind of like an alias, so it's still the location parameter but instead we're calling
it in this view "Country". The cool thing about Dataview is that it is dynamically generated. So if we go back to that Alice page and I decide that she's now been assigned to project X as well, I can just add `project: Project X` and that Dataview table
is going to be updated. So what if we have a
meeting about Project X? Well, I would probably create
a sort of meetings folder and then I'd say introductory
meeting for project X and I will also copy that as the title. And let's say we have meeting notes here and then let's add some parameters and I'll add instead of person this time, I'll type meeting and the project will be project X. But then maybe I also
want to add the attendees. I'll add something here
that says attendees, Kieran and also maybe Alice. Another thing that I like do for meetings is add a bit of a summary. So at the end of the meeting, I kind of write down any decisions, that way I can bring it
up really quickly later. So I'll say Alice and Kieran are going to be working on Project X, let's say that's the decision. In the project X page here, I can add another section called meetings and we're going to do a Dataview query based on those meetings. So, I'll add Dataview
here, I want another table, this time maybe I want the date actually, we haven't added the date yet. So let's do that now. So date, I'll say it was today, go back into the meeting here and I'll say I want the date and summary. And then for the where clause, I'm going to say where
project equals project X. So now there's a nice table here, but look, we're see the meeting, but we're also seeing Alice and Kieran. Those aren't meetings, those are people, and that's because I only specified that the field is going to be project X, right? So two ways that I could do this one is I could add another class here that says and type equals meeting and that should work and only
bring up that one meeting. The other way that I can do it though is because I created this
in a meetings folder, I could add `FROM "Meetings"` and that's the name of the folder that I put that meeting note in and it's going to have the same effect. It's going to have the
date and the summary. So imagine that the more meetings I have, the more meetings are going to appear in this Dataview results as well. Another thing you can do with
Dataview is start to build up like a glossary of sorts. Let's say I'm building a
Performance Testing Glossary so I could have a note like this but I need things to go in it. So I guess first I should a
note on performance testing and in the body of the note itself, I'm going to say definition and then I could also have tags here so I could put glossary, performance. Now in the Performance
Testing Glossary page, I could have (you guessed it)
a Dataview query with a table and I'll have the term which
is going to be the page and also the definition as definition. But I don't just want everything, I want notes where the
tags include glossary. So now I've got performance testing and the definition in here. And if you want to specify that it's going to be
just about performance, you could have `WHERE
contains(tags,"performance")`. And then if I remove this
performance tag here, it should disappear from
this glossary as well. Let's look at something from Readwise. Readwise is a service that I use for automatically bringing in my highlights from books, from Kindle books
that I read into Obsidian. So you can see these are
things that I highlighted while I was reading it on my Kindle or on the Kindle app as well. And it's also already got
some tags that I've specified. And what if I want to have a list of all the
books that I read in 2022 or reread in this case. I could create a page
called books I read in 2022 and open that up here and I'll add that as the title. This is kind of like if
you are trying to set up your own version of Goodreads, one that's completely
in your Obsidian Vault and always accessible. So then I would probably
create a table for this, we'll say I want the rating as rating and I don't want it to list everything in case I've also rated
TV shows or something. So I'm going to type #books, so I'm going to put where the date is greater than or equal
to the date of 2022-01-01. So that's January 1st. So, there's going to be
a bunch of things here. You know what, let's add date in here so we can see, instead of rating. And if we wanted to
instead of sorting by date, we could do it by title as well to look for "Dune" in there. And there's Dune on March 27th, 2022. Following on that though, let's say that I had some
tasks in that meeting. So, I'm going to add a checkbox here. So maybe one of the action
items in this meeting is talk to Rob about the intended
deadline for this project. So then maybe I'll have a section in the project X note called tasks. And this is the third type, so we've already gone over list and table and this is the third type which is tasks. I'll still go ahead and do
Dataview here and I'll add task. So I could just leave
it as task with a space and let's see what that brings back. Looks like we had other
tasks elsewhere in the vault. There was this one about product X that happened earlier on in the week. There's another one from my daily note where I needed to buy spaghetti and there's this task from this meeting but this is the project X note. So we don't want everything. So, we will just say where
project equals project X and not completed because if we tick off one of those tasks, then we don't really
need to chase that up. So let's see. Now we're only seeing
the one for project X. Let's see if we tick this one, that should disappear
from the Dataview query and there it is and if you untick that
it should show up again. Another thing you could
do is instead of table we could use a calendar as well. Now that's the fourth
type we've done lists, tables, tasks and now
we're doing calendar. So one thing that we
could use is file.mtime, and that's the modified time of a file. So if I get out of that, it's going to show a calendar
of notes that were changed, so you can see this is where I imported all of those Readwise books. Looks like I wrote some things
last week and today as well. Those are all the things
that I changed, see, but if we're just looking at books we're going to need to
do `FROM #books` again. The thing is that I imported
all of my Readwise notes into this test vault but normally
when Readwise is running, it's going to be automatically
importing those books when I read them. So it would be more spread out than this. Building a second brain
isn't terribly useful if it has the same issues in
retrieval and storage of data that the first one has. When we take a bottom up
approach to note taking, we're taking notes
without categorizing them or thinking about what their
purpose might be in the future. But the problem with that is that we end up with a lot of notes and we're in the Evernote
trap of just hoarding data rather than actually learning from it. Dataview gives us a way to take that data and make something actually usable so that at the end of it, we have a database of what we've learned rather than just a replica
of a flawed system. If you're wondering how
I go from reading a book to having it automatically imported and tagged and queried by Dataview, check out this video on
how I do that with Readwise and how you can do it too. And as always, thank you for
watching. ¡Gracias a todos!