Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Introduction to Database Concepts

4,224 views

Published on

Published in: Technology
  • Be the first to comment

Introduction to Database Concepts

  1. 1. Introduction to Database Concepts
  2. 2. Campaigns Need Data <ul><li>Campaigning depends on lists. </li></ul><ul><ul><li>Supporters </li></ul></ul><ul><ul><li>Volunteers </li></ul></ul><ul><ul><li>Donors </li></ul></ul><ul><ul><li>Voters </li></ul></ul><ul><ul><li>Legislators </li></ul></ul><ul><ul><li>Can you think of others? </li></ul></ul>
  3. 3. The (Internet) Life of Data
  4. 4. Important Data Terms Database In practice, a set of tables. Relational databases (like the ones that underlie websites) have tables that are related to each other by common fields. <ul><ul><li>(clarity over accuracy) </li></ul></ul>Table A table is a collection of data organized into columns (fields) and rows (records) and related to other tables by common fields. Field A column. A field contains all the same type of data; each cell refers to a different unit. Record A row. A record contains all the different types of data about a unit of analysis (e.g. user, order, letter).
  5. 5. Tables Relate to Each Other “Keys” to success Fields that relate tables to each other are called “ keys ”. “ Primary key ” is the field (column) containing a unique id for each record. Keys prevent duplication of info in database. donations volunteers campaigns users
  6. 6. Exercise <ul><li>Which campaign did Mr. Greenburg volunteer for? </li></ul><ul><li>How much money did Sarah raise? </li></ul><ul><li>Who recruited her? </li></ul><ul><li>How much money did the phone bank raise? </li></ul>users volunteers donations campaigns
  7. 7. Tables Relate to Each Other “Keys” to success Fields that relate tables to each other are called “ keys ”. “ Primary key ” is the field (column) containing a unique id for each record. Keys prevent duplication of info in database. donations volunteers campaigns users
  8. 8. Structured Query Language SQL A standard language for querying and modifying relational databases. Query Using SQL to ask the database a question. mySQL An Open Source Software relational database management system that uses SQL. mySQL Query Browser One of many available programs that allows you to connect to a database and run queries on it.
  9. 9. Structured Query Language Use SQL SELECT, UPDATE, INSERT, or DELETE data. SELECT statements ask the database to display data. SQL is the standard language used to speak to databases Use a SQL client to connect to the database and execute SELECT, UPDATE, INSERT, or DELETE statements.
  10. 10. mySQL Query Browser The database has a message for you…
  11. 11. Anatomy a SELECT statement <ul><li>SELECT [fields] </li></ul><ul><li>FROM [tables] </li></ul><ul><li>JOIN [tables] </li></ul><ul><li>WHERE [criteria] </li></ul><ul><li>ORDER BY [sort] </li></ul><ul><li>GROUP BY [field] </li></ul><ul><li>LIMIT [# of results] </li></ul>We’ll focus on SELECT statements today, because they’re the most basic, and what you’ll need most in your work. Leave the UPDATE, DELETE, INSERT to the tech team, if there is one.
  12. 12. Anatomy a SELECT statement <ul><li>The most basic: </li></ul><ul><li>SELECT * </li></ul><ul><li>FROM users; </li></ul>We’ll focus on SELECT statements today, because they’re the most basic, and what you’ll need most in your work. Leave the UPDATE, DELETE, INSERT to the tech team, if there is one.
  13. 13. Anatomy a SELECT statement <ul><li>The second most basic: </li></ul><ul><li>SELECT user_id </li></ul><ul><li>FROM users; </li></ul>We’ll focus on SELECT statements today, because they’re the most basic, and what you’ll need most in your work. Leave the UPDATE, DELETE, INSERT to the tech team, if there is one.
  14. 14. Anatomy a SELECT statement <ul><li>SELECT [fields] </li></ul><ul><li>FROM [tables] </li></ul><ul><li>JOIN [tables] </li></ul><ul><li>WHERE [criteria] </li></ul><ul><li>ORDER BY [sort] </li></ul><ul><li>GROUP BY [field] </li></ul><ul><li>LIMIT [# of results] </li></ul>We’ll focus on SELECT statements today, because they’re the most basic, and what you’ll need most in your work. Leave the UPDATE, DELETE, INSERT to the tech team, if there is one.
  15. 15. Anatomy a SELECT statement <ul><li>SELECT * </li></ul><ul><li>FROM users </li></ul><ul><li>WHERE </li></ul><ul><li>city = ‘Austin’; </li></ul>We’ll focus on SELECT statements today, because they’re the most basic, and what you’ll need most in your work. Leave the UPDATE, DELETE, INSERT to the tech team, if there is one.
  16. 16. Exercise <ul><li>Show all members’ first names </li></ul><ul><li>Show how much Dave Young donated </li></ul><ul><li>Show when Sarah Jones signed up to volunteer </li></ul><ul><li>Show the contact info for everyone from Massachusetts </li></ul><ul><li>List the user_id of everyone who donated to the general fund </li></ul>users volunteers donations campaigns
  17. 17. Try this at home. <ul><li>Install Query Browser: http://dev.mysql.com/downloads/query-browser/index.html </li></ul><ul><li>Connect to the test database: host: 66.226.14.211 username/pw/schema: noi (all 3 the same) </li></ul><ul><li>mySQL Docs: http://dev.mysql.com/doc/refman/5.1/en/index.html </li></ul><ul><li>SQL Tutorial: http://www.w3schools.com/sql/sql_intro.asp </li></ul>

×