Database schema:

CREATE TABLE cards (
	id INTEGER NOT NULL -- unique id number identifying the cards, example: ['41138', '1349'],
	artist TEXT -- example: ['Volkan Baǵa', 'Pete Venters'],
	"asciiName" TEXT -- ascii Name, example: ['Junun Efreet', 'El-Hajjaj'],
	availability TEXT -- example: ['mtgo,paper', 'paper'],
	"borderColor" TEXT -- border Color, example: ['black', 'white'],
	"cardKingdomFoilId" TEXT -- card Kingdom Foil Id, example: ['123094', '123095'],
	"cardKingdomId" TEXT -- card Kingdom Id, example: ['122719', '122720'],
	"colorIdentity" TEXT -- color Identity, example: ['B', 'W'],
	"colorIndicator" TEXT -- color Indicator, example: ['U', 'G'],
	colors TEXT -- example: ['B', 'W'],
	"convertedManaCost" REAL -- converted Mana Cost, example: ['5.0', '7.0'],
	"duelDeck" TEXT -- duel Deck, example: ['b', 'a'],
	"edhrecRank" INTEGER -- rec Rank in edh, example: ['15650', '12702'],
	"faceConvertedManaCost" REAL -- face Converted Mana Cost, example: ['5.0', '4.0'],
	"faceName" TEXT -- face Name, example: ['Dusk', 'Dawn'],
	"flavorName" TEXT -- flavor Name, example: ['Godzilla, King of the Monsters', 'King Caesar, Ancient Guardian'],
	"flavorText" TEXT -- flavor Text, example: ['The perfect antidote for a tightly packed formatio', 'Every tear shed is a drop of immortality.'],
	"frameEffects" TEXT -- frame Effects, example: ['nyxtouched', 'legendary'],
	"frameVersion" TEXT -- frame Version, example: ['2003', '1993'],
	hand TEXT -- example: ['0', '1'],
	"hasAlternativeDeckLimit" INTEGER DEFAULT 0 NOT NULL, 
	"hasContentWarning" INTEGER DEFAULT 0 NOT NULL -- has Content Warning, example: ['0', '1'],
	"hasFoil" INTEGER DEFAULT 0 NOT NULL -- has Foil, example: ['0', '1'],
	"hasNonFoil" INTEGER DEFAULT 0 NOT NULL -- has Non Foil, example: ['0', '1'],
	"isAlternative" INTEGER DEFAULT 0 NOT NULL, 
	"isFullArt" INTEGER DEFAULT 0 NOT NULL -- is Full Art, example: ['0', '1'],
	"isOnlineOnly" INTEGER DEFAULT 0 NOT NULL -- is Online Only, example: ['0', '1'],
	"isOversized" INTEGER DEFAULT 0 NOT NULL -- is Oversized, example: ['0', '1'],
	"isPromo" INTEGER DEFAULT 0 NOT NULL -- is Promotion, example: ['0', '1'],
	"isReprint" INTEGER DEFAULT 0 NOT NULL -- is Reprint, example: ['0', '1'],
	"isReserved" INTEGER DEFAULT 0 NOT NULL -- is Reserved, example: ['0', '1'],
	"isStarter" INTEGER DEFAULT 0 NOT NULL -- is Starter, example: ['0', '1'],
	"isStorySpotlight" INTEGER DEFAULT 0 NOT NULL -- is Story Spotlight, example: ['0', '1'],
	"isTextless" INTEGER DEFAULT 0 NOT NULL -- is Text less, example: ['0', '1'],
	"isTimeshifted" INTEGER DEFAULT 0 NOT NULL -- is Time shifted, example: ['0', '1'],
	keywords TEXT -- example: ['First strike', 'Flying'],
	layout TEXT -- example: ['normal', 'aftermath'],
	"leadershipSkills" TEXT -- leadership Skills, example: ["{'brawl': False, 'commander': False, 'oathbreaker'", "{'brawl': False, 'commander': True, 'oathbreaker':"],
	life TEXT -- example: ['-1', '-5'],
	loyalty TEXT -- example: ['6', '3'],
	"manaCost" TEXT -- mana Cost, example: ['{5}{W}{W}', '{4}{W}'],
	"mcmId" TEXT -- example: ['16166', '16165'],
	"mcmMetaId" TEXT -- example: ['176', '156'],
	"mtgArenaId" TEXT -- example: ['74986', '74983'],
	"mtgjsonV4Id" TEXT -- example: ['9eb2e54c-a12b-5e88-a9c0-d8c84c52d59c', 'ad41be73-582f-58ed-abd4-a88c1f616ac3'],
	"mtgoFoilId" TEXT -- example: ['27501', '26993'],
	"mtgoId" TEXT -- example: ['26992', '27500'],
	"multiverseId" TEXT -- example: ['129465', '130550'],
	name TEXT -- example: ["Ancestor's Chosen", 'Angel of Mercy'],
	number TEXT -- example: ['2', '1'],
	"originalReleaseDate" TEXT -- example: ['2006/12/1', '2012/12/1'],
	"originalText" TEXT -- example: ['First strike (This creature deals combat damage be', "Flying (This creature can't be blocked except by c"],
	"originalType" TEXT -- example: ['Creature - Angel', 'Creature - Human Cleric'],
	"otherFaceIds" TEXT -- example: ['f9f10d34-071c-57a6-b58c-7553abad5c20', '87f0062a-8321-5c16-960e-a12ce1df5839'],
	power TEXT -- example: ['4', '3'],
	printings TEXT -- example: ['10E,8ED,9ED,DDC,DVD,IMA,INV,JMP,MB1,P02,PS11,PSAL,', '10E,JUD,UMA'],
	"promoTypes" TEXT -- promo Types, example: ['boxtopper,boosterfun', 'boosterfun'],
	"purchaseUrls" TEXT -- purchase Urls, example: ["{'cardKingdom': 'https://mtgjson.com/links/027095d", "{'cardKingdom': 'https://mtgjson.com/links/9fb51af"],
	rarity TEXT -- example: ['common', 'uncommon'],
	"scryfallId" TEXT -- example: ['7a5cd03c-4227-4551-aa4b-7d119f0468b5', '8f7980d4-da43-4d6d-ad16-14b8a34ae91d'],
	"scryfallIllustrationId" TEXT -- example: ['be2f7173-c8b7-4172-a388-9b2c6b3c16e5', 'e4d6c53f-e936-4be8-8b70-47c2be863b20'],
	"scryfallOracleId" TEXT -- example: ['a2daaf32-dbfe-4618-892e-0da24f63a44a', 'fc2ccab7-cab1-4463-b73d-898070136d74'],
	"setCode" TEXT -- Set Code, example: ['10E', '2ED'],
	side TEXT -- example: ['b', 'a'],
	subtypes TEXT -- example: ['Human,Cleric', 'Angel'],
	supertypes TEXT -- super types, example: ['Basic', 'Legendary'],
	"tcgplayerProductId" TEXT -- tcg player ProductId, example: ['15032', '15033'],
	text TEXT -- example: ['First strike (This creature deals combat damage be', 'Flying\nWhen Angel of Mercy enters the battlefield,'],
	toughness TEXT -- example: ['4', '3'],
	type TEXT -- example: ['Creature — Human Cleric', 'Creature — Angel'],
	types TEXT -- example: ['Instant', 'Creature'],
	uuid TEXT NOT NULL -- example: ['0001e0d0-2dcd-5640-aadc-a84765cf5fc9', '00010d56-fe38-5e35-8aed-518019aa36a5'],
	variations TEXT -- example: ['8fd4e2eb-3eb4-50ea-856b-ef638fa47f8a', 'b7c19924-b4bf-56fc-aa73-f586e940bd42'],
	watermark TEXT -- example: ['set (HOU)', 'set (LGN)'],
	PRIMARY KEY (id)
)


