Enum "orders_status" {
  "created"
  "running"
  "done"
  "failure"
}

Enum "product status" {
  "Out of Stock"
  "In Stock"
}

Table "orders" {
  "id" SERIAL [pk, increment]
  "user_id" int [unique, not null]
  "status" orders_status
  "created_at" varchar
}

Table "order_items" {
  "order_id" int
  "product_id" int
  "quantity" int [default: 1]
}

Table "products" {
  "id" int [pk]
  "name" varchar
  "merchant_id" int [not null]
  "price" int
  "status" "product status"
  "created_at" datetime [default: `now()`]

  Indexes {
    (merchant_id, status) [name: "product_status"]
    id [type: hash, unique]
  }
}

Table "users" {
  "id" int [pk]
  "full_name" varchar
  "email" varchar [unique]
  "gender" varchar
  "date_of_birth" varchar
  "created_at" varchar
  "country_code" int
}

Table "merchants" {
  "id" int [pk]
  "merchant_name" varchar
  "country_code" int
  "created_at" varchar
  "admin_id" int
}

Table "countries" {
  "code" int [pk]
  "name" varchar
  "continent_name" varchar
}

Table "comment_on_product" {
  "comment_id" int
  "product_family" int
  "delete" boolean
  "comment_value" varchar

  Indexes {
    (comment_id, product_family) [pk, name: "comment_on_product_pk"]
    (delete, comment_id, product_family) [unique, name: "comment_on_product_idx_unique"]
  }
}

Ref:"orders"."id" < "order_items"."order_id"

Ref:"products"."id" < "order_items"."product_id"

Ref:"countries"."code" < "users"."country_code"

Ref:"countries"."code" < "merchants"."country_code"

Ref:"merchants"."id" < "products"."merchant_id"

Ref:"users"."id" < "merchants"."admin_id"

