Skip to content

OPQ Data Architecture

anthonyjchriste edited this page Nov 18, 2015 · 9 revisions

This is a working document which explains our data architecture between OPQView and OPQHub.

Data from our backend (OPQHub) is generally going to be noisy and non-intuitive for the average user. The backend is responsible for creating digestible data products for the front end to consume. The following is a list of data objects and roles we see playing a part in our data design between these two components.

OPQView DB Model

Enumerations

box_event_type

Type Reference
FREQUENCY IEC 61000-4-30 p. 21 s. 5.1
VOLTAGE_DIP IEC 61000-4-30 p. 24 s. 5.4.2
VOLTAGE_SWELL IEC 61000-4-30 p. 25 s. 5.4.3
VOLTAGE_INTERRUPTION IEC 61000-4-30 p. 26 s. 5.5
VOLTAGE_TRANSIENT IEC 61000-4-30 p. 44 s. A.4
VOLTAGE_HARMONICS IEC 61000-4-30 p. 29 s. 5.8
VOLTAGE_INTERHARMONICS IEC 61000-4-30 p. 30 s. 5.8.3
RAPID_VOLTAGE_CHANGE IEC 61000-4-30 p. 31 s. 5.11
MAINS_SIGNALLING IEC 61000-4-30 p. 31 s. 5.10
CURRENT_MAGNITUDE IEC 61000-4-30 p. 35 s. 5.13.2
CURRENT_HARMONICS IEC 61000-4-30 p. 36 s. 5.13.4
CURRENT_INTERHARMONICS IEC 61000-4-30 p. 36 s. 5.13.5

grid_event_type

  • DEFAULT

access_modifier

  • PUBLIC
  • SUBSCRIBE
  • ACADEMIC

subscription_request_status

  • PENDING
  • APPROVED
  • DENIED

subscription_request_type

  • BOX
  • GROUP

Access Modifiers

access_modifers are used to control access to data. Three of our collections use access modifiers, box, box_event, and group. Each box_event inherits the access_modifiers of its box.

These collections take an array of access modifiers. The possible combinations are described below.

Access Modifiers
[] (empty list) All data and groups are private to owners of the device only.
[ACADEMIC] Same as [], but allows certain anonymous data to be used for academic purposes.
[SUBSCRIBE] Same as [], but allows other users to request permission to subscribe to a device or group.
[SUBSCRIBE, ACADEMIC] Same as [SUBSCRIBE], but allows certin anonymous data to be used for academic purposes.
[PUBLIC] Anyone can subscribe to public groups or boxes. Public data is automatically used for academic purposes.

Collections

box

  • _id: oid
  • device_id: int
  • secret_key: string
  • access_modifiers: list(access_modifier)
  • created_on: date
  • last_seen: date
  • box_events: list(box_event.oid)
  • grid_events: list(grid_event.oid)
  • messages: list(box_message.oid)
  • owners: list(opq_user.oid)
  • subscribers: list(opq_user.oid)
  • groups: list(group.oid)
  • subscription_requests: list(subscription_request.oid)

box_message

  • _id: oid
  • box: box.oid
  • message: string
  • timestamp: date
  • active: boolean

box_event

  • _id: oid
  • timestamp: date
  • duration: int (seconds)
  • event_type: box_event_type
  • value: float
  • data: list(float)
  • access_modifiers: list(access_modifier)

grid_event

  • _id: oid
  • timestamp: date
  • grid_event_type: grid_event_type
  • duration: int (seconds)
  • boxes: list(box.oid)
  • box_events: list(box_event.oid)
  • updated_on: date

opq_user

  • _id: oid
  • email: string
  • created_on: date
  • updated_on: date
  • owned_boxes: list(box.oid)
  • subscribed_boxes: list(box.oid)
  • owned_groups: list(group.oid)
  • subscribed_groups: list(group.oid)
  • subscription_requests: lists(subscription_request.oid)
  • messages: list(box_message.oid)

group

  • _id: oid
  • access_modifiers: list(access_modifier)
  • group_name: string
  • boxes: list(box.oid)
  • groups: list(group.oid)
  • owners: list(opq_user.oid)
  • subscribers: list(opq_user.oid)
  • created_on: date
  • updated_on: date

subscription_request

  • _id: oid
  • requestee: opq_user.oid
  • request_type: request_type
  • resource: opq_box.oid | group.oid
  • status: subscription_request_status
  • created_on: date
  • updated_on: date