Lab Impossible to complete with just lecture knowledge (Apply the Polymorphic Pattern)

What is a first time learner supposed to know to attempt this lab?
There are no reference readings below the lecture, should learner be googling through mongo blogs?
Generally i don’t remember any part of the whole course teaching the student how the schema is converted to the materialized representation (which is what the lectures show), so the labs requiring the inverse operation of editing the schema is difficult.
All previous labs have a {} on outer level, but this one has [] of {}. What does it mean? I thought i had to reduce the 3 {} objects into 1 somehow, with sub documents.
How is [] syntax in schema related to polymorphism? Is this the only pattern that needs []?
Lecture: Guide to Homework Validation says this schema is a custom notation for schema definition, and isn’t jsonSchema. If it’s custom, how does a student know how to edit it without documentation of the syntax possibilities? Previous labs are still manageable because the lecture shows some examples, but this one felt like it wasn’t created to support learning.

should be unified across all documents. What does “unify” mean exactly? What must someone do to achieve that? I don’t remember the lecture demonstrating how to unify something, or that it has to do with making sure field names and types are consistent. (I only knew this after looking at the answer).

It is a thing inherent from Javascript. For a JSON representation {} means a single object and [] mean an array. an object can have many key:value pairs and every value can be an atomic, or another object, or an array, also indexed by the key. in contrast, an array has only values that will be indexed by a number starting from 0, but they can be any atomic, object, or array. (atomic means string, number, true/false)

In that lecture, you are told you have 3 different schemas in use, so they themselves are the objects. But then instead of 3 separate files, you are given an array made of those 3 schema objects.

and yes, you are now required to unify these 3 formats but not all the fields. if you look closely, some key names are slightly different but refer to the same thing. you need to “unify” them under the same name, and also add some new key-value pairs as required. (also the value type might need a change from an atomic to an array if it will hold many items)

if it helps, create 3 new json files and carry these 3 objects into them (printed book, electronic book, audio book), make required changes, then combine them again in a single file for the validation purpose.

as an example, you might have 3 student schemas with “sid”, “student_id” and “stud_id” all referring to ID of a student, then you would change them to a single name, say “student_id”. you would of course change already existing documents later to have this new key but that is another topic.

2 Likes