CREATE TABLE foreign_data (
	id INTEGER NOT NULL -- example: ['2', '1'],
	"flavorText" TEXT -- flavor Text, example: ['"La voluntad de todos, realizada por mi mano."', '„Es ist der Wille aller, und meine Hand, die ihn a'],
	language TEXT -- example: ['Spanish', 'German'],
	multiverseid INTEGER -- example: ['150317', '148411'],
	name TEXT -- example: ['Ausgewählter der Ahnfrau', 'Elegido de la Antepasada'],
	text TEXT -- example: ['Erstschlag (Diese Kreatur fügt Kampfschaden vor Kr', 'Daña primero. (Esta criatura hace daño de combate '],
	type TEXT -- example: ['Criatura — Clérigo humano', 'Kreatur — Mensch, Kleriker'],
	uuid TEXT -- example: ['57aaebc1-850c-503d-9f6e-bb8d00d8bf7c', '5f8287b1-5bb6-5f4c-ad17-316a40d5bb0c'],
	PRIMARY KEY (id), 
	CONSTRAINT fk_foreign_data_cards FOREIGN KEY(uuid) REFERENCES cards (uuid)
)


CREATE TABLE legalities (
	id INTEGER NOT NULL -- example: ['2', '1'],
	format TEXT -- example: ['duel', 'commander'],
	status TEXT -- example: ['Banned', 'Legal'],
	uuid TEXT -- example: ['57aaebc1-850c-503d-9f6e-bb8d00d8bf7c', '5f8287b1-5bb6-5f4c-ad17-316a40d5bb0c'],
	PRIMARY KEY (id), 
	CONSTRAINT fk_legalities_cards FOREIGN KEY(uuid) REFERENCES cards (uuid)
)


CREATE TABLE rulings (
	id INTEGER NOT NULL -- example: ['2', '1'],
	date DATE -- example: ['2007-02-01', '2007-07-15'],
	text TEXT -- example: ['If you double a negative life total, you do the re', 'You draw the card when Bandage resolves, not when '],
	uuid TEXT -- example: ['6d268c95-c176-5766-9a46-c14f739aba1c', '56f4935b-f6c5-59b9-88bf-9bcce20247ce'],
	PRIMARY KEY (id), 
	CONSTRAINT fk_rulings_cards FOREIGN KEY(uuid) REFERENCES cards (uuid)
)


CREATE TABLE set_translations (
	id INTEGER NOT NULL -- example: ['2', '1'],
	language TEXT -- example: ['Chinese Simplified', 'Chinese Traditional'],
	"setCode" TEXT -- set code, example: ['10E', '4ED'],
	translation TEXT -- example: ['Dixième édition', '核心系列第十版'],
	PRIMARY KEY (id), 
	CONSTRAINT fk_set_translations_sets FOREIGN KEY("setCode") REFERENCES sets (code)
)


CREATE TABLE sets (
	id INTEGER NOT NULL -- example: ['2', '1'],
	"baseSetSize" INTEGER -- base Set Size, example: ['302', '383'],
	block TEXT -- example: ['Core Set', 'Mirrodin'],
	booster TEXT -- example: ["{'default': {'boosters': [{'contents': {'basic': 1", "{'default': {'boosters': [{'contents': {'common': "],
	code TEXT NOT NULL -- example: ['10E', '2ED'],
	"isFoilOnly" INTEGER DEFAULT 0 NOT NULL -- is Foil Only, example: ['0', '1'],
	"isForeignOnly" INTEGER DEFAULT 0 NOT NULL -- is Foreign Only, example: ['0', '1'],
	"isNonFoilOnly" INTEGER DEFAULT 0 NOT NULL -- is Non Foil Only, example: ['0', '1'],
	"isOnlineOnly" INTEGER DEFAULT 0 NOT NULL -- is Online Only, example: ['0', '1'],
	"isPartialPreview" INTEGER DEFAULT 0 NOT NULL -- is Partial Preview, example: ['0', '1'],
	"keyruneCode" TEXT -- keyrune Code, example: ['10E', '2ED'],
	"mcmId" INTEGER -- magic card market id, example: ['3204', '74'],
	"mcmIdExtras" INTEGER -- magic card market ID Extras, example: ['3209', '3459'],
	"mcmName" TEXT -- magic card market name, example: ['Double Masters', 'Tenth Edition'],
	"mtgoCode" TEXT -- magic the gathering online code, example: ['10E', '2XM'],
	name TEXT -- example: ['Tenth Edition', 'Unlimited Edition'],
	"parentCode" TEXT -- parent Code, example: ['MH1', 'JMP'],
	"releaseDate" DATE -- release Date, example: ['2007-07-13', '1993-12-01'],
	"tcgplayerGroupId" INTEGER -- tcg player Group Id, example: ['1', '115'],
	"totalSetSize" INTEGER -- total Set Size, example: ['302', '508'],
	type TEXT -- example: ['masters', 'core'],
	PRIMARY KEY (id)
)

Question: List the names of all the cards in the set Hour of Devastation and find the formats in which these cards are legal.
Evidence: the set Hour of Devastation refers to set.name = 'Hour of Devastation'; names of all the cards in the set refers to cards.name; legal cards refers to status = 'Legal'; the formats refers to format

SQL:
SELECT DISTINCT T2.name , CASE WHEN T1.status = 'Legal' THEN T1.format ELSE NULL END FROM legalities AS T1 INNER JOIN cards AS T2 ON T2.uuid = T1.uuid WHERE T2.setCode IN ( SELECT code FROM sets WHERE name = 'Hour of Devastation' )