DB Quacks SQL Tutorial · Chapter 6

JSON Bourne: The Schema Identity

Jason Bourne Duck appears in tactical gear. Ive lost my data identity! Complex JSON with nested duck profiles - extract names and favorite foods from deep inside flexible schemas. Navigate the schema-free underworld!

Your task

Extract duck names and their favorite food from nested JSON data using the 'data/json_duck_profiles.json' file. You will be navigating nested JSON structures using JSON operators.

Hint

Look for operators that can access nested JSON properties and extract text values.

Expected result

A table showing duck names and their favorite foods extracted from JSON.

Tables

duck_diaries (10 rows)

columntype
diary_idBIGINT
duck_idBIGINT
entry_dateDATE
diary_textVARCHAR
moodVARCHAR

duck_surveys (5000 rows)

columntype
survey_idBIGINT
duck_idBIGINT
ageBIGINT
favorite_foodVARCHAR
favorite_pondBIGINT
swimming_ratingBIGINT
migration_preferenceVARCHAR
social_behaviorVARCHAR
health_statusVARCHAR
activity_levelVARCHAR
survey_dateDATE
survey_locationBIGINT

ducks (15 rows)

columntype
idBIGINT
nameVARCHAR
ageBIGINT
speciesVARCHAR
birth_dateDATE
arrival_dateDATE

ponds (3 rows)

columntype
pond_idBIGINT
pond_nameVARCHAR
location_latDOUBLE
location_lngDOUBLE
capacityBIGINT
featuresVARCHAR[]
amenitiesVARCHAR[]

Files

data/json_duck_profiles.json (5 rows)

columntype
profile_idBIGINT
dataSTRUCT(duck_id BIGINT, "name" VARCHAR, skills VARCHAR[], preferences STRUCT(favorite_food VARCHAR, favorite_activity VARCHAR, favorite_time VARCHAR), contact_info STRUCT(email VARCHAR, phone VARCHAR))

Database: https://dbquacks.com/data/databases/tutorial.duckdb

This page as markdown: https://dbquacks.com/tutorial/34.md

Start level 34 →

DuckDB docs for this lesson