AccessionSQL, one case at a time
#018Level 1 of 6 · Scenario 4: Provenance

Who owns what

Scenario 4 · Provenance

The loans committee wants a list of what the museum holds and who legally owns it. The objects table only stores an owner id, and an id is not something you put in front of a committee.

Schema · 3 tables
owners
  • idpkINTEGER
  • nameVARCHAR
  • countryVARCHAR
objects
  • idpkINTEGER
  • titleVARCHAR
  • wingVARCHAR
  • current_owner_idINTEGER
transfers
  • idpkINTEGER
  • object_idINTEGER
  • seqINTEGER
  • from_owner_idINTEGER
  • to_owner_idINTEGER
  • transferred_onDATE
  • document_refVARCHAR

Toolkit

SELECT
Choose which columns come back.
FROM
Specify which table to read.
WHERE
Filter rows by a condition.
ORDER BY
Sort the results by a column.
IS NULL
Test whether a value is missing.
INNER JOIN
Match rows in two tables. Keeps only the rows that matched on both sides.
ON
The condition the two tables match on.
Objective

Return the object title and the owner's name for every object that has an owner recorded, alphabetically by title.

Your query

starting DuckDB…
loading editor…

Results

No result yet.