
CREATE TABLE "Customers" (
	customer_id INTEGER, 
	customer_name VARCHAR(80), 
	customer_details VARCHAR(255), 
	PRIMARY KEY (customer_id)
)


CREATE TABLE "Invoices" (
	invoice_number INTEGER, 
	invoice_date DATETIME, 
	invoice_details VARCHAR(255), 
	PRIMARY KEY (invoice_number)
)


CREATE TABLE "Order_Items" (
	order_item_id INTEGER, 
	product_id INTEGER NOT NULL, 
	order_id INTEGER NOT NULL, 
	order_item_status VARCHAR(10) NOT NULL, 
	order_item_details VARCHAR(255), 
	PRIMARY KEY (order_item_id), 
	FOREIGN KEY(product_id) REFERENCES "Products" (product_id), 
	FOREIGN KEY(order_id) REFERENCES "Orders" (order_id)
)


CREATE TABLE "Orders" (
	order_id INTEGER, 
	customer_id INTEGER NOT NULL, 
	order_status VARCHAR(10) NOT NULL, 
	date_order_placed DATETIME NOT NULL, 
	order_details VARCHAR(255), 
	PRIMARY KEY (order_id), 
	FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id)
)


CREATE TABLE "Products" (
	product_id INTEGER, 
	product_name VARCHAR(80), 
	product_details VARCHAR(255), 
	PRIMARY KEY (product_id)
)


CREATE TABLE "Shipment_Items" (
	shipment_id INTEGER NOT NULL, 
	order_item_id INTEGER NOT NULL, 
	FOREIGN KEY(shipment_id) REFERENCES "Shipments" (shipment_id), 
	FOREIGN KEY(order_item_id) REFERENCES "Order_Items" (order_item_id)
)


CREATE TABLE "Shipments" (
	shipment_id INTEGER, 
	order_id INTEGER NOT NULL, 
	invoice_number INTEGER NOT NULL, 
	shipment_tracking_number VARCHAR(80), 
	shipment_date DATETIME, 
	other_shipment_details VARCHAR(255), 
	PRIMARY KEY (shipment_id), 
	FOREIGN KEY(invoice_number) REFERENCES "Invoices" (invoice_number), 
	FOREIGN KEY(order_id) REFERENCES "Orders" (order_id)
)

CREATE TABLE "Customers" (
	customer_id INTEGER, 
	customer_name VARCHAR(80), 
	customer_details VARCHAR(255), 
	PRIMARY KEY (customer_id)
)

/*
2 rows from Customers table:
customer_id	customer_name	customer_details
1	Savannah	rerum
2	George	est
*/


CREATE TABLE "Invoices" (
	invoice_number INTEGER, 
	invoice_date DATETIME, 
	invoice_details VARCHAR(255), 
	PRIMARY KEY (invoice_number)
)

/*
2 rows from Invoices table:
invoice_number	invoice_date	invoice_details
1	1989-09-03 16:03:05	vitae
2	1989-12-11 16:40:57	magnam
*/


CREATE TABLE "Order_Items" (
	order_item_id INTEGER, 
	product_id INTEGER NOT NULL, 
	order_id INTEGER NOT NULL, 
	order_item_status VARCHAR(10) NOT NULL, 
	order_item_details VARCHAR(255), 
	PRIMARY KEY (order_item_id), 
	FOREIGN KEY(product_id) REFERENCES "Products" (product_id), 
	FOREIGN KEY(order_id) REFERENCES "Orders" (order_id)
)

/*
2 rows from Order_Items table:
order_item_id	product_id	order_id	order_item_status	order_item_details
1	4	6	Finish	None
2	15	6	Finish	None
*/


CREATE TABLE "Orders" (
	order_id INTEGER, 
	customer_id INTEGER NOT NULL, 
	order_status VARCHAR(10) NOT NULL, 
	date_order_placed DATETIME NOT NULL, 
	order_details VARCHAR(255), 
	PRIMARY KEY (order_id), 
	FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id)
)

/*
2 rows from Orders table:
order_id	customer_id	order_status	date_order_placed	order_details
1	2	Shipped	2009-02-21 15:26:19	None
2	11	Shipped	1974-06-24 22:10:26	None
*/


CREATE TABLE "Products" (
	product_id INTEGER, 
	product_name VARCHAR(80), 
	product_details VARCHAR(255), 
	PRIMARY KEY (product_id)
)

/*
2 rows from Products table:
product_id	product_name	product_details
1	food	None
2	book	None
*/


CREATE TABLE "Shipment_Items" (
	shipment_id INTEGER NOT NULL, 
	order_item_id INTEGER NOT NULL, 
	FOREIGN KEY(shipment_id) REFERENCES "Shipments" (shipment_id), 
	FOREIGN KEY(order_item_id) REFERENCES "Order_Items" (order_item_id)
)

/*
2 rows from Shipment_Items table:
shipment_id	order_item_id
11	12
10	15
*/


CREATE TABLE "Shipments" (
	shipment_id INTEGER, 
	order_id INTEGER NOT NULL, 
	invoice_number INTEGER NOT NULL, 
	shipment_tracking_number VARCHAR(80), 
	shipment_date DATETIME, 
	other_shipment_details VARCHAR(255), 
	PRIMARY KEY (shipment_id), 
	FOREIGN KEY(invoice_number) REFERENCES "Invoices" (invoice_number), 
	FOREIGN KEY(order_id) REFERENCES "Orders" (order_id)
)

/*
2 rows from Shipments table:
shipment_id	order_id	invoice_number	shipment_tracking_number	shipment_date	other_shipment_details
1	5	13	3452	1983-08-13 22:34:11	None
2	7	2	0114	1977-11-10 12:11:25	None
*/
Which customers made orders between 2009-01-01 and 2010-01-01? Find their names.
SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.date_order_placed >= "2009-01-01" AND T2.date_order_placed <= "2010-01-01"
[{'customer_name': 'George'}]