-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoffeedb.sql
More file actions
59 lines (54 loc) · 1.16 KB
/
coffeedb.sql
File metadata and controls
59 lines (54 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
* SQLite CREATE TABLE examples.
* Created by Alvin Alexander, http://alvinalexander.com
* Released under the Creative Commons License.
*/
--
-- coffees
--
CREATE TABLE coffees (
id INTEGER PRIMARY KEY,
coffee_name TEXT NOT NULL,
price REAL NOT NULL
);
--
-- salespeople
--
CREATE TABLE salespeople (
id INTEGER PRIMARY KEY,
first_name TEXT NOT NULL,
last_name TEXT NOT NULL,
commission_rate REAL NOT NULL
);
--
-- customers
--
CREATE TABLE customers (
id INTEGER PRIMARY KEY,
company_name TEXT NOT NULL,
street_address TEXT NOT NULL,
city TEXT NOT NULL,
state TEXT NOT NULL,
zip TEXT NOT NULL
);
--
-- orders
--
CREATE TABLE orders (
id INTEGER PRIMARY KEY,
customer_id INTEGER,
salesperson_id INTEGER,
FOREIGN KEY(customer_id) REFERENCES customers(id),
FOREIGN KEY(salesperson_id) REFERENCES salespeople(id)
);
/*
* order_items (multiline comment example)
*/
CREATE TABLE order_items (
id INTEGER PRIMARY KEY,
order_id INTEGER,
product_id INTEGER,
product_quantity INTEGER,
FOREIGN KEY(order_id) REFERENCES orders(id),
FOREIGN KEY(product_id) REFERENCES products(id)
);