SlideShare ist ein Scribd-Unternehmen logo
1 von 18
SQL 2 MDST 3559:  DataestheticsProf. Alvarado02/24/2011
Business PHP lessons today and tomorrow  2 today, 4 tomorrow – can on move? To meet in room 323
Review Data structures Have addressable elements Have Categories, Instances, and Values Data models Categories are implicitly related to each other Organized around an implicit subject Each instance (e.g. a row in table) is an example of the subject
What is the implied subject of a phone book?
Example What is the implicit subject? CATEGORIES EACH ROW IS AN INSTANCE, EACH CELL CONTAINS VALUES
IMPLIED SUBJECT COUNTRY (owns) (uses) SOCIAL NETWORK US Debt Country X uses social network Y Country X owns US Debt Z (in billions of $)
Overview When last we met  We created a MySQL account on UVA’s server We created a database for our account We logged into phpMyAdmin to see our new database Today we will learn how to  Upload CSV data to MySQL Search and query this data Create new tables of data from scratch Learn some basic SQL commands to interact with the data
Exercise Go to database on phpMyAdmin https://dbm2.itc.virginia.edu/phpmyadmin Download the two CSV files Import into your database Explore See: http://pages.shanti.virginia.edu/Dataesthetics_S11/archives/187
Exercise: Modify Table Familiarize yourself with the interface Left and Right sides On the Right: Top and Bottom Go to Operations view to change table name Go to Structure view to modify columns Click on icon next to table name Or click on Structure tab when looking at table Review data types
Data Types See http://pages.shanti.virginia.edu/Dataesthetics_S11/?p=194&preview=true
Exercise: Searches Use the Search function to: Find all countries that use Facebook Find China in both tables Find countries that own a debt larger than 50
Exercise: Queries Use the SQL function to make calls with the following SQL keywords SELECT FROM WHERE ORDER BY DISTINCT Syntax Table names and columns can be quoted with “back ticks” Strings quotes with single quotes
Exercise: Joins SELECT * FROM table1, table2  WHERE table1.country = table2.country
Exercise: Joins SELECT table1.country, table1.debt, table2.network FROM table1, table2  WHERE table1.country = table2.country
Exercise: LEFT Joins SELECT table1.country, table1.debt, table2.network FROM table1 LEFT JOIN table2  ON table1.country = table2.country
Dirty Data Why does the join fail? Clean up the data to make it work Try again
Exercise: Views Save your SQL as a View using “CREATE VIEW” link at bottom of report
Exercise: Create a table

Weitere ähnliche Inhalte

Was ist angesagt?

Introduction to Data Modeling
Introduction to Data ModelingIntroduction to Data Modeling
Introduction to Data Modelingguest02ff4b5
 
physical and logical data independence
physical and logical data independencephysical and logical data independence
physical and logical data independenceapoorva_upadhyay
 
Database Relationships
Database RelationshipsDatabase Relationships
Database Relationshipswmassie
 
Table naming convention
Table naming conventionTable naming convention
Table naming conventionDilip Murugan
 
Relational database- Fundamentals
Relational database- FundamentalsRelational database- Fundamentals
Relational database- FundamentalsMohammed El Hedhly
 
Data Models & Introduction to UML
Data Models & Introduction to UML Data Models & Introduction to UML
Data Models & Introduction to UML نبيله نواز
 
Relationships within the relational database
Relationships within the relational databaseRelationships within the relational database
Relationships within the relational databaseJanecatalla
 
Types of keys in dbms
Types of keys in dbmsTypes of keys in dbms
Types of keys in dbmsdarshhingu
 
Quick And Dirty Databases
Quick And Dirty DatabasesQuick And Dirty Databases
Quick And Dirty Databasescwarren
 
Chapter 2 Relational Data Model-part1
Chapter 2 Relational Data Model-part1Chapter 2 Relational Data Model-part1
Chapter 2 Relational Data Model-part1Eddyzulham Mahluzydde
 
Database Introduction by Luke Lonergan
Database Introduction by Luke LonerganDatabase Introduction by Luke Lonergan
Database Introduction by Luke LonerganLuke Lonergan
 
Relational Database Fundamentals
Relational Database FundamentalsRelational Database Fundamentals
Relational Database FundamentalsKHALID C
 

Was ist angesagt? (20)

Introduction to Data Modeling
Introduction to Data ModelingIntroduction to Data Modeling
Introduction to Data Modeling
 
physical and logical data independence
physical and logical data independencephysical and logical data independence
physical and logical data independence
 
Data Dictionary
Data DictionaryData Dictionary
Data Dictionary
 
Database Relationships
Database RelationshipsDatabase Relationships
Database Relationships
 
Table naming convention
Table naming conventionTable naming convention
Table naming convention
 
Relational database- Fundamentals
Relational database- FundamentalsRelational database- Fundamentals
Relational database- Fundamentals
 
Data Models & Introduction to UML
Data Models & Introduction to UML Data Models & Introduction to UML
Data Models & Introduction to UML
 
Chapter 3 Entity Relationship Model
Chapter 3 Entity Relationship ModelChapter 3 Entity Relationship Model
Chapter 3 Entity Relationship Model
 
RDBMS_Unit 01
RDBMS_Unit 01RDBMS_Unit 01
RDBMS_Unit 01
 
Relationships within the relational database
Relationships within the relational databaseRelationships within the relational database
Relationships within the relational database
 
Year 11 DATA PROCESSING 1st Term
Year 11 DATA PROCESSING 1st TermYear 11 DATA PROCESSING 1st Term
Year 11 DATA PROCESSING 1st Term
 
Types of keys in dbms
Types of keys in dbmsTypes of keys in dbms
Types of keys in dbms
 
Keerty rdbms sql
Keerty rdbms sqlKeerty rdbms sql
Keerty rdbms sql
 
Quick And Dirty Databases
Quick And Dirty DatabasesQuick And Dirty Databases
Quick And Dirty Databases
 
Keys used in database
Keys used in databaseKeys used in database
Keys used in database
 
Chapter 2 Relational Data Model-part1
Chapter 2 Relational Data Model-part1Chapter 2 Relational Data Model-part1
Chapter 2 Relational Data Model-part1
 
Database Introduction by Luke Lonergan
Database Introduction by Luke LonerganDatabase Introduction by Luke Lonergan
Database Introduction by Luke Lonergan
 
Db sys concept
Db sys conceptDb sys concept
Db sys concept
 
RDBMS with MySQL
RDBMS with MySQLRDBMS with MySQL
RDBMS with MySQL
 
Relational Database Fundamentals
Relational Database FundamentalsRelational Database Fundamentals
Relational Database Fundamentals
 

Andere mochten auch

MDST 3703 F10 Seminar 11
MDST 3703 F10 Seminar 11MDST 3703 F10 Seminar 11
MDST 3703 F10 Seminar 11Rafael Alvarado
 
Thatcamp2011 intro to-cm_ses
Thatcamp2011 intro to-cm_sesThatcamp2011 intro to-cm_ses
Thatcamp2011 intro to-cm_sesRafael Alvarado
 
Mdst3705 2013-01-31-php3
Mdst3705 2013-01-31-php3Mdst3705 2013-01-31-php3
Mdst3705 2013-01-31-php3Rafael Alvarado
 
UVA MDST 3703 JavaScript (ii) 2012-10-04
UVA MDST 3703 JavaScript (ii) 2012-10-04UVA MDST 3703 JavaScript (ii) 2012-10-04
UVA MDST 3703 JavaScript (ii) 2012-10-04Rafael Alvarado
 
Mdst3705 2013-02-05-databases
Mdst3705 2013-02-05-databasesMdst3705 2013-02-05-databases
Mdst3705 2013-02-05-databasesRafael Alvarado
 
Mdst3559 2011-04-26-viz1
Mdst3559 2011-04-26-viz1Mdst3559 2011-04-26-viz1
Mdst3559 2011-04-26-viz1Rafael Alvarado
 
Mdst3703 projects-2012-10-11
Mdst3703 projects-2012-10-11Mdst3703 projects-2012-10-11
Mdst3703 projects-2012-10-11Rafael Alvarado
 
Teaching the Digital Humanities
Teaching the Digital HumanitiesTeaching the Digital Humanities
Teaching the Digital HumanitiesRafael Alvarado
 
Mdst3705 2012-01-15-introduction
Mdst3705 2012-01-15-introductionMdst3705 2012-01-15-introduction
Mdst3705 2012-01-15-introductionRafael Alvarado
 
Mdst3703 2013-09-05-studio2
Mdst3703 2013-09-05-studio2Mdst3703 2013-09-05-studio2
Mdst3703 2013-09-05-studio2Rafael Alvarado
 
Mdst3705 2013-01-29-praxis
Mdst3705 2013-01-29-praxisMdst3705 2013-01-29-praxis
Mdst3705 2013-01-29-praxisRafael Alvarado
 
Mdst 3559-01-25-data-journalism
Mdst 3559-01-25-data-journalismMdst 3559-01-25-data-journalism
Mdst 3559-01-25-data-journalismRafael Alvarado
 
Mdst3703 2013-09-03-plato2
Mdst3703 2013-09-03-plato2Mdst3703 2013-09-03-plato2
Mdst3703 2013-09-03-plato2Rafael Alvarado
 
Mdst3703 2013-10-01-hypertext-and-history
Mdst3703 2013-10-01-hypertext-and-historyMdst3703 2013-10-01-hypertext-and-history
Mdst3703 2013-10-01-hypertext-and-historyRafael Alvarado
 
UVA MDST 3703 Marking-Up a Text 2012-09-13
UVA MDST 3703 Marking-Up a Text 2012-09-13UVA MDST 3703 Marking-Up a Text 2012-09-13
UVA MDST 3703 Marking-Up a Text 2012-09-13Rafael Alvarado
 

Andere mochten auch (19)

MDST 3703 F10 Seminar 11
MDST 3703 F10 Seminar 11MDST 3703 F10 Seminar 11
MDST 3703 F10 Seminar 11
 
Thatcamp2011 intro to-cm_ses
Thatcamp2011 intro to-cm_sesThatcamp2011 intro to-cm_ses
Thatcamp2011 intro to-cm_ses
 
Mdst3705 2013-01-31-php3
Mdst3705 2013-01-31-php3Mdst3705 2013-01-31-php3
Mdst3705 2013-01-31-php3
 
MDST 3703 F10 Seminar 6
MDST 3703 F10 Seminar 6MDST 3703 F10 Seminar 6
MDST 3703 F10 Seminar 6
 
UVA MDST 3703 JavaScript (ii) 2012-10-04
UVA MDST 3703 JavaScript (ii) 2012-10-04UVA MDST 3703 JavaScript (ii) 2012-10-04
UVA MDST 3703 JavaScript (ii) 2012-10-04
 
Mdst3705 2013-02-05-databases
Mdst3705 2013-02-05-databasesMdst3705 2013-02-05-databases
Mdst3705 2013-02-05-databases
 
MDST 3703 F10 Seminar 2
MDST 3703 F10 Seminar 2MDST 3703 F10 Seminar 2
MDST 3703 F10 Seminar 2
 
Mdst 3559-03-29-case-1b
Mdst 3559-03-29-case-1bMdst 3559-03-29-case-1b
Mdst 3559-03-29-case-1b
 
Mdst3559 2011-04-26-viz1
Mdst3559 2011-04-26-viz1Mdst3559 2011-04-26-viz1
Mdst3559 2011-04-26-viz1
 
Mdst3703 projects-2012-10-11
Mdst3703 projects-2012-10-11Mdst3703 projects-2012-10-11
Mdst3703 projects-2012-10-11
 
Teaching the Digital Humanities
Teaching the Digital HumanitiesTeaching the Digital Humanities
Teaching the Digital Humanities
 
Mdst3705 2012-01-15-introduction
Mdst3705 2012-01-15-introductionMdst3705 2012-01-15-introduction
Mdst3705 2012-01-15-introduction
 
MDST 3703 F10 Studio 5
MDST 3703 F10 Studio 5MDST 3703 F10 Studio 5
MDST 3703 F10 Studio 5
 
Mdst3703 2013-09-05-studio2
Mdst3703 2013-09-05-studio2Mdst3703 2013-09-05-studio2
Mdst3703 2013-09-05-studio2
 
Mdst3705 2013-01-29-praxis
Mdst3705 2013-01-29-praxisMdst3705 2013-01-29-praxis
Mdst3705 2013-01-29-praxis
 
