Database Management/SQL

This lesson introduces Structured Query Language (SQL). SQL is a domain-specific language used in programming and designed for managing data held in a relational database management system (RDBMS).[1]

Objectives and SkillsEdit

Objectives and skills for this lesson include:

  • Understand SQL concepts
  • Create single-table SQL queries using a database application
  • Create multi-table SQL queries using a database application

ReadingsEdit

  1. Wikipedia: SQL
  2. Wikibooks: Structured Query Language/Data Query Language

MultimediaEdit

  1. YouTube: Learn Basic SQL
  2. YouTube: The Structured Query Language (SQL)
  3. YouTube: Introduction to SQL with LibreOffice Base
  4. YouTube: Microsoft Access SQL Basics

ActivitiesEdit

  1. Select a database application to use for this lesson. LibreOffice Base and Microsoft Access are recommended.
  2. Review Database Applications and Database Software for background information and tutorials.
  3. Complete the activities below using your selected database application and SQL view.

LibreOffice BaseEdit

  1. To view SQL for a query, open the query and then select View and Switch Design View On/Off.

Microsoft AccessEdit

  1. To view SQL for a query, open the query and then select View and SQL View.

NorthwindEdit

  1. Download a copy of the Database Examples/Northwind database for your selected database application.
  2. Review the E-R diagram in your database application to verify that it matches the Database Examples/Northwind example. Note the primary keys, foreign keys, and relationships. Then write SQL queries to determine results for each of the following.
  3. Select all fields and all records in the Categories table.
  4. Select the CustomerName for all customers.
  5. Select the CustomerName for all customers in the country 'Italy'.
  6. Select the ProductName for all products in Category 1 with a price less than $5.00.
  7. Select the SupplierName for all suppliers from English-speaking countries (Australia, Canada, UK, USA)
  8. Select the first and last names of all employees having a birthday in September.
  9. Select the CustomerName and OrderID for all orders placed on 9 September 1996.
  10. Select the ProductName for all seafood products with a supplier from 'Boston'.

Lesson SummaryEdit

  • SQL is a domain-specific language used in programming and designed for managing data held in a relational database management system (RDBMS).[2]
  • SQL statements may be classified into either data query language (DQL), data definition language (DDL), data control language (DCL), or data manipulation language (DML).[3]
  • Data query language (DQL) includes the SELECT statement.[4]
  • The structure of the SELECT statement is:[5]
    • SELECT ... FROM ... WHERE ...
  • The FROM clause, which indicates the table(s) to retrieve data from.[6]
  • The WHERE clause includes a comparison predicate, which restricts the rows returned by the query.[7]

Key TermsEdit

See AlsoEdit

ReferencesEdit