
CREATE TABLE "Document_Functional_Areas" (
	document_code VARCHAR(15) NOT NULL, 
	functional_area_code VARCHAR(15) NOT NULL, 
	FOREIGN KEY(functional_area_code) REFERENCES "Functional_Areas" (functional_area_code), 
	FOREIGN KEY(document_code) REFERENCES "Documents" (document_code)
)


CREATE TABLE "Document_Sections" (
	section_id INTEGER, 
	document_code VARCHAR(15) NOT NULL, 
	section_sequence INTEGER, 
	section_code VARCHAR(20), 
	section_title VARCHAR(80), 
	PRIMARY KEY (section_id), 
	FOREIGN KEY(document_code) REFERENCES "Documents" (document_code)
)


CREATE TABLE "Document_Sections_Images" (
	section_id INTEGER NOT NULL, 
	image_id INTEGER NOT NULL, 
	PRIMARY KEY (section_id, image_id), 
	FOREIGN KEY(image_id) REFERENCES "Images" (image_id), 
	FOREIGN KEY(section_id) REFERENCES "Document_Sections" (section_id)
)


CREATE TABLE "Document_Structures" (
	document_structure_code VARCHAR(15), 
	parent_document_structure_code VARCHAR(15), 
	document_structure_description VARCHAR(80), 
	PRIMARY KEY (document_structure_code)
)


CREATE TABLE "Documents" (
	document_code VARCHAR(15), 
	document_structure_code VARCHAR(15) NOT NULL, 
	document_type_code VARCHAR(15) NOT NULL, 
	access_count INTEGER, 
	document_name VARCHAR(80), 
	PRIMARY KEY (document_code), 
	FOREIGN KEY(document_structure_code) REFERENCES "Document_Structures" (document_structure_code)
)


CREATE TABLE "Functional_Areas" (
	functional_area_code VARCHAR(15), 
	parent_functional_area_code VARCHAR(15), 
	functional_area_description VARCHAR(80) NOT NULL, 
	PRIMARY KEY (functional_area_code)
)


CREATE TABLE "Images" (
	image_id INTEGER, 
	image_alt_text VARCHAR(80), 
	image_name VARCHAR(40), 
	image_url VARCHAR(255), 
	PRIMARY KEY (image_id)
)


CREATE TABLE "Roles" (
	role_code VARCHAR(15), 
	role_description VARCHAR(80), 
	PRIMARY KEY (role_code)
)


CREATE TABLE "Users" (
	user_id INTEGER, 
	role_code VARCHAR(15) NOT NULL, 
	user_name VARCHAR(40), 
	user_login VARCHAR(40), 
	password VARCHAR(40), 
	PRIMARY KEY (user_id), 
	FOREIGN KEY(role_code) REFERENCES "Roles" (role_code)
)

CREATE TABLE "Document_Functional_Areas" (
	document_code VARCHAR(15) NOT NULL, 
	functional_area_code VARCHAR(15) NOT NULL, 
	FOREIGN KEY(functional_area_code) REFERENCES "Functional_Areas" (functional_area_code), 
	FOREIGN KEY(document_code) REFERENCES "Documents" (document_code)
)

/*
2 rows from Document_Functional_Areas table:
document_code	functional_area_code
675	9
930	1
*/


CREATE TABLE "Document_Sections" (
	section_id INTEGER, 
	document_code VARCHAR(15) NOT NULL, 
	section_sequence INTEGER, 
	section_code VARCHAR(20), 
	section_title VARCHAR(80), 
	PRIMARY KEY (section_id), 
	FOREIGN KEY(document_code) REFERENCES "Documents" (document_code)
)

/*
2 rows from Document_Sections table:
section_id	document_code	section_sequence	section_code	section_title
12	714	6072	70	after
15	217	4510	14	after
*/


CREATE TABLE "Document_Sections_Images" (
	section_id INTEGER NOT NULL, 
	image_id INTEGER NOT NULL, 
	PRIMARY KEY (section_id, image_id), 
	FOREIGN KEY(image_id) REFERENCES "Images" (image_id), 
	FOREIGN KEY(section_id) REFERENCES "Document_Sections" (section_id)
)

/*
2 rows from Document_Sections_Images table:
section_id	image_id
93	6
86	2
*/


CREATE TABLE "Document_Structures" (
	document_structure_code VARCHAR(15), 
	parent_document_structure_code VARCHAR(15), 
	document_structure_description VARCHAR(80), 
	PRIMARY KEY (document_structure_code)
)

/*
2 rows from Document_Structures table:
document_structure_code	parent_document_structure_code	document_structure_description
1	1	Header
6	1	Main section
*/


CREATE TABLE "Documents" (
	document_code VARCHAR(15), 
	document_structure_code VARCHAR(15) NOT NULL, 
	document_type_code VARCHAR(15) NOT NULL, 
	access_count INTEGER, 
	document_name VARCHAR(80), 
	PRIMARY KEY (document_code), 
	FOREIGN KEY(document_structure_code) REFERENCES "Document_Structures" (document_structure_code)
)

/*
2 rows from Documents table:
document_code	document_structure_code	document_type_code	access_count	document_name
217	8	Book	1864	Learning English
621	1	Paper	8208	Research about Art history
*/


CREATE TABLE "Functional_Areas" (
	functional_area_code VARCHAR(15), 
	parent_functional_area_code VARCHAR(15), 
	functional_area_description VARCHAR(80) NOT NULL, 
	PRIMARY KEY (functional_area_code)
)

/*
2 rows from Functional_Areas table:
functional_area_code	parent_functional_area_code	functional_area_description
8	8	Signature
1	8	Acknowledgement
*/


CREATE TABLE "Images" (
	image_id INTEGER, 
	image_alt_text VARCHAR(80), 
	image_name VARCHAR(40), 
	image_url VARCHAR(255), 
	PRIMARY KEY (image_id)
)

/*
2 rows from Images table:
image_id	image_alt_text	image_name	image_url
1	Lea	top1	http://www.rempelnader.com/1.jpg
2	Arden	top2	http://connellykertzmann.org/1.jpg
*/


CREATE TABLE "Roles" (
	role_code VARCHAR(15), 
	role_description VARCHAR(80), 
	PRIMARY KEY (role_code)
)

/*
2 rows from Roles table:
role_code	role_description
DBA	Database Administrator
PROJ-MGR	Project Manager
*/


CREATE TABLE "Users" (
	user_id INTEGER, 
	role_code VARCHAR(15) NOT NULL, 
	user_name VARCHAR(40), 
	user_login VARCHAR(40), 
	password VARCHAR(40), 
	PRIMARY KEY (user_id), 
	FOREIGN KEY(role_code) REFERENCES "Roles" (role_code)
)

/*
2 rows from Users table:
user_id	role_code	user_name	user_login	password
1	PROJ-MGR	dickens.elta	0	e72b5a2d50b39a8760764a5f7a9d68ca2f076877
2	DBA	tremblay.raheem	1	9bc25a040d5647ced5ec32e1a455e90fafc10bcb
*/
What are the names of all the documents, as well as the access counts of each, ordered alphabetically?
SELECT document_name ,  access_count FROM documents ORDER BY document_name
[{'document_name': 'David CV', 'access_count': 6345}, {'document_name': 'Fall Sails', 'access_count': 7509}, {'document_name': 'How to cook pasta', 'access_count': 2045}, {'document_name': 'Humanity: a fact', 'access_count': 3479}, {'document_name': 'Joe CV', 'access_count': 2294}, {'document_name': 'John CV', 'access_count': 5924}, {'document_name': 'Learning Database', 'access_count': 3769}, {'document_name': 'Learning English', 'access_count': 1864}, {'document_name': 'Learning Japanese', 'access_count': 2910}, {'document_name': 'Life about Claude Monet', 'access_count': 1219}, {'document_name': 'Relationships between History and Arts', 'access_count': 9948}, {'document_name': 'Research about Art history', 'access_count': 8208}, {'document_name': 'Spring Sails', 'access_count': 3289}, {'document_name': 'Summer Sails', 'access_count': 6661}, {'document_name': 'Winter Sails', 'access_count': 8623}]