Skip to content

Instantly share code, notes, and snippets.

@punchouty
Created April 23, 2021 09:53
Show Gist options
  • Save punchouty/f5b6d3666151f8a2e0dec555d32674db to your computer and use it in GitHub Desktop.
Save punchouty/f5b6d3666151f8a2e0dec555d32674db to your computer and use it in GitHub Desktop.
Sample Retail POS Data

POS

Invoice Structure

  1. Entities
    1. Customer
      1. age (numeric)
      2. customer_type (platinum, gold, silver) | qualifiers (assigned_date, minimum_monthly_purchase)
      3. gender (male, female, other)
    2. Product
      1. type (fruits, vegetables, grocery, electronic) | qualifiers (is_perishable)
      2. mrp (float) | qualifiers (applied_date, percent_increase)
    3. Coupon
      1. coupon_type (invoice_level, line_item_level)
      2. validity_date
      3. discount (float)
  2. Properties
    1. transaction_time (timestamp)
    2. invoice_total (double)
    3. source_lat_long (lat & long)
  3. Context
    1. shopping_hours (morning_hours, evening_hours, noon)
    2. days_of_week (weeked, weekday)
    3. store_location (metro, city, town)
  4. Predicates
    1. product_coupon | qualifiers (discount_behaviour - {additive, ignore_other, ignore_this}, start_date, end_date, max_items - uint32)
    2. customer_product | qualifiers (favourite, item_purchased)

Quantity Dictionary

{
  "/common/quantity/age": {
    "vertical": "common",
    "type": "/common/quantity/age_in_years",
    "unit": "AGE_YEARS",
    "numeric": {
      "minimum": 0,
      "maximum": 100,
      "value_type": "uint32"
    }
  },
  "/common/quantity/count": {
    "vertical": "common",
    "type": "/common/quantity/count",
    "unit": "NA",
    "numeric": {
      "minimum": 0,
      "value_type": "uint32"
    }
  },
  "/retail/quantity/customer_type": {
    "vertical": "retail",
    "type": "/retail/quantity/customer_type",
    "unit": "NA",
    "symbolic": {
      "dictionary": {
        "key": [
          "platinum",
          "gold",
          "silver"
        ],
        "index": {
          "gold": 0,
          "platinum": 1,
          "silver": 2
        }
      }
    }
  },
  "/common/quantity/gender": {
    "vertical": "common",
    "type": "/common/quantity/gender",
    "unit": "NA",
    "symbolic": {
      "dictionary": {
        "key": [
          "male",
          "female",
          "other"
        ],
        "index": {
          "female": 0,
          "male": 1,
          "other": 2
        }
      }
    }
  },
  "/retail/quantity/product_type": {
    "vertical": "retail",
    "type": "/retail/quantity/product_type",
    "unit": "NA",
    "symbolic": {
      "dictionary": {
        "key": [
          "electronic",
          "fruit",
          "vegetable",
          "grocery",
          "clothes"
        ],
        "index": {
          "clothes": 0,
          "electronic": 1,
          "fruit": 2,
          "grocery": 3,
          "vegetable": 4
        }
      }
    }
  },
  "/common/quantity/monetary": {
    "vertical": "common",
    "type": "/common/quantity/monetary",
    "unit": "MONETARY_INR",
    "numeric": {
      "minimum": 0,
      "maximum": 100000,
      "value_type": "float"
    }
  },
  "/retail/quantity/coupon_type": {
    "vertical": "retail",
    "type": "/retail/quantity/coupon_type",
    "unit": "NA",
    "symbolic": {
      "dictionary": {
        "key": [
          "invoice_level",
          "line_item_level"
        ],
        "index": {
          "invoice_level": 0,
          "line_item_level": 1
        }
      }
    }
  },
  "/common/quantity/date": {
    "vertical": "common",
    "type": "/common/quantity/date",
    "unit": "none",
    "temporal": "timestamp"
  },
  "/common/quantity/percent": {
    "vertical": "retail",
    "type": "/common/quantity/percent",
    "unit": "%",
    "numeric": {
      "minimum": 0,
      "maximum": 100,
      "value_type": "float"
    }
  },
  "/common/quantity/boolean": {
    "vertical": "common",
    "type": "/common/quantity/boolean",
    "unit": "NA",
    "symbolic": {
      "dictionary": {
        "key": [
          "true",
          "false",
          "not_assigned"
        ],
        "index": {
          "false": 0,
          "not_assigned": 1,
          "true": 2
        }
      }
    }
  },
  "/common/quantity/time_of_day": {
    "vertical": "common",
    "type": "/common/quantity/time_of_day",
    "unit": "NA",
    "symbolic": {
      "dictionary": {
        "key": [
          "morning",
          "afternoon",
          "evening",
          "night"
        ],
        "index": {
          "afternoon": 0,
          "evening": 1,
          "morning": 2,
          "night": 3
        }
      }
    }
  },
  "/common/quantity/day_of_week": {
    "vertical": "common",
    "type": "/common/quantity/day_of_week",
    "unit": "NA",
    "symbolic": {
      "dictionary": {
        "key": [
          "weekday",
          "weekend"
        ],
        "index": {
          "weekday": 0,
          "weekend": 1
        }
      }
    }
  },
  "/common/quantity/location_type": {
    "vertical": "common",
    "type": "/common/quantity/location_type",
    "unit": "NA",
    "symbolic": {
      "dictionary": {
        "key": [
          "village",
          "town",
          "city",
          "metro"
        ],
        "index": {
          "city": 0,
          "metro": 1,
          "town": 2,
          "village": 3
        }
      }
    }
  },
  "/retail/quantity/discount_behaviour": {
    "vertical": "retail",
    "type": "/retail/quantity/discount_behaviour",
    "unit": "NA",
    "symbolic": {
      "dictionary": {
        "key": [
          "additive",
          "ignore_when_other",
          "ignore_other"
        ],
        "index": {
          "additive": 0,
          "ignore_other": 1,
          "ignore_when_other": 2
        }
      }
    }
  },
  "/common/quantity/lat_long": {
    "vertical": "common",
    "type": "/common/quantity/lat_long",
    "unit": "NA",
    "location": {
      "latitude": "double",
      "longitude": "double"
    }
  }
}

