Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
250 lines (250 sloc) 10.7 KB
[
{
"puzzle": "S1",
"exemplar": "suppliers-and-parts",
"level": 0,
"description": "Get all suppliers.",
"predicate": "Supplier with number `sid` is named `name`, has status `status` and is located in the city named `city`",
"hints": "\"Get all...\" and \"Get ... (unqualified)\" means \"with all available attributes\"."
},
{
"puzzle": "S2",
"exemplar": "suppliers-and-parts",
"level": 0,
"description": "Get the number and name of suppliers.",
"predicate": "Supplier with number `sid` is named `name`",
"hints": "\"Get x, y, and z ...\" means \"x, y and z attributes only\"."
},
{
"puzzle": "S3",
"exemplar": "suppliers-and-parts",
"level": 0,
"description": "Get all but the status of suppliers.",
"predicate": "(There exists a status such that) supplier with number `sid` is named `name` and is located in city named `city`",
"hints": "\"Get all but x, y and z\" means \"all available attributes except x, y and z\""
},
{
"puzzle": "S4",
"exemplar": "suppliers-and-parts",
"level": 0,
"description": "Get the city names where at least one supplier is located.",
"predicate": "(There exists a supplier, say s, ... such that) s is located in city named `city`",
"hints": "In accordance with relational theory, \"the city names\" means \"no duplicates\"."
},
{
"puzzle": "S5",
"exemplar": "suppliers-and-parts",
"level": 0,
"description": "Get suppliers with status in the range 15 to 25 inclusive.",
"predicate": "[Supplier with number `sid` is named `name`, has status `status`, is located in city named `city`] and his status is in the range 15 to 25 inclusive",
"hints": ""
},
{
"puzzle": "S6",
"exemplar": "suppliers-and-parts",
"level": 0,
"description": "Get suppliers located in London or Athens.",
"predicate": "[...] and that city is named London or is named Athens",
"hints": "[...] means \"the common predicate for the relation variable at hand\""
},
{
"puzzle": "S7",
"exemplar": "suppliers-and-parts",
"level": 0,
"description": "Get suppliers not located in London nor in Athens.",
"predicate": "[...] and that city is not named London nor Athens",
"hints": ""
},
{
"puzzle": "S8",
"exemplar": "suppliers-and-parts",
"level": 0,
"description": "Get supplier numbers for suppliers located in London.",
"predicate": "Supplier with number `sid` is located in London",
"hints": ""
},
{
"puzzle": "E1",
"exemplar": "suppliers-and-parts",
"level": 1,
"description": "Get supplier numbers for suppliers who supply part P1.",
"predicate": "Supplier with number `sid` supplies the part whose number is P1",
"hints": ""
},
{
"puzzle": "E2",
"exemplar": "suppliers-and-parts",
"level": 1,
"description": "Get how many shipments there are.",
"predicate": "The total count of shipments is `c`",
"hints": "The result is a single scalar. To keep the automation of corrections simple enough, we want a relation with one single tuple and one single attribute named `c`."
},
{
"puzzle": "E3",
"exemplar": "suppliers-and-parts",
"level": 1,
"description": "Get how many parts are supplied by supplier S1.",
"predicate": "Supplier whose number is S1 supplies `c` parts",
"hints": "By convention, an unknown supplier supplies no part at all, accounting for zero."
},
{
"puzzle": "E4",
"exemplar": "suppliers-and-parts",
"level": 1,
"description": "Get suppliers who supply at least one part.",
"predicate": "Supplier with number `sid` is named `name`, has status `status`, is located in the city named `city` and supplies at least one part (i.e. there exists a part number such that...)",
"hints": ""
},
{
"puzzle": "E5",
"exemplar": "suppliers-and-parts",
"level": 1,
"description": "Get suppliers who supply no part at all.",
"predicate": "Supplier with number `sid` [is named ...] and supplies no part at all (i.e. there does not exist...)",
"hints": "negation, exists, forall"
},
{
"puzzle": "E6",
"exemplar": "suppliers-and-parts",
"level": 1,
"description": "Get shipments together with the name of the supplier (sname) and the name of the part (pname)",
"predicate": "Supplier with number `sid` is named `sname` and ships the part with number `pid`, named `pname` in `qty` quantity.",
"hints": ""
},
{
"puzzle": "M1",
"exemplar": "suppliers-and-parts",
"level": 2,
"description": "Get the `total` quantity of parts supplied by supplier S1.",
"predicate": "Supplier whose number is S1 supplies parts for a total quantity of `total`",
"hints": "By convention, an unknown supplier supplies no part at all, for a total quantity of zero. SQL may seem to lack consistency... Does Tutorial D do?"
},
{
"puzzle": "M2",
"exemplar": "suppliers-and-parts",
"level": 2,
"description": "Get part numbers for parts supplied by at least one supplier in Paris.",
"predicate": "The exists at least one supplier located in Paris who supplies the part whose number is `pid`",
"hints": ""
},
{
"puzzle": "M3",
"exemplar": "suppliers-and-parts",
"level": 2,
"description": "Get city names for cities in which at least two suppliers are located.",
"predicate": "There exists at least two suppliers located in the city named `city`",
"hints": "At least means \">=\""
},
{
"puzzle": "M4",
"exemplar": "suppliers-and-parts",
"level": 2,
"description": "Get supplier numbers for suppliers whose city is first in the alphabetic list of such cities.",
"predicate": "Supplier with number `sid` is located in the city named `city` and that city name appears first in the alphabetic list of supplier cities.",
"hints": ""
},
{
"puzzle": "M5",
"exemplar": "suppliers-and-parts",
"level": 2,
"description": "Get the supplier numbers and the `total` quantity of supplied parts for each of them.",
"predicate": "Supplier with number `sid` supplies parts for a total quantity of `total`",
"hints": "Including those who do not seem to supply any part"
},
{
"puzzle": "M6",
"exemplar": "suppliers-and-parts",
"level": 2,
"description": "Get the number(s) of lightest part(s). In case of ex-aequo, get all parts with that smallest weight.",
"predicate": "Part with number `pid` has the smallest known weight among all parts",
"hints": ""
},
{
"puzzle": "D1",
"exemplar": "suppliers-and-parts",
"level": 3,
"description": "Get part numbers for parts not supplied by any supplier in Paris.",
"predicate": "No supplier in Paris supplies the part with number `pid`",
"hints": ""
},
{
"puzzle": "D2",
"exemplar": "suppliers-and-parts",
"level": 3,
"description": "Get numbers of suppliers who supply all parts.",
"predicate": "Supplier with number `sid` supplies all parts.",
"hints": "What if no parts at all?"
},
{
"puzzle": "D3",
"exemplar": "suppliers-and-parts",
"level": 3,
"description": "Get supplier for suppliers with a status strictly lower than of supplier S1.",
"predicate": "Supplier with number `sid` is named [...] and has a status strictly lower than supplier with number S1",
"hints": "What if supplier S1 does not exist?"
},
{
"puzzle": "D4",
"exemplar": "suppliers-and-parts",
"level": 3,
"description": "Get supplier-number\/part-number pairs such that the indicated supplier does not supply the indicated part.",
"predicate": "Supplier with number `sid` does not supply part with number `pid`",
"hints": ""
},
{
"puzzle": "D5",
"exemplar": "suppliers-and-parts",
"level": 3,
"description": "Get every known city together with the count of parts located in that city (`ps`), the count of suppliers located there (`ss`), and the total shipped quantity by the latter (`total`).",
"predicate": "In city named `city`, there are `ps` located parts, `ss` located suppliers and a total quantity of `total` shipped parts by those suppliers.",
"hints": "ALL known cities"
},
{
"puzzle": "D6",
"exemplar": "suppliers-and-parts",
"level": 3,
"description": "Get the heaviest part. In case of ex-aequo, select the one with the smallest part number.",
"predicate": "Part number `pid` is the first in the alphabetic list of (part numbers of) heaviest parts",
"hints": ""
},
{
"puzzle": "H1",
"exemplar": "suppliers-and-parts",
"level": 4,
"description": "Get every city name where at least one part is located, together with the average supplier status in that city (`avg_status`). Do not include cities where no supplier is located.",
"predicate": "At least one part is located in the the city named `city` and that city has located suppliers for an average status of `avg_status`",
"hints": ""
},
{
"puzzle": "H2",
"exemplar": "suppliers-and-parts",
"level": 4,
"description": "Get part numbers for parts supplied by all suppliers in London.",
"predicate": "Part with number `pid` is supplied by all suppliers located in London",
"hints": ""
},
{
"puzzle": "H3",
"exemplar": "suppliers-and-parts",
"level": 4,
"description": "Get all pairs of supplier numbers, say sx and sy, such that sx and sy supply exactly the same set of parts each.",
"predicate": "Supplier with number `sx` supplies the same parts as supplier with number `sy`.",
"hints": "\"the same parts\" means the same set of part numbers, that is, abstracting from quantities. We require here supplier numbers to be distinct (i.e. sx <> sy) and consider ordered pairs, that is, (sx=S1,sy=S2) is different than (sx=S2,sy=S1)."
},
{
"puzzle": "H4",
"exemplar": "suppliers-and-parts",
"level": 4,
"description": "Get all pairs of part numbers (as `p` and `q`) such that some supplier supplies both of the indicated parts.",
"predicate": "There exists a supplier supplying both part with number `p` and part with number `q`",
"hints": "We require here part numbers to be distinct (i.e. p <> q) and consider ordered pairs, that is, (p=P1,q=P2) is different than (p=P2,q=P1)."
},
{
"puzzle": "H5",
"exemplar": "suppliers-and-parts",
"level": 4,
"description": "Get supplier numbers for suppliers supplying at least as many parts as the three \"best\" suppliers (in terms of supplied quantities), together with their respective total quantity.",
"predicate": "With a total quantity of supplied parts `total`, supplier with number `sid` is among those who supply the three largest total quantities of parts.",
"hints": "The result does not necessarily contain three tuples; it might contain more (why?), or less (why?)."
}
]
You can’t perform that action at this time.