This document provides an overview of SQL (Structured Query Language) including what it is, practical applications, and basic syntax. SQL is a programming language used to access and manipulate data stored in relational databases. It allows users to easily manage data through commands to select, update, and insert records. The document discusses how SQL is used with relational database systems like MySQL and Microsoft Access. It also provides examples of basic SQL syntax for selecting, updating, and inserting data.
3. Undergraduate Economics Association
SQL
3
• A very high level programming language, used to access
information stored on a database system
• SQL let you manipulate data easily through a series of
commands
• Why use SQL?
• Relational Databases vs. Flat Database
• http://office.microsoft.com/en-
us/training/relational-means-data-in-multiple-
tables-RZ010253998.aspx?section=3
8. Undergraduate Economics Association
Syntax(selecting)
8
• The Basics (the SQL query):
• SELECT
• Choosing your data to manipulate or view
by field (column)
• FROM
• Choosing your data by table
• WHERE
• The parameters of your query, will define
what results you see
• http://sqlzoo.net
9. Undergraduate Economics Association
Syntax(updating)
9
• A little more advanced:
• UPDATE
• Choosing your data by table
• SET
• Choosing your data to manipulate by field
(column)
• WHERE
• The parameters of your query, will define
what results you see
• IF YOU DO NOT SET A WHERE CLAUSE, YOU
LOSE ALL DATA!
• An update query will not show results without a
select query!
10. Undergraduate Economics Association
Syntax(inserting)
10
• A little more advanced:
• Two ways:
• INSERT INTO
• Choosing your data entry point manipulate
by table(field,field)
• SELECT
• Choosing your data by field
• FROM
• Choosing your data by table
OR
• INSERT INTO
• VALUES
('2012',’Sydney'),('2016',’Athens'),(‘2020’,’Beijing’);
• An update query will not show results without a
select query!
11. Undergraduate Economics Association
PrimaryKeyandForeignKey
11
• The Primary Key is a unique identifier that defines
each row
• Ex. Your BU ID number
• Data without an assigned Primary Key will create
errors in your database
• Cannot contain NULL values
• Foreign Keys point to Primary Keys in other tables,
linking them together
• Persons linked to Orders table, cannot create
new order without P_id link
12. Undergraduate Economics Association
Syntax
12
• Google is your friend
• http://stackoverflow.com
• “Introduction to Access SQL”, Microsoft website
• Also: Microsoft Office training courses
• http://www.w3schools.com/sql
13. Undergraduate Economics Association
Upcoming:
13
• Email reports to spetitti@bu.edu
• The UEA will be compiling the information into a
release for the journal, each individual will be
credited for their contribution