Property Dictionary

{
  "/retail/property/pos/transaction_time": "/common/quantity/date",
  "/retail/property/pos/invoice_total": "/common/quantity/monetary",
  "/retail/property/pos/source_lat_long": "/common/quantity/lat_long"
}

Context Dictionary

{
  "/retail/context/pos/shopping_hours": "/common/quantity/time_of_day",
  "/retail/context/pos/days_of_week": "/common/quantity/day_of_week",
  "/retail/context/pos/store_location": "/common/quantity/location_type"
}

Attribute Dictionary

{
  "/common/attribute/customer/age": {
    "attribute_descriptor": "/common/attribute/customer/age",
    "vertical" : "common",
    "entity_type" : "/common/entity/customer",
    "attribute_name" : "age",
    "quantity_type": "/common/quantity/age_in_years",
    "qualifier": {}
  },
  "/common/attribute/customer/customer_type": {
    "attribute_descriptor": "/common/attribute/customer/customer_type",
    "vertical" : "common",
    "entity_type" : "/common/entity/customer",
    "attribute_name" : "customer_type",
    "quantity_type": "retail/quantity/customer_type",
    "qualifier": {
      "/retail/qualifier/customer/customer_type/assigned_date": "/common/quantity/date",
      "/retail/qualifier/customer/customer_type/minimum_monthly_purchase": "/common/quantity/monetary"
    }
  },
  "/common/attribute/customer/gender": {
    "attribute_descriptor": "/common/attribute/customer/gender",
    "vertical" : "common",
    "entity_type" : "/common/entity/customer",
    "attribute_name" : "gender",
    "quantity_type": "/common/quantity/gender",
    "qualifier": {}
  },
  "/retail/attribute/product/product_type": {
    "attribute_descriptor": "/retail/attribute/product/product_type",
    "vertical" : "retail",
    "entity_type" : "/retail/entity/product",
    "attribute_name" : "product_type",
    "quantity_type": "/retail/quantity/product_type",
    "qualifier": {
      "retail/qualifier/product/product_type/is_perishable": "/common/quantity/boolean"
    }
  },
  "retail/attribute/product/mrp": {
    "attribute_descriptor": "/retail/attribute/product/mrp",
    "vertical" : "retail",
    "entity_type" : "/retail/entity/product",
    "attribute_name" : "mrp",
    "quantity_type": "/common/quantity/monetary",
    "qualifier": {
      "retail/qualifier/product/mrp/applied_date": "/common/quantity/date",
      "retail/qualifier/product/mrp/percent_increase": "/common/quantity/percent"
    }
  },
  "/retail/attribute/coupon/coupon_type": {
    "attribute_descriptor": "/retail/attribute/coupon/coupon_type",
    "vertical" : "retail",
    "entity_type" : "/retail/entity/coupon",
    "attribute_name" : "coupon_type",
    "quantity_type": "/retail/quantity/coupon_type",
    "qualifier": {}
  },
  "/retail/attribute/coupon/validity_date": {
    "attribute_descriptor": "/retail/attribute/coupon/validity_date",
    "vertical" : "retail",
    "entity_type" : "/retail/entity/coupon",
    "attribute_name" : "validity_date",
    "quantity_type": "/common/quantity/date",
    "qualifier": {}
  },
  "/retail/attribute/coupon/discount": {
    "attribute_descriptor": "/retail/attribute/coupon/discount",
    "vertical" : "retail",
    "entity_type" : "/retail/entity/coupon",
    "attribute_name" : "discount",
    "quantity_type": "/common/quantity/percent",
    "qualifier": {}
  }
}

