A new timeline database schema

I keep track of the DC Trade Paperback Timeline through a database I designed on top of third party tools (think Airtable). I download the data as JSON and process it with JavaScript to output HTML, which is what you see on the web. For a while, the structure has been something like this:

- Title: "Demon: From the Darkness"
- Description: ""

- Title: "Tales of the Green Lantern Corps Vol. 3"
- Description: ""

- Title: "Wonder Woman: Gods and Mortals"
- Description: "The events of Demon: From the Darkness take place after Superman: Man of Steel Vol. 1 ..."

The HTML was a series of unordered lists (<ul>) and list items (<li>) for the titles, and then a dictionary definition (<dd>) inside a dictionary list (<dl>) — with no dictionary term (<dt>), I know, I know!

The JavaScript would start off dropping an opening <ul>, and then every time it came to a description that wasn’t empty, it would close the unordered list, open a dictionary list, include the description in the dictionary definition, close the dictionary list, and then open a new unordered list in expectation of the next set of titles. At the end I’d need one more set of closing tags to finish it all out.

My impetus for changing all this was trying to simplify my processes related to “dynamic” posts on the site as part of the general site refresh — that is, not the straight review posts, but the timeline, the review index, the category and date archives, etc. — a way that these could be auto-generated better, toward pushing them online through an API. And as I was looking at the timeline structure, it was starting to bother me that, semantically, the titles (the <ul>s) were wholly disconnected from the descriptions (the <dl>s), not to mention that indeed I’m using dictionary lists semantically wrong in not having dictionary terms, just dictionary definitions.

And then I got it. The problem here is that whereas I was making descriptions (the timeline text) the children of the titles (and it was just that some titles had descriptions and some didn’t), what I really needed was to start creating timeline “blocks,” each of which contained a description, and then multiple titles could link to a block. The example above comes from the Legends section of the timeline, the first section, and it’s the second block. Under the new schema, my database looks like this:

- Block: 1-2
- Description: "The events of Demon: From the Darkness take place after Superman: Man of Steel Vol. 1 ..."

- Titles
- - Title: "Demon: From the Darkness"
- - Block: 1-2
- - Order: 1

- - Title: "Tales of the Green Lantern Corps Vol. 3"
- - Block: 1-2
- - Order: 2

- - Title: "Wonder Woman: Gods and Mortals"
- - Block: 1-2
- - Order: 3

Now, instead of having empty description fields that really weren’t functioning for anything (since multiple titles were “related” to one description), the titles point back to a block “address” and bring with them their own order data for within that block. It also means the Javascript isn’t starting with a <ul> and then parsing record by record until it finds a description, in which case it closes the <ul> and opens a <dl> — which sometimes led to unclosed tags — but rather each “block” is now its own discrete entity.

What does this mean for your experience with the DC Trade Paperback Timeline? I am updating the code so that I’m using dictionary lists correctly, nesting the unordered lists within a dictionary term and then keeping the descriptions as dictionary definitions, but visually you shouldn’t see a difference. But whereas before, given over 1,500 titles on the timeline, if I wanted to add a book in the middle — say, a series where I had some volumes, skipped a few, and then had some more — that required updating the sequential order of potentially hundreds of titles. Now, to add a title to an existing block only means updating the sequence of 10–20 titles within that block, a faster and considerably less complicated endeavor.

In the last timeline update, I added a bunch of Harley Quinn books that were missing from the timeline between volumes of Harley Quinn that had been added. Some of that I did under the old timeline system, some under the new. But I’ve recently added some missing Flash titles in the database on my end using the new system and it was much faster and easier, so I’m hoping that will lead to more updates overall.

Comments

Post a Comment

To post a comment, you may need to temporarily allow "cross-site tracking" in your browser of choice.

Newer Post Home Older Post