Mdst 3559-01-25-data-journalism
Mdst 3559-01-25-data-journalismMdst 3559-01-25-data-journalism
Mdst 3559-01-25-data-journalism
 
Mdst3703 2013-09-03-plato2
Mdst3703 2013-09-03-plato2Mdst3703 2013-09-03-plato2
Mdst3703 2013-09-03-plato2
 
Mdst3703 2013-10-01-hypertext-and-history
Mdst3703 2013-10-01-hypertext-and-historyMdst3703 2013-10-01-hypertext-and-history
Mdst3703 2013-10-01-hypertext-and-history
 
UVA MDST 3703 Marking-Up a Text 2012-09-13
UVA MDST 3703 Marking-Up a Text 2012-09-13UVA MDST 3703 Marking-Up a Text 2012-09-13
UVA MDST 3703 Marking-Up a Text 2012-09-13
 

Ähnlich wie Mdst 3559-02-24-sql2

Dbms Lec Uog 02
Dbms Lec Uog 02Dbms Lec Uog 02
Dbms Lec Uog 02smelltulip
 
Week 4 The Relational Data Model & The Entity Relationship Data Model
Week 4 The Relational Data Model & The Entity Relationship Data ModelWeek 4 The Relational Data Model & The Entity Relationship Data Model
Week 4 The Relational Data Model & The Entity Relationship Data Modeloudesign
 
Data_base.pptx
Data_base.pptxData_base.pptx
Data_base.pptxMohit89650
 
Modeling- Object, Dynamic and Functional
Modeling- Object, Dynamic and FunctionalModeling- Object, Dynamic and Functional
Modeling- Object, Dynamic and FunctionalRajani Bhandari
 
Bank mangement system
Bank mangement systemBank mangement system
Bank mangement systemFaisalGhffar
 
Database system the final assignment for this course is an eight to
Database system the final assignment for this course is an eight toDatabase system the final assignment for this course is an eight to
Database system the final assignment for this course is an eight tomehek4
 
Islamic University Previous Year Question Solution 2019 (ADBMS)
Islamic University Previous Year Question Solution 2019 (ADBMS)Islamic University Previous Year Question Solution 2019 (ADBMS)
Islamic University Previous Year Question Solution 2019 (ADBMS)Rakibul Hasan Pranto
 
Advanced Database Systems - Presentation 1 with quiz.pptx
Advanced Database Systems - Presentation 1 with quiz.pptxAdvanced Database Systems - Presentation 1 with quiz.pptx
Advanced Database Systems - Presentation 1 with quiz.pptxEllenGracePorras
 
Artifacts, Data Dictionary, Data Modeling, Data Wrangling
Artifacts, Data Dictionary, Data Modeling, Data WranglingArtifacts, Data Dictionary, Data Modeling, Data Wrangling
Artifacts, Data Dictionary, Data Modeling, Data WranglingFaisal Akbar
 
Info systems databases
Info systems databasesInfo systems databases
Info systems databasesMR Z
 

Ähnlich wie Mdst 3559-02-24-sql2 (20)

Fg d
Fg dFg d
Fg d
 
Unit_2.pdf
Unit_2.pdfUnit_2.pdf
Unit_2.pdf
 
Topics-Ch4Ch5.ppt
Topics-Ch4Ch5.pptTopics-Ch4Ch5.ppt
Topics-Ch4Ch5.ppt
 
Topics-Ch4Ch5.ppt
Topics-Ch4Ch5.pptTopics-Ch4Ch5.ppt
Topics-Ch4Ch5.ppt
 
Dbms Lec Uog 02
Dbms Lec Uog 02Dbms Lec Uog 02
Dbms Lec Uog 02
 
Week 4 The Relational Data Model & The Entity Relationship Data Model
Week 4 The Relational Data Model & The Entity Relationship Data ModelWeek 4 The Relational Data Model & The Entity Relationship Data Model
Week 4 The Relational Data Model & The Entity Relationship Data Model
 
Data_base.pptx
Data_base.pptxData_base.pptx
Data_base.pptx
 
RDMS AND SQL
RDMS AND SQLRDMS AND SQL
RDMS AND SQL
 
Modeling- Object, Dynamic and Functional
Modeling- Object, Dynamic and FunctionalModeling- Object, Dynamic and Functional
Modeling- Object, Dynamic and Functional
 
Bank mangement system
Bank mangement systemBank mangement system
Bank mangement system
 
Database system the final assignment for this course is an eight to
Database system the final assignment for this course is an eight toDatabase system the final assignment for this course is an eight to
Database system the final assignment for this course is an eight to
 
Islamic University Previous Year Question Solution 2019 (ADBMS)
Islamic University Previous Year Question Solution 2019 (ADBMS)Islamic University Previous Year Question Solution 2019 (ADBMS)
Islamic University Previous Year Question Solution 2019 (ADBMS)
 
Advanced Database Systems - Presentation 1 with quiz.pptx
Advanced Database Systems - Presentation 1 with quiz.pptxAdvanced Database Systems - Presentation 1 with quiz.pptx
Advanced Database Systems - Presentation 1 with quiz.pptx
 
E-R diagram & SQL
E-R diagram & SQLE-R diagram & SQL
E-R diagram & SQL
 
Data models
Data modelsData models
Data models
 
Data models
Data modelsData models
Data models
 
Database Project
Database ProjectDatabase Project
Database Project
 
T-SQL Overview
T-SQL OverviewT-SQL Overview
T-SQL Overview
 
Artifacts, Data Dictionary, Data Modeling, Data Wrangling
Artifacts, Data Dictionary, Data Modeling, Data WranglingArtifacts, Data Dictionary, Data Modeling, Data Wrangling
Artifacts, Data Dictionary, Data Modeling, Data Wrangling
 
Info systems databases
Info systems databasesInfo systems databases
Info systems databases
 

Mehr von Rafael Alvarado

Mdst3703 2013-10-08-thematic-research-collections
Mdst3703 2013-10-08-thematic-research-collectionsMdst3703 2013-10-08-thematic-research-collections
Mdst3703 2013-10-08-thematic-research-collectionsRafael Alvarado
 
Mdst3703 2013-09-24-hypertext
Mdst3703 2013-09-24-hypertextMdst3703 2013-09-24-hypertext
Mdst3703 2013-09-24-hypertextRafael Alvarado
 
Mdst3703 2013-09-12-semantic-html
Mdst3703 2013-09-12-semantic-htmlMdst3703 2013-09-12-semantic-html
Mdst3703 2013-09-12-semantic-htmlRafael Alvarado
 
Mdst3703 2013-09-17-text-models
Mdst3703 2013-09-17-text-modelsMdst3703 2013-09-17-text-models
Mdst3703 2013-09-17-text-modelsRafael Alvarado
 
Mdst3703 2013-09-10-textual-signals
Mdst3703 2013-09-10-textual-signalsMdst3703 2013-09-10-textual-signals
Mdst3703 2013-09-10-textual-signalsRafael Alvarado
 
Mdst3703 2013-08-29-hello-world
Mdst3703 2013-08-29-hello-worldMdst3703 2013-08-29-hello-world
Mdst3703 2013-08-29-hello-worldRafael Alvarado
 
UVA MDST 3703 2013 08-27 Introduction
UVA MDST 3703 2013 08-27 IntroductionUVA MDST 3703 2013 08-27 Introduction
UVA MDST 3703 2013 08-27 IntroductionRafael Alvarado
 
MDST 3705 2012-03-05 Databases to Visualization
MDST 3705 2012-03-05 Databases to VisualizationMDST 3705 2012-03-05 Databases to Visualization
MDST 3705 2012-03-05 Databases to VisualizationRafael Alvarado
 
Mdst3705 2013-02-26-db-as-genre
Mdst3705 2013-02-26-db-as-genreMdst3705 2013-02-26-db-as-genre
Mdst3705 2013-02-26-db-as-genreRafael Alvarado
 
Mdst3705 2013-02-19-text-into-data
Mdst3705 2013-02-19-text-into-dataMdst3705 2013-02-19-text-into-data
Mdst3705 2013-02-19-text-into-dataRafael Alvarado
 
Mdst3705 2013-02-12-finding-data
Mdst3705 2013-02-12-finding-dataMdst3705 2013-02-12-finding-data
Mdst3705 2013-02-12-finding-dataRafael Alvarado
 
Mdst3705 2012-01-22-code-as-language
Mdst3705 2012-01-22-code-as-languageMdst3705 2012-01-22-code-as-language
Mdst3705 2012-01-22-code-as-languageRafael Alvarado
 
Mdst3705 2013-01-24-php2
Mdst3705 2013-01-24-php2Mdst3705 2013-01-24-php2
Mdst3705 2013-01-24-php2Rafael Alvarado
 
Mdst3703 graph-theory-11-20-2012
Mdst3703 graph-theory-11-20-2012Mdst3703 graph-theory-11-20-2012
Mdst3703 graph-theory-11-20-2012Rafael Alvarado
 
Mdst3703 maps-and-timelines-2012-11-13
Mdst3703 maps-and-timelines-2012-11-13Mdst3703 maps-and-timelines-2012-11-13
Mdst3703 maps-and-timelines-2012-11-13Rafael Alvarado
 
Mdst3703 culturomics-2012-11-01
Mdst3703 culturomics-2012-11-01Mdst3703 culturomics-2012-11-01
Mdst3703 culturomics-2012-11-01Rafael Alvarado
 
Mdst3703 visualization-2012-10-23
Mdst3703 visualization-2012-10-23Mdst3703 visualization-2012-10-23
Mdst3703 visualization-2012-10-23Rafael Alvarado
 
Mdst3703 shiva-2012-10-18
Mdst3703 shiva-2012-10-18Mdst3703 shiva-2012-10-18
Mdst3703 shiva-2012-10-18Rafael Alvarado
 
Mdst3703 ontology-overrated-2012-10-16
Mdst3703 ontology-overrated-2012-10-16Mdst3703 ontology-overrated-2012-10-16
Mdst3703 ontology-overrated-2012-10-16Rafael Alvarado
 

Mehr von Rafael Alvarado (20)

Mdst3703 2013-10-08-thematic-research-collections
Mdst3703 2013-10-08-thematic-research-collectionsMdst3703 2013-10-08-thematic-research-collections
Mdst3703 2013-10-08-thematic-research-collections
 
Mdst3703 2013-09-24-hypertext
Mdst3703 2013-09-24-hypertextMdst3703 2013-09-24-hypertext
Mdst3703 2013-09-24-hypertext
 
Presentation1
Presentation1Presentation1
Presentation1
 
Mdst3703 2013-09-12-semantic-html
Mdst3703 2013-09-12-semantic-htmlMdst3703 2013-09-12-semantic-html
Mdst3703 2013-09-12-semantic-html
 
Mdst3703 2013-09-17-text-models
Mdst3703 2013-09-17-text-modelsMdst3703 2013-09-17-text-models
Mdst3703 2013-09-17-text-models
 
Mdst3703 2013-09-10-textual-signals
Mdst3703 2013-09-10-textual-signalsMdst3703 2013-09-10-textual-signals
Mdst3703 2013-09-10-textual-signals
 
Mdst3703 2013-08-29-hello-world
Mdst3703 2013-08-29-hello-worldMdst3703 2013-08-29-hello-world
Mdst3703 2013-08-29-hello-world
 
UVA MDST 3703 2013 08-27 Introduction
UVA MDST 3703 2013 08-27 IntroductionUVA MDST 3703 2013 08-27 Introduction
UVA MDST 3703 2013 08-27 Introduction
 
MDST 3705 2012-03-05 Databases to Visualization
MDST 3705 2012-03-05 Databases to VisualizationMDST 3705 2012-03-05 Databases to Visualization
MDST 3705 2012-03-05 Databases to Visualization
 
Mdst3705 2013-02-26-db-as-genre
Mdst3705 2013-02-26-db-as-genreMdst3705 2013-02-26-db-as-genre
Mdst3705 2013-02-26-db-as-genre
 
Mdst3705 2013-02-19-text-into-data
Mdst3705 2013-02-19-text-into-dataMdst3705 2013-02-19-text-into-data
Mdst3705 2013-02-19-text-into-data
 
Mdst3705 2013-02-12-finding-data
Mdst3705 2013-02-12-finding-dataMdst3705 2013-02-12-finding-data
Mdst3705 2013-02-12-finding-data
 
Mdst3705 2012-01-22-code-as-language
Mdst3705 2012-01-22-code-as-languageMdst3705 2012-01-22-code-as-language
Mdst3705 2012-01-22-code-as-language
 
Mdst3705 2013-01-24-php2
Mdst3705 2013-01-24-php2Mdst3705 2013-01-24-php2
Mdst3705 2013-01-24-php2
 
Mdst3703 graph-theory-11-20-2012
Mdst3703 graph-theory-11-20-2012Mdst3703 graph-theory-11-20-2012
Mdst3703 graph-theory-11-20-2012
 
Mdst3703 maps-and-timelines-2012-11-13
Mdst3703 maps-and-timelines-2012-11-13Mdst3703 maps-and-timelines-2012-11-13
Mdst3703 maps-and-timelines-2012-11-13
 
Mdst3703 culturomics-2012-11-01
Mdst3703 culturomics-2012-11-01Mdst3703 culturomics-2012-11-01
Mdst3703 culturomics-2012-11-01
 
Mdst3703 visualization-2012-10-23
Mdst3703 visualization-2012-10-23Mdst3703 visualization-2012-10-23
Mdst3703 visualization-2012-10-23
 
Mdst3703 shiva-2012-10-18
Mdst3703 shiva-2012-10-18Mdst3703 shiva-2012-10-18
Mdst3703 shiva-2012-10-18
 
Mdst3703 ontology-overrated-2012-10-16
Mdst3703 ontology-overrated-2012-10-16Mdst3703 ontology-overrated-2012-10-16
Mdst3703 ontology-overrated-2012-10-16
 

Mdst 3559-02-24-sql2

  • 1. SQL 2 MDST 3559: DataestheticsProf. Alvarado02/24/2011
  • 2. Business PHP lessons today and tomorrow 2 today, 4 tomorrow – can on move? To meet in room 323
  • 3. Review Data structures Have addressable elements Have Categories, Instances, and Values Data models Categories are implicitly related to each other Organized around an implicit subject Each instance (e.g. a row in table) is an example of the subject
  • 4. What is the implied subject of a phone book?
  • 5. Example What is the implicit subject? CATEGORIES EACH ROW IS AN INSTANCE, EACH CELL CONTAINS VALUES
  • 6. IMPLIED SUBJECT COUNTRY (owns) (uses) SOCIAL NETWORK US Debt Country X uses social network Y Country X owns US Debt Z (in billions of $)
  • 7. Overview When last we met We created a MySQL account on UVA’s server We created a database for our account We logged into phpMyAdmin to see our new database Today we will learn how to Upload CSV data to MySQL Search and query this data Create new tables of data from scratch Learn some basic SQL commands to interact with the data
  • 8. Exercise Go to database on phpMyAdmin https://dbm2.itc.virginia.edu/phpmyadmin Download the two CSV files Import into your database Explore See: http://pages.shanti.virginia.edu/Dataesthetics_S11/archives/187
  • 9. Exercise: Modify Table Familiarize yourself with the interface Left and Right sides On the Right: Top and Bottom Go to Operations view to change table name Go to Structure view to modify columns Click on icon next to table name Or click on Structure tab when looking at table Review data types
  • 10. Data Types See http://pages.shanti.virginia.edu/Dataesthetics_S11/?p=194&preview=true
  • 11. Exercise: Searches Use the Search function to: Find all countries that use Facebook Find China in both tables Find countries that own a debt larger than 50
  • 12. Exercise: Queries Use the SQL function to make calls with the following SQL keywords SELECT FROM WHERE ORDER BY DISTINCT Syntax Table names and columns can be quoted with “back ticks” Strings quotes with single quotes
  • 13. Exercise: Joins SELECT * FROM table1, table2 WHERE table1.country = table2.country
  • 14. Exercise: Joins SELECT table1.country, table1.debt, table2.network FROM table1, table2 WHERE table1.country = table2.country
  • 15. Exercise: LEFT Joins SELECT table1.country, table1.debt, table2.network FROM table1 LEFT JOIN table2 ON table1.country = table2.country
  • 16. Dirty Data Why does the join fail? Clean up the data to make it work Try again
  • 17. Exercise: Views Save your SQL as a View using “CREATE VIEW” link at bottom of report