Predicate Dictionary

{
  "/retail/predicate/product/apply/coupon": {
    "predicate_descriptor": "/retail/predicate/product/apply/coupon",
    "vertical": "retail",
    "subject_type": "/retail/entity/product",
    "object_type": "/retail/entity/coupon",
    "predicate_name": "apply",
    "qualifier": {
      "/retail/qualifier/predicate/product/apply/coupon/discount_behaviour": "/retail/quantity/discount_behaviour",
      "/retail/qualifier/predicate/product/apply/coupon/start_date": "common/quantity/date",
      "/retail/qualifier/predicate/product/apply/coupon/end_date": "common/quantity/date",
      "/retail/qualifier/predicate/product/apply/coupon/max_items": "common/quantity/count"
    }
  },
  "/retail/predicate/customer/favourite/product": {
    "predicate_descriptor": "/retail/predicate/customer/favourite/product",
    "vertical": "retail",
    "subject_type": "/common/entity/customer",
    "object_type": "/retail/entity/product",
    "predicate_name": "favourite",
    "qualifier": {
      "/retail/qualifier/predicate/customer/favourite/product/is_favourite": "/common/quantity/boolean",
      "/retail/qualifier/predicate/customer/favourite/product/items_purchased": "common/quantity/count"
    }
  }
}

Entity Dictionary

{
  "/common/entity/customer" : {
    "entity_descriptor" : "/common/entity/customer",
    "vertical" : "common",
    "attribute_descriptor" : [
      "/common/attribute/customer/age",
      "/common/attribute/customer/customer_type",
      "/common/attribute/customer/gender"
    ]
  },
  "/retail/entity/product" : {
    "entity_descriptor" : "/retail/entity/product",
    "vertical" : "retail",
    "attribute_descriptor" : [
      "/retail/attribute/product/product_type",
      "retail/attribute/product/mrp"
    ]
  },
  "/retail/entity/coupon" : {
    "entity_descriptor" : "/retail/entity/coupon",
    "vertical" : "retail",
    "attribute_descriptor" : [
      "/retail/attribute/coupon/coupon_type",
      "/retail/attribute/coupon/validity_date",
      "/retail/attribute/coupon/discount"
    ]
  }
}

Event Dictionary

{
  "/retail/event/pos" : {
    "entity_descriptor" : "/retail/event/pos",
    "vertical" : "retail",
    "key_schema" : {},
    "value_schema" : {
      "entity_descriptor" : [
        "/common/entity/customer",
        "/retail/entity/product",
        "/retail/entity/coupon"
      ],
      "property_descriptor" : [
        "/retail/property/pos/transaction_time",
        "/retail/property/pos/invoice_total",
        "/retail/property/pos/source_lat_long"
      ],
      "context_descriptor" : [
        "/retail/context/pos/shopping_hours",
        "/retail/context/pos/days_of_week",
        "/retail/context/pos/store_location"
      ],
      "predicate_descriptor" : [
        "/retail/predicate/product/apply/coupon",
        "/retail/predicate/customer/favourite/product"
      ]
    }
  },
  "/retail/event/item_return" : {
    "event_type" : "/retail/event/item_return",
    "vertical" : "retail",
    "key_schema" : {},
    "value_schema" : {}
  }
}

Event Store

