Datasets:
File size: 1,946 Bytes
7e5adcc | 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 | -- Generated by Misata Studio engine 0.1.0. Dialect: clickhouse.
-- ClickHouse declares no foreign keys: each table's relationships are listed above it, and every one holds in the rows.
CREATE TABLE "stores" (
"store_id" UInt32,
"store_name" LowCardinality(String),
"channel" LowCardinality(String),
"country" LowCardinality(String),
"region" LowCardinality(String),
"city" LowCardinality(String)
) ENGINE = MergeTree ORDER BY ("store_id");
CREATE TABLE "products" (
"product_id" UInt32,
"subcategory" String,
"category" String,
"product_name" LowCardinality(String),
"brand" String,
"list_price" Float64,
"unit_cost" Float64
) ENGINE = MergeTree ORDER BY ("product_id");
CREATE TABLE "customers" (
"customer_id" UInt32,
"customer_name" String,
"segment" LowCardinality(Nullable(String)),
"country" String,
"region" String,
"city" String,
"signup_date" Date
) ENGINE = MergeTree ORDER BY ("customer_id");
-- orders.customer_id -> customers.customer_id
-- orders.store_id -> stores.store_id
CREATE TABLE "orders" (
"order_id" UInt32,
"order_date" Date,
"customer_id" Nullable(UInt32),
"store_id" UInt32
) ENGINE = MergeTree ORDER BY ("order_id");
-- order_lines.order_id -> orders.order_id
-- order_lines.product_id -> products.product_id
CREATE TABLE "order_lines" (
"order_line_id" UInt32,
"order_id" UInt32,
"order_date" DateTime64(3, 'UTC'),
"customer_id" Nullable(UInt32),
"store_id" UInt8,
"product_id" UInt32,
"quantity" UInt8,
"unit_price" Decimal(9, 2),
"unit_cost" Float64,
"discount_pct" Float64,
"net_amount" Float64,
"cost_amount" Float64
) ENGINE = MergeTree ORDER BY ("order_line_id");
-- returns.order_line_id -> order_lines.order_line_id
CREATE TABLE "returns" (
"return_id" UInt32,
"order_line_id" UInt32,
"return_date" Date,
"returned_qty" UInt8,
"reason" LowCardinality(String)
) ENGINE = MergeTree ORDER BY ("return_date", "return_id");
|