-- 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");