SQL at PVS


New to SQL

Please note: interacting with our database through SQL is a privilege for high-performing interns and staff. Its use and practice should not interfere with the accomplishment of your normal responsibilities and duties as previously described in any way.

We use PostgreSQL and documentation is located here: https://www.postgresql.org/

Before being trained, please read this page. It will give you some background for the upcoming training:
http://wiki.votesmart.org/ResearchSQLTutorial

During training, we will practice with these queries. It's unlikely we'll get through all 7, so please try the others in your spare time.
http://wiki.votesmart.org/TrainingPracticeQueries

This map of our database may help when you're looking for information about the tables: https://dl.dropboxusercontent.com/u/50470502/pvsadmin.public.png
Or, if you learn better with tables and text, check out the PvsadminSchema

Once you become comfortable with these basic concepts, we can show you how to use different types of JOINs, as well as subqueries. More info on joins can be found on the SQLJoins page.

Understand that this is not the easiest stuff to wrap your head around, so feel free to ask if you need help. Try out this tutorial if you are interested in further developing your SQL skills.


How to Train

The Vote Smart SQL training routine has two main sections and three overarching knowledge areas. The sections are addressed in order and the different knowledge areas are emphasized as they come up within each section. The whole training session usually lasts from 2-4 hours depending on how quickly the trainees pick it up and the number of questions. Before the training session, I have them read over this wiki page: http://wiki.votesmart.org/ResearchSQLTutorial (this is mentioned at the top of this page) just to get a handle on some of the vocabulary.

In order of lowest to highest types of knowledge, those areas are:
1. knowledge about databases - general database structures (tables, fields, cells, data types, etc.) and relationships as well as the organization specific data as seen on https://dl.dropboxusercontent.com/u/50470502/pvsadmin.public.png (while still conceptually useful, this map may be outdated).
2. knowledge about the SQL language - it is important to stress that this is a language in that it requires an understanding of vocabulary and rules of grammar not to mention style and structure.
3. knowledge about how to ask a question - ask for the data that will answer the question and build in checks to avoid duplicates, false positives, and other errors.

Part 1
The first main section is most closely related to knowledge area # 1 and it covers basic ideas about relational databases, tables, fields, datatypes, along with some details about our tables and fields that they should already know through their work in admin. I make sure to define the various terms starting with the most basic:
At this point, we've given the trainees a decent introduction to databases, structures, vocabulary, and some of our data. That should form the foundation of knowledge area #1.

Part 2
The second main section really covers the basics of knowledge area #2 and some key parts of #3. Here are some definitions and notes for those basic terms:

Have the trainees take turns working through the other practice queries. As the trainer, you should help them with direct assistance, leading questions, as well as misleading questions to emphasize certain points. This is especially useful with items related to knowledge area #3. They can help each other as well.

We never get through all 7 of them, so I tell the trainees to work on the others in their spare time. Before ending the training I like to show them some interesting queries we've saved to the wiki (see below). This last step gives the new trainees an idea of what's possible with slightly more advanced queries.


Useful Research Queries

These pages include queries to find errors (pyquals and others) as well as measures of productivity and generally interesting queries.




ResearchQueries

Returns candidate table showing preferred name

Returns all currently active officials in state legislatures with some biographical information

Queries For Candidates (Office Seeking)

Queries For Committees

Queries For Endorsements

Queries for Former Office Holders - To display lists of state and federal officials from prior years.
There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki