Category Document

In the technology overview section, we briefly discussed the ideas behind a document-oriented database and how it is used in Scrapbook101. In this section we describe one of the two key document types stored in the document-oriented database, the category document.

Our design approach is model-first approach meaning we start with a prototype category document in JSON that represents Scrapbook101 categories. From this prototype document, a the code class Category.cs is defined in our Visual Studio project representing this category document.

Overview

This Scrapbook101 category document defines the types of categories that items can belong to (via the category field). It is one of the two document types (distinguished by the type field) stored in the document-oriented datastore. The other is the Item Document. The data store will contain many item documents and one category document.

The categories used in Scrapbook101 are: Book, Event, Film, Museum, People, and Performance. This reduced number of categories was selected to make the code easier to work with and describe. In the version of Scrapbook described in the related blog post over 20 categories are used.

Each category has a name, description, and one or more associated categoryFields.

{
    "id": "GUID",
    "type": "scrapbook101Categories",
    "categories": [
        {
            "name": "Book",
            "description": "Book",
            "categoryFields": {
                "author": "Author name.",
                "genre": "Genre.",
                "pubYear": "Year published.",
                "synopsis": "Short description.",
                "theme": "Topic or themes."
            }
        },
        {
            "name": "Event",
            "description": "A gathering, party, celebration.",
            "categoryFields": {
                "location": "Joe Smith's house, restaurant name.",
                "people": "A list of people who were there.",
                "type": "[dinner, lunch, party, wedding, festival]"
            }
        },
        {
            "name": "Film",
            "description": "Movie, documentary, series.",
            "categoryFields": {
                "director": "Director name.",
                "genre": "Genre",
                "releaseYear": "Release year.",
                "synopsis": "Short description."
            }
        },
        {
            "name": "Museum",
            "description": "A musuem, site.",
            "categoryFields": {
                "highlight": "Highlight."
            }
        },
        {
            "name": "People",
            "description": "Friend, family, contact, group.",
            "categoryFields": {
                "birthDate": "yyyy-mm-dd",
                "location:": "Where the person lives.",
                "type": "[family, friend, contact, group]"
            }
        },
        {
            "name": "Performance",
            "description": "Theater, concert, play, live performance.",
            "categoryFields": {
                "artist": "Composer, author, or artist.",
                "location": "Venue, theater name.",
                "synopsis": "Brief one sentence overview.",
                "type": "[theater, theatre, concert, play, ballet, opera, dance]"
            }
        }
    ]
}

Description of fields

Fields not marked as Required are not required.

categoryFields
Data fields specific to the category. In this implementation of Scrapbook101 item, the following keys are supported artist, author, birthDate, director, genre, highlight, location, synopsis, theme, type who, and year. The keys are not required. If specified, their values are strings.

Which keys are used depends on the category chosen for the Scrapbook101 item. If null, no keys are stored for the item.

Default: null
Format: A JSON object containing key-value pairs.

description
Describes the category. This field is used for information in dropdowns or tooltips.

Default: null
Format: A string.

id
This is an auto-generated GUID representing the item. The value can be auto-generated or assigned. The id is used to easily reference the category document.

Required
Format: A GUID, e.g., "49916d87-e565-4220-8806-b9e60c867ae6".

type
Describes the type of record. If your records are stored in a data store with other records with an id field, then type helps distinguish Scrapbook101 records uniquely. There are two types of documents, item documents and category documents.

Required
Format: A string equal to "scrapbook101Categories".