TFC-ListProject / build-the-list

build the most exhaustive list of campaigns down to the district level
0 stars 1 forks source link

Database schema #4

Open dbolson opened 7 years ago

dbolson commented 7 years ago

Based on the initial proposed schema and data from New Jersey, here is a proposed updated schema. I left off a few details from the first one but only for the sake of clarity here. This would be version 1 of a few before we would have a final schema for the mvp.

candidates
first_name varchar(255)
last_name varchar(255)
candidates_elections
candidate_id integer
election_id integer
party_id integer
districts
name varchar(255)
state varchar(2)
district_election_results
candidate_id integer
district_id integer
election_id integer
votes integer
election_types
name varchar(100)
elections
election_type_id integer
year smallint default date_part('year', now())
state varchar(2)
municipalities
district_id integer
name varchar(255)
municipality_election_results
candidate_id integer
election_id integer
municipality_id integer
votes integer
parties
name varchar(255)
dbolson commented 7 years ago
tarheel commented 7 years ago

Thanks for iterating on this. One other wrinkle: we want to be able to store data about how the people within a district voted in other elections, e.g. the 2012 presidential election or a 2014 U.S. Senate race.

dbolson commented 7 years ago

The district_election_results should take care of this. It records

This is the same for municipality_election_results.

Does this get us the data you're talking about?

tarheel commented 7 years ago

Oh, I see. I had misunderstood your design.

dbolson commented 7 years ago

Would it be helpful to show example data for this design?

tarheel commented 7 years ago

Nah, it's clear now.

tarheel commented 7 years ago

Some suggestions on the schema:

(previously discussed)

(new)

tarheel commented 7 years ago

Also add the following columns to the *_election_results tables: