sql - structured query language for database analyses

6
SQL - Structured Query Language For database analyses

Upload: marian-french

Post on 05-Jan-2016

219 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: SQL - Structured Query Language For database analyses

SQL - Structured Query Language

For database analyses

Page 2: SQL - Structured Query Language For database analyses

SQL – Structured Query Language

• SQL is designed to do variable selection and manipulation on data stored in multiple tables

Why multiple tables? (aka database)• Avoid duplication of information• Ease of updating information• Linked by unique identifiers/codesWhere would we use? A single entity with many

different operations with common information

Page 3: SQL - Structured Query Language For database analyses

University

• Many functions: students taking classes & getting grades, scheduling classes in rooms, students paying tuition & fees, faculty teaching classes, faculty getting paid, etc

Tables of • Students, faculty with demographics• Students*classes, faculty*classes• Tuition payments, faculty payroll, etc.• Linked by studentID, facultyID, classID, etc

Page 4: SQL - Structured Query Language For database analyses

Business

• Multiple functions including selling, buying, production, and paying employees

Tables of orders, suppliers, customers, products, accounts payable & receivable, payroll, ….

Linked by productID, customerID, …

Page 5: SQL - Structured Query Language For database analyses

Baseball

Lahman database – season summaries•Tables of teams, batting (player*season), pitching (player*season), salaries, demographics (Master)•Linked by playerID, teamID, etc.•Why baseball? Nonproprietary, not small, interesting? … maybe

Page 6: SQL - Structured Query Language For database analyses

In SAS

• PROC SQL• Designed to run interactively (end with QUIT;)• Tables are stored as SAS datasets

Let’s look at the baseball data in SAS….