Example_Schema_for_database_Structure

Example Schema for db(database) Structure

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "A Schema to define the JSON object which holds an edge devices database",
  "definitions": {
    "numberDelete": {
      "minItems": 0,
      "maxItems": 5000,
      "uniqueItems": true
    },
    "numberUpdate": {
      "minItems": 0,
      "maxItems": 5000,
      "uniqueItems": true
    },
    "numberAdd": {
      "minItems": 0,
      "maxItems": 5000,
      "uniqueItems": true
    },
    "dbDwnLdTm": {
      "description": "YYYYMMDDHHMMSS – Exclusions - SC",
      "type": "string",
      "minLength": 14,
      "maxLength": 14,
      "additionalProperties": false
    },
    "nxtDbVerTS": {
      "description": "Hexadecimal value, that starts with 0x, followed by 16 hex digits. (i.e. “0x08d16357eef73a69” )",
      "type": "string",
      "pattern": "^0x{1}(...)([0-9]|[A-F]){13}$",
      "additionalProperties": false
    },
    "deleteAll": {
      "description": "1 = Delete entire existing database; 0 = Do not delete entire existing database",
      "type": "integer",
      "minimum": 0,
      "maximum": 1,
      "exclusiveMinimum": false,
      "exclusiveMaximum": false,
      "additionalProperties": false
    },
    "usrID": {
      "description": "1-1,048,575 record number identifier ",
      "type": "integer",
      "minimum": 1,
      "maximum": 1048575,
      "exclusiveMinimum": false,
      "exclusiveMaximum": false,
      "additionalProperties": false
    },
    "adaEn": {
      "description": "0 = ADA Disabled; 1 = ADA Enabled",
      "type": "integer",
      "minimum": 0,
      "maximum": 1,
      "exclusiveMinimum": false,
      "exclusiveMaximum": false,
      "additionalProperties": false
    },
    "fnctn": {
      "description": "This is for NDE only. Exclusion - RMRU",
      "type": "string",
      "pattern": "(^norm$)|(^freeze$)|(^toggle$)|(^passThru$)|(^lockDown$)|(^oneTm$)|(^delAlrm$)|(^updtFrmSvr$)|(^updtFrmSvrNrm$)|
      (^blocked$)",
      "additionalProperties": false
    },
    "crSch": {
      "description": "1 through N, where N is the maximum number of credential schedules the device allows. At a minimum, a user 
       record will have a credential schedule of “[1]”, which means the credential will have 24-7 access.",
      "type": "array",
      "minItems": 1,
      "maxItems": 16,
      "uniqueItems": true,
      "items": {
        "type": "integer",
        "multipleOf": 1,
        "minimum": 1,
        "maximum": 16,
        "exclusiveMaximum": false,
        "exclusiveMinimum": false
      },
      "additionalProperties": false
    },
    "actDtTm": {
      "description": "YYYYMMDDHHMMSS – Exclusion - RMRU",
      "type": "string",
      "minLength": 14,
      "maxLength": 14,
      "additionalProperties": false
    },
    "expDtTm": {
      "description": "YYYYMMDDHHMMSS - Exclusion - RMRU",
      "type": "string",
      "minLength": 14,
      "maxLength": 14,
      "additionalProperties": false
    },
    "primeCr": {
      "description": "The primary credential data in hexadecimal format. Exclusions - RMRU.",
      "type": "string",
      "pattern": "^([0-9]|[A-F]|[a-f]){1,32}$",
      "additionalProperties": false
    },
    "prCrTyp": {
      "description": "The primary credential type (card, pin, biomtrc)",
      "type": "string",
      "pattern": "(^card$)|(^pin$)|(^biomtrc$)",
      "additionalProperties": false
    },
    "scndCr": {
      "description": "The secondary credential data in hexadecimal format. Exclusions - RMRU, SC.",
      "type": "string",
      "pattern": "^([0-9]|[A-F]|[a-f]){0,32}$",
      "additionalProperties": false
    },
    "scndCrTyp": {
      "description": "The secondary credential type (card, pin, biomtrc).",
      "type": "string",
      "pattern": "(^card$)|(^pin$)|(^biomtrc$)",
      "additionalProperties": false
    },
    "days": {
      "description": "The day(s) of the week for the schedule to be active",
      "type": "array",
      "minItems": 1,
      "maxItems": 7,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "enum": [
          "Su",
          "Mo",
          "Tu",
          "We",
          "Th",
          "Fr",
          "Sa"
        ]
      },
      "additionalProperties": false
    },
    "strtHr": {
      "description": "Start Hour, where a start hour (Hr) can be 0-23. Exclusions - RMRU, SC.",
      "type": "integer",
      "minimum": 0,
      "maximum": 23,
      "exclusiveMinimum": false,
      "exclusiveMaximum": false,
      "additionalProperties": false
    },
    "strtMn": {
      "description": "Start Minute, where minute can be 0-59. Exclusions - RMRU, SC.",
      "type": "integer",
      "minimum": 0,
      "maximum": 59,
      "exclusiveMinimum": false,
      "exclusiveMaximum": false,
      "additionalProperties": false
    },
    "lngth": {
      "description": "Duration of the schedule in minutes (decimal) (1 – 1439 ). Exclusions - RMRU.",
      "type": "integer",
      "minimum": 1,
      "maximum": 1439,
      "exclusiveMinimum": false,
      "exclusiveMaximum": false,
      "additionalProperties": false
    },
    "strtDtTm": {
      "description": "YYYYMMDDHHMMSS – Exclusions - SC.",
      "type": "string",
      "minLength": 14,
      "maxLength": 14,
      "additionalProperties": false
    },
    "endDtTm": {
      "description": "YYYYMMDDHHMMSS – Exclusions - SC.",
      "type": "string",
      "minLength": 14,
      "maxLength": 14,
      "additionalProperties": false
    },
    "actionHolidays": {
      "description": "The action for Holidays. Exclusions - SC.",
      "type": "string",
      "pattern": "(^pass$)|(^sec$)|(^rstrctSec$)",
      "additionalProperties": false
    },
    "actionAutoUnlock": {
      "description": "The action for Auto Unlock. Exclusions - SC.",
      "type": "string",
      "pattern": "(^pass$)|(^sec$)",
      "additionalProperties": false
    }
  },
  "type": "object",
  "properties": {
    "db": {
      "description": "The Database tag; This should always contain usrRcrd, schedules.",
      "type": "object",
      "required": [
        "usrRcrd",
        "schedules"
      ],
      "properties": {
        "usrRcrd": {
          "type": "object",
          "required": [
            "deleteAll",
            "delete",
            "update",
            "add"
          ],
          "propertyOrder": [
            "deleteAll",
            "delete",
            "update",
            "add"
          ],
          "properties": {
            "deleteAll": {
              "$ref": "#/definitions/deleteAll"
            },
            "delete": {
              "type": "array",
              "$ref": "#/definitions/numberDelete",
              "items": {
                "type": "object",
                "dependencies": {
                  "primeCr": [
                    "prCrTyp"
                  ],
                  "prCrTyp": [
                    "primeCr"
                  ]
                },
                "properties": {
                  "primeCr": {
                    "$ref": "#/definitions/primeCr"
                  },
                  "prCrTyp": {
                    "$ref": "#/definitions/prCrTyp"
                  },
                  "scndCr": {
                    "$ref": "#/definitions/scndCr"
                  },
                  "scndCrTyp": {
                    "$ref": "#/definitions/scndCrTyp"
                  }
                }
              }
            },
            "update": {
              "type": "array",
              "$ref": "#/definitions/numberUpdate",
              "items": {
                "type": "object",
                "properties": {
                  "usrID": {
                    "$ref": "#/definitions/usrID"
                  },
                  "adaEn": {
                    "$ref": "#/definitions/adaEn"
                  },
                  "fnctn": {
                    "$ref": "#/definitions/fnctn"
                  },
                  "crSch": {
                    "$ref": "#/definitions/crSch"
                  },
                  "actDtTm": {
                    "$ref": "#/definitions/actDtTm"
                  },
                  "expDtTm": {
                    "$ref": "#/definitions/expDtTm"
                  },
                  "primeCr": {
                    "$ref": "#/definitions/primeCr"
                  },
                  "prCrTyp": {
                    "$ref": "#/definitions/prCrTyp"
                  },
                  "scndCr": {
                    "$ref": "#/definitions/scndCr"
                  },
                  "scndCrTyp": {
                    "$ref": "#/definitions/scndCrTyp"
                  }
                }
              }
            },
            "add": {
              "type": "array",
              "$ref": "#/definitions/numberAdd",
              "items": {
                "type": "object",
                "dependencies": {
                  "primeCr": [
                    "prCrTyp"
                  ],
                  "prCrTyp": [
                    "primeCr"
                  ]
                },
                "required": [
                  "usrID",
                  "adaEn",
                  "fnctn",
                  "crSch",
                  "actDtTm",
                  "expDtTm",
                  "primeCr",
                  "prCrTyp"
                ],
                "properties": {
                  "usrID": {
                    "$ref": "#/definitions/usrID"
                  },
                  "adaEn": {
                    "$ref": "#/definitions/adaEn"
                  },
                  "fnctn": {
                    "$ref": "#/definitions/fnctn"
                  },
                  "crSch": {
                    "$ref": "#/definitions/crSch"
                  },
                  "actDtTm": {
                    "$ref": "#/definitions/actDtTm"
                  },
                  "expDtTm": {
                    "$ref": "#/definitions/expDtTm"
                  },
                  "primeCr": {
                    "$ref": "#/definitions/primeCr"
                  },
                  "prCrTyp": {
                    "$ref": "#/definitions/prCrTyp"
                  },
                  "scndCr": {
                    "$ref": "#/definitions/scndCr"
                  },
                  "scndCrTyp": {
                    "$ref": "#/definitions/scndCrTyp"
                  }
                }
              }
            }
          },
          "schedules": {
            "type": "array",
            "required": [
              "days",
              "strtHr",
              "strtMn",
              "lngth"
            ],
            "properties": {
              "days": {
                "$ref": "#/definitions/days"
              },
              "strtHr": {
                "$ref": "#/definitions/strtHr"
              },
              "strtMn": {
                "$ref": "#/definitions/strtMn"
              },
              "lngth": {
                "$ref": "#/definitions/lngth"
              }
            }
          },
          "holidays": {
            "type": "array",
            "required": [
              "strtDtTm",
              "endDtTm",
              "action"
            ],
            "properties": {
              "strtDtTm": {
                "$ref": "#/definitions/strtDtTm"
              },
              "endDtTm": {
                "$ref": "#/definitions/endDtTm"
              },
              "action": {
                "$ref": "#/definitions/actionHolidays"
              }
            }
          },
          "autoUnlock": {
            "type": "array",
            "required": [
              "action",
              "strtHr",
              "strtMn",
              "days"
            ],
            "properties": {
              "action": {
                "$ref": "#/definitions/actionAutoUnlock"
              },
              "strtHr": {
                "$ref": "#/definitions/strtHr"
              },
              "strtMn": {
                "$ref": "#/definitions/strtMn"
              },
              "days": {
                "$ref": "#/definitions/days"
              }
            }
          }
        }
      }
    }
  },
  "dbDwnLdTm": {
    "$ref": "#/definitions/dbDwnLdTm"
  },
  "nxtDbVerTS": {
    "$ref": "#/definitions/nxtDbVerTS"
  }
}