-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
35 lines (31 loc) · 1.21 KB
/
Copy pathschema.sql
File metadata and controls
35 lines (31 loc) · 1.21 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
-- Analytics schema for the SQL case study.
-- Engine: DuckDB. Generated deterministically by generate_data.py (seed=42).
CREATE TABLE users (
user_id INTEGER PRIMARY KEY,
signup_date DATE,
channel VARCHAR, -- organic | paid_search | social | referral | email
country VARCHAR, -- RU | UA | KZ | BY | Other
device VARCHAR, -- ios | android | web
ab_variant VARCHAR -- control | treatment (A/B assignment, see case 09)
);
CREATE TABLE events (
event_id INTEGER PRIMARY KEY,
user_id INTEGER REFERENCES users(user_id),
session_id INTEGER,
event_time TIMESTAMP,
event_name VARCHAR -- app_open | view_item | add_to_cart | checkout | purchase
);
CREATE TABLE orders (
order_id INTEGER PRIMARY KEY,
user_id INTEGER REFERENCES users(user_id),
order_ts TIMESTAMP,
amount DOUBLE,
product_category VARCHAR -- electronics | clothing | home | books | beauty | sports
);
CREATE TABLE subscriptions (
sub_id INTEGER PRIMARY KEY,
user_id INTEGER REFERENCES users(user_id),
started_at TIMESTAMP,
plan VARCHAR, -- monthly | annual
amount DOUBLE
);