NOTES:

1. cascade-on-delete denoted by [D]
   restrict-on-delete denoted by [!!] (i.e., stops delete)

##########################################
certnames:
  name
  deactiviated

Examples: (puppetdb.stanford.edu, null)

##########################################
environments:
  id
  name

Examples: (1, production), (3, idg_master3)

##########################################
catalogs:
  id
  certname UNIQUE:  references certnames.name  [DEL]
  environment_id:   references environments.id [DEL]

##########################################
Every fact type has an entry here (note: no _values_, just the fact name and type).

fact_paths:
  id
  value_type_id: the type of the fact
                 (e.g., string, number, json, etc.) [!!]
  name: the name of the fact

Examples: (4, 0, fqdn) (0 stands for the type 'string')
(16, 0, kernelmajversion)

#########################################
Each fact on each machine has an entry in the fact_values table.

fact_values
  id
  path_id: references fact_paths.id (points to the kind of fact this fact
                      value is)
  value_type_id: the type of the fact (e.g., string, number, json, etc.) [!!]
  value_hash
  value_integer
  value_float
  value_string
  value_boolean
  value_json

The tuple (path_id, and one of the value_* fields) defines the fact type and value.

#########################################
Each client has a single associated factset in the factsets table.

factsets:
  id
  certname UNIQUE:  references certnames.name
  environment_id:   references environments.id [!!]

Note: the factsets table prevents the deletion of any environment if there
are any clients on that environment still in the factsets table.

#########################################
To get all the facts for a given machine, the facts table is a join table
that links the factsets table and the fact_values table.

facts:
  factset_id      [DEL]
  fact_value_id

#########################################
reports:
  hash: PRIMARY KEY
  certname:         references certnames.name
  environment_id:   references environments.id [DEL]

Note that each node can have multiple entries in this table.

#########################################
tangled:
  pid: primary key
  node: nodename (should have been called certname)
  timestamp

#########################################
logcache:
  pid
  node:  nodename (should have been called certname)
  timestamp
  logline

