Lab Test 2 Version B W23 Mad 6123

Lab Test: Building the Back End Data Store for a Node.js Full Stack Web Application

Scenario: You are building a back end data store for a pet store that needs to store information about pets and their owners.


Pets: stores information about the pets, such as their name, species, breed, age, and owner ID.
Owners: stores information about the owners, such as their name, address, phone number, and email address.
Breeds: stores information about the different breeds of pets, such as their name and characteristics.

Sample Data:

Name: Bella, Species: Dog, Breed: Labrador Retriever, Age: 3, Owner ID: 1
Name: Simba, Species: Cat, Breed: Siamese, Age: 2, Owner ID: 2
Name: Max, Species: Dog, Breed: Golden Retriever, Age: 4, Owner ID: 3
Name: John Smith, Address: 123 Main St, Phone: 555-1234, Email:
Name: Jane Doe, Address: 456 Maple Ave, Phone: 555-5678, Email:
Name: Bob Johnson, Address: 789 Oak St, Phone: 555-9012, Email:
Name: Labrador Retriever, Characteristics: Friendly, Energetic, Intelligent
Name: Siamese, Characteristics: Intelligent, Affectionate, Talkative
Name: Golden Retriever, Characteristics: Friendly, Intelligent, Devoted


Make a MongoDB database with collections for pets, owners, and breeds.
Add sample data for pets, owners, and breeds to your database.
Implement a join between the pets and owners collections to retrieve a list of pets and their owners.
Implement a join between the pets and breeds collections to retrieve a list of pets and their breeds.
Implement a join between the owners and pets collections to retrieve a list of owners and their pets.
Test your application by running queries to retrieve the lists of pets and their owners, pets and their breeds, and owners and their pets.

JSON Schema:

"Pets": {
"<Pet ID>": {
"Name": "<Pet Name>",
"Species": "<Pet Species>",
"Breed": "<Breed Name>",
"Age": "<Pet Age>",
"Owner ID": "<Owner ID>"
"Owners": {
"<Owner ID>": {
"Name": "<Owner Name>",
"Address": "<Owner Address>",
"Phone": "<Owner Phone>",
"Email": "<Owner Email>"
"Breeds": {
"<Breed Name>": {
"Characteristics": "<Breed Characteristics>"

Starter Code:

{ $lookup:
from: "owners",
localField: "owner_id",
foreignField: "_id",
as: "owner"
{ $lookup:
from: "breeds",
localField: "breed",
foreignField: "_id",
as: "breed"

{ $lookup:
from: "pets",
localField: "_id",
foreignField: "owner_id",
as: "pets"

Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
) instead.