
CREATE TABLE chip_model (
	"Model_name" TEXT, 
	"Launch_year" REAL, 
	"RAM_MiB" REAL, 
	"ROM_MiB" REAL, 
	"Slots" TEXT, 
	"WiFi" TEXT, 
	"Bluetooth" TEXT, 
	PRIMARY KEY ("Model_name")
)


CREATE TABLE phone (
	"Company_name" TEXT, 
	"Hardware_Model_name" TEXT, 
	"Accreditation_type" TEXT, 
	"Accreditation_level" TEXT, 
	"Date" TEXT, 
	chip_model TEXT, 
	screen_mode TEXT, 
	PRIMARY KEY ("Hardware_Model_name"), 
	FOREIGN KEY(chip_model) REFERENCES chip_model ("Model_name"), 
	FOREIGN KEY(screen_mode) REFERENCES screen_mode ("Graphics_mode")
)


CREATE TABLE screen_mode (
	"Graphics_mode" REAL, 
	"Char_cells" TEXT, 
	"Pixels" TEXT, 
	"Hardware_colours" REAL, 
	used_kb REAL, 
	map TEXT, 
	"Type" TEXT, 
	PRIMARY KEY ("Graphics_mode")
)

CREATE TABLE chip_model (
	"Model_name" TEXT, 
	"Launch_year" REAL, 
	"RAM_MiB" REAL, 
	"ROM_MiB" REAL, 
	"Slots" TEXT, 
	"WiFi" TEXT, 
	"Bluetooth" TEXT, 
	PRIMARY KEY ("Model_name")
)

/*
2 rows from chip_model table:
Model_name	Launch_year	RAM_MiB	ROM_MiB	Slots	WiFi	Bluetooth
X5	2002.0	32.0	32.0	1CFII,1SD	No	No
X5 high end	2002.0	64.0	48.0	1CFII,1SD	No	No
*/


CREATE TABLE phone (
	"Company_name" TEXT, 
	"Hardware_Model_name" TEXT, 
	"Accreditation_type" TEXT, 
	"Accreditation_level" TEXT, 
	"Date" TEXT, 
	chip_model TEXT, 
	screen_mode TEXT, 
	PRIMARY KEY ("Hardware_Model_name"), 
	FOREIGN KEY(chip_model) REFERENCES chip_model ("Model_name"), 
	FOREIGN KEY(screen_mode) REFERENCES screen_mode ("Graphics_mode")
)

/*
2 rows from phone table:
Company_name	Hardware_Model_name	Accreditation_type	Accreditation_level	Date	chip_model	screen_mode
Sony Mobile Communications	XPERIA T, XPERIA J	Full	joyn Hot Fixes	Approved (awarded 15.11.12)	X5	1
LG Electronics	LG-P760	Full	joyn Hot Fixes	Approved (awarded 19.11.12)	X51v	3
*/


CREATE TABLE screen_mode (
	"Graphics_mode" REAL, 
	"Char_cells" TEXT, 
	"Pixels" TEXT, 
	"Hardware_colours" REAL, 
	used_kb REAL, 
	map TEXT, 
	"Type" TEXT, 
	PRIMARY KEY ("Graphics_mode")
)

/*
2 rows from screen_mode table:
Graphics_mode	Char_cells	Pixels	Hardware_colours	used_kb	map	Type
0.0	80 × 32	640 × 256	2.0	20.0	3000–7FFF	Graphics
1.0	40 × 32	320 × 256	4.0	20.0	3000–7FFF	Graphics
*/
List all the model names sorted by their launch year.
SELECT model_name FROM chip_model ORDER BY launch_year
[{'Model_name': 'X5'}, {'Model_name': 'X5 high end'}, {'Model_name': 'X3 Basic'}, {'Model_name': 'X3 Advanced'}, {'Model_name': 'X3i'}, {'Model_name': 'X30 low-end'}, {'Model_name': 'X30 mid-range'}, {'Model_name': 'X30 high-end'}, {'Model_name': 'X50 Standard'}, {'Model_name': 'X50 Advanced'}, {'Model_name': 'X50v'}, {'Model_name': 'X51 low-end'}, {'Model_name': 'X51 mid-range'}, {'Model_name': 'X51v'}]