{
  "event-id" : "event-01",
  "event_key" : {},
  "event_value" : {
    "entity_index" : {
      "0-/retail/entity/coupon" : {
        "key" : ["coupon-01", "coupon-02"],
        "index" : {
          "0" : "coupon-01",
          "1": "coupon-02"
        }
      },
      "1-/common/entity/customer" : {
        "key" : ["customer-01"],
        "index" : {
          "0" : "customer-01"
        }
      },
      "2-/retail/entity/product" : {
        "key" : ["product-01", "product-02", "product-03"],
        "index" : {
          "0" : "product-01",
          "1": "product-02",
          "2": "product-03"
        }
      }
    },
    "attribute" : {
      "0-/retail/entity/coupon" : {
        "0-coupon-01" : {
          "attribute" : {
            "0-/retail/attribute/coupon/coupon_type" : 0,
            "1-/retail/attribute/coupon/discount" : 10,
            "2-/retail/attribute/coupon/validity_date" : "31-12-2021"
          },
          "qualifier" : {}
        },
        "1-coupon-02" : {
          "attribute" : {
            "0-/retail/attribute/coupon/coupon_type" : 0,
            "1-/retail/attribute/coupon/discount" : 12,
            "2-/retail/attribute/coupon/validity_date" : "31-08-2021"
          },
          "qualifier" : {}
        }
      },
      "1-/common/entity/customer" : {
        "0-customer-01" : {
          "attribute" : {
            "0-/common/attribute/customer/age" : 30,
            "1-/common/attribute/customer/customer_type" : 0,
            "2-/common/attribute/customer/gender" : 1
          },
          "qualifier" : {}
        }
      },
      "2-/retail/entity/product" : {
        "0-product-01" : {
          "attribute" : {
            "0-retail/attribute/product/mrp" : 1000,
            "1-/retail/attribute/product/product_type" : 0
          },
          "qualifier" : {
            "0-retail/attribute/product/mrp" : {
              "0-retail/qualifier/product/mrp/applied_date" : "01-12-2020",
              "1-retail/qualifier/product/mrp/percent_increase" : 5
            },
            "1-/retail/attribute/product/product_type" : {
              "1-retail/qualifier/product/product_type/is_perishable": 2
            }
          }
        },
        "1-product-01" : {
          "attribute" : {
            "0-retail/attribute/product/mrp" : 500,
            "1-/retail/attribute/product/product_type" : 1
          },
          "qualifier" : {
            "0-retail/attribute/product/mrp" : {
              "0-retail/qualifier/product/mrp/applied_date" : "01-01-2021",
              "1-retail/qualifier/product/mrp/percent_increase" : 10
            },
            "1-/retail/attribute/product/product_type" : {
              "1-retail/qualifier/product/product_type/is_perishable": 1
            }
          }
        },
        "2-product-01" : {
          "attribute" : {
            "0-retail/attribute/product/mrp" : 700,
            "1-/retail/attribute/product/product_type" : 2
          },
          "qualifier" : {
            "0-retail/attribute/product/mrp" : {
              "0-retail/qualifier/product/mrp/applied_date" : null,
              "1-retail/qualifier/product/mrp/percent_increase" : null
            },
            "1-/retail/attribute/product/product_type" : {
              "1-retail/qualifier/product/product_type/is_perishable": null
            }
          }
        }
      }
    },
    "property" : {
      "0-/retail/property/pos/invoice_total": 1450,
      "1-/retail/property/pos/transaction_time": "2021-04-22 10:30:32",
      "2-/retail/property/pos/source_lat_long" : "as8d0j"
    },
    "context" : {
      "0-/retail/context/pos/days_of_week": 0,
      "1-/retail/context/pos/shopping_hours": 2,
      "2-/retail/context/pos/store_location": 1
    },
    "predicate" : {
      "0-/retail/predicate/product/apply/coupon" : {
        "0-/retail/qualifier/predicate/product/apply/coupon/discount_behaviour" : 1,
        "1-/retail/qualifier/predicate/product/apply/coupon/end_date" : null,
        "2-/retail/qualifier/predicate/product/apply/coupon/max_items" : 2,
        "3-/retail/qualifier/predicate/product/apply/coupon/start_date" : "15-01-2021"
      },
      "1-/retail/predicate/customer/favourite/product" : {
        "0-/retail/qualifier/predicate/customer/favourite/product/is_favourite" : false,
        "1- /retail/qualifier/predicate/customer/favourite/product/items_purchased": 5
      }
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment