Introduction to the Northwind Database

Contact Us or call 1-877-932-8228
Introduction to the Northwind Database

Introduction to the Northwind Database

The Northwind database is a sample database used by Microsoft to demonstrate the features of some of its products, including SQL Server and Microsoft Access. The database contains the sales data for Northwind Traders, a fictitious specialty foods export-import company.

Although the code taught in this class is not specific to Microsoft products, we use the Northwind database for many of our examples because many people are already familiar with it and because there are many resources for related learning that make use of the same database.

The diagram below shows the table structure of the Northwind database.

The Northwind database has additional tables, but we will only be using the ones shown above. In this lesson, we will explore some of these tables.

Some Basics

Comments

The standard SQL comment is two hyphens (--). However, some databases use other forms of comments as shown in the table below.

SQL Comments
-- # /* */
Example -- Comment # Comment /* Comment */
ANSI YES NO NO
SQL Server YES NO YES
Oracle YES NO YES
MySQL YES YES YES

The code sample below shows some sample comments.

Code Sample:

SimpleSelects/Demos/Comments.sql
-- Single-line comment
/*
	Multi-line comment used in:
		 -SQL Server
		 -Oracle
		 -MySQL
*/

Whitespace and Semi-colons

Whitespace is ignored in SQL statements. Multiple statements are separated with semi-colons. The two statements in the sample below are equally valid.

Code Sample:

SimpleSelects/Demos/WhiteSpace.sql
SELECT * FROM Employees;

SELECT *
FROM Employees;

Case Sensitivity

SQL is not case sensitive. It is common practice to write reserved words in all capital letters. User-defined names, such as table names and column names may or may not be case sensitive depending on the operating system used.

SELECTing All Columns in All Rows

The following syntax is used to retrieve all columns in all rows of a table.

Syntax

SELECT table.*
FROM table;

	-- OR

SELECT *
FROM table;

Code Sample:

SimpleSelects/Demos/SelectAll.sql
--Retrieve all columns in the Region table
SELECT *
FROM Region;

The above SELECT statement will return the following results:

As you can see, the Region table has only two columns, RegionID and RegionDescription, and four rows.

Next