-
Notifications
You must be signed in to change notification settings - Fork 0
/
northwind.sql
198 lines (167 loc) · 3.95 KB
/
northwind.sql
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
-- Create the northwind database
CREATE DATABASE northwind;
-- CockroachDB only
USE northwind;
--
-- Name: customer_customer_demo;
--
CREATE TABLE customer_customer_demo (
customer_id character varying(5) NOT NULL,
customer_type_id character varying(5) NOT NULL
);
--
-- Name: customer_demographics;
--
CREATE TABLE customer_demographics (
customer_type_id character varying(5) NOT NULL,
customer_desc text
);
--
-- Name: customers;
--
CREATE TABLE IF NOT EXISTS customers (
customer_id character varying(5) NOT NULL,
company_name character varying(40) NOT NULL,
contact_name character varying(30),
contact_title character varying(30),
address character varying(60),
city character varying(15),
region character varying(15),
postal_code character varying(10),
country character varying(15),
phone character varying(24),
fax character varying(24)
);
--
-- Name: employees;
--
CREATE TABLE IF NOT EXISTS employees (
employee_id smallint NOT NULL,
last_name character varying(20) NOT NULL,
first_name character varying(10) NOT NULL,
title character varying(30),
title_of_courtesy character varying(25),
birth_date date,
hire_date date,
address character varying(60),
city character varying(15),
region character varying(15),
postal_code character varying(10),
country character varying(15),
home_phone character varying(24),
extension character varying(4),
photo bytea,
notes text,
reports_to smallint,
photo_path character varying(255)
);
--
-- Name: employee_territories;
--
CREATE TABLE IF NOT EXISTS employee_territories (
employee_id smallint NOT NULL,
territory_id character varying(20) NOT NULL
);
--
-- Name: order_details;
--
CREATE TABLE IF NOT EXISTS order_details (
order_id smallint NOT NULL,
product_id smallint NOT NULL,
unit_price real NOT NULL,
quantity smallint NOT NULL,
discount real NOT NULL
);
--
-- Name: orders;
--
CREATE TABLE IF NOT EXISTS orders (
order_id smallint NOT NULL,
customer_id character varying(5),
employee_id smallint,
order_date date,
required_date date,
shipped_date date,
ship_via smallint,
freight real,
ship_name character varying(40),
ship_address character varying(60),
ship_city character varying(15),
ship_region character varying(15),
ship_postal_code character varying(10),
ship_country character varying(15)
);
--
-- Name: products;
--
CREATE TABLE IF NOT EXISTS products (
product_id smallint NOT NULL,
product_name character varying(40) NOT NULL,
supplier_id smallint,
category_id smallint,
quantity_per_unit character varying(20),
unit_price real,
units_in_stock smallint,
units_on_order smallint,
reorder_level smallint,
discontinued integer NOT NULL
);
--
-- Name: region;
--
CREATE TABLE IF NOT EXISTS region (
region_id smallint NOT NULL,
region_description character varying(60) NOT NULL
);
--
-- Name: shippers;
--
CREATE TABLE IF NOT EXISTS shippers (
shipper_id smallint NOT NULL,
company_name character varying(40) NOT NULL,
phone character varying(24)
);
--
-- Name: suppliers;
--
CREATE TABLE IF NOT EXISTS suppliers (
supplier_id smallint NOT NULL,
company_name character varying(40) NOT NULL,
contact_name character varying(30),
contact_title character varying(30),
address character varying(60),
city character varying(15),
region character varying(15),
postal_code character varying(10),
country character varying(15),
phone character varying(24),
fax character varying(24),
homepage text
);
--
-- Name: territories;
--
CREATE TABLE IF NOT EXISTS territories (
territory_id character varying(20) NOT NULL,
territory_description character varying(60) NOT NULL,
region_id smallint NOT NULL
);
--
-- Name: us_states;
--
CREATE TABLE IF NOT EXISTS us_states (
state_id smallint NOT NULL,
state_name character varying(100),
state_abbr character varying(2),
state_region character varying(50)
);
--
-- Name: transactions;
--
CREATE TABLE IF NOT EXISTS transactions (
lane VARCHAR,
id UUID,
event INT,
ts TIMESTAMP,
PRIMARY KEY (lane, id, event)
);