Skip to content

Open Election Data Models

Dan Melton edited this page Jun 12, 2019 · 23 revisions

All tables

Required fields are the minimum number of fields required to create the record in the database. The application may require additional fields.

Fields denoted with an asterisk * are indexed.

required fields:

id* - UID - secure unique identifier - created in postgres. Do not use integer types.
createdAt - datetime stamp in UTC for record created
updatedAt - datetime stamp in UTC for last update. - Indexed
deletedAt - datetime stamp in UTC for deletion

Government

Governments are entities that match donations, administer donation programs and possibly run elections.

Table Name: Governments

Required fields:

slug* - varchar(24) - unique indexed - the subdomain and humanreadable name 
for the government (i.e. portland, seattle). must be alphanumeric. 
will be used for folders & naming items in the system
name - varchar(255) - the display name of the government program

Not Required


website - varchar(255) - the government's main website for the matching program
domain - varchar(255) - the fully qualified domain name for the program (https://www.portlandopenelections.org)

User

Users have access to the system, are linked to permissions and can add/edit/read data.

Table name: Users

Required Fields:

email* - varchar(255) - required - the email of the user
salt - varchar(255) - required - the application generated salt for the password
passwordHash - varchar(255) - required - the salted md5 hash of the password (salt + password)

Not Required Fields:

phone - uinteger(64) - the phone number of the user
firstName - varchar(255) - the user's first name
lastName - varchar(255) - the user's last name
address1 - varchar(255) - the mailing address
address2 - varchar(255) - the additional mailing address
city - varchar(255) - the city
state - varchar(255) - the two letter abbreviation
postcalCode - varchar(255) - the postal code - 5 to 8 numbers. dashes allowed

Permissions

Permissions connects a user to a campaign and/or governnent.

Table name: Permissions

Required fields

userId* - the user record - Indexed
role - enum[superAdmin|campaignAdmin|campaignStaff]
governmentId* - the government id - if set, applies to all campaigns under the government
campaignId* - the campaign id - if set, applies to only the campaign

Campaign

Campaigns are entities that will receive donation match funds. They submit donations and expenditures, and receive a matching donation. Campaigns are for ONE candidate running for office. A user can be connected to multiple campaigns.

Required Fields

Name - Campaign name

Contribution

Fields - Generated by the api

id
createdAt
updatedAt

Fields - Entered by the Campaign

date - the contribution date
type - ENUM Contribution | Other
subType - If Contribution was selected: ENUM of cash, inkind_contribution, inkind_paid_supervision, inkind_forgiven_account, inkind_forgiven_personal.
If Other type, ENUM of item_sold_fair_market, item_returned_check, item_misc, item_refund.
contributorType - ENUM  individual, business, family, labor, political_committee, political_party, unregistered, other
all strings -> contrPrefix, contrFirst, contrMiddleInitial, contrLast, contrSuffix, contrTitle 
contrBusinessName: string
Address1, Address2, Country/Region, City, State, Zip, County strings
email: string
phone: string
phoneType: ENUM Mobile, Work, Home
submitForMatching: boolean,
checkNumber: string,
amount: float
calendarYearAggregate: float,
inKindDescription: blob,
occupation: string
employerName: string
employerCity:string
employerState:string
notes: blob
matchStatus: ENUM Draft, Submitted

Fields managed by city:

complianceStatus: in_compliance, out_of_compliance, other_compliance
matchStatus: Matcheable, Processed, Paid
matchAmount: float

Documents

Activity Record

We need an auditable activity log of all actions taken in the system.

** Table Name: activities ***

Required fields

id - uniq/indexed
userId* - the user id who performed or target of the activity
activityType* - an enum of activity types
activityRecordId* - an id of the record affected
notes* - Plain language description of what occured

Not Required fields

campaignId - the campaign id
governmentId - the government id

Expenditures

Expenditures are line item expenses submitted by campaigns.

Required

date - UTC integer
type - ENUM Expenditure, Other, Other Disbursement
subtype - Expenditure - ENUM Accounts Payable, Cash Expenditure, Personal Expenditure for Reimbursement. Other - Accounts Payable Rescinded, Cash Balance Adjustment. Other Disbursement -Miscellaneous Other Disbursement, Return or Refund of Contribution.
payeeType - Individual, Business Entity, Candidate’s Immediate Family, Labor Organization, Political Committee, Political Party Committee, Unregistered Committee, Other
payeeName - string
address - string
city - string
state - string
zip - string
amount - decimal
paymentMethod - Check, Credit Card, Debit Card, Electronic Check, Electronic Funds Transfer
description - string
campaignId 
governmentId
expenditureStatus: Archived, Draft, Submitted, Out of Compliance, In Compliance

Not required


checkNumber - string
notes - string