Itzik Ben-Gan’s SQL Database


This entry is part 1 of 1 in the series SQL Itzik Database
  • Itzik Ben-Gan’s SQL Database

In Itzik’s book T-SQL Querying, published by Microsoft Press in 2015, he uses several tables as examples. Here is one set of tables he frequently uses shown below in a screen shot of a SQL Server database diagram I created from Itzik’s database. This diagram includes almost all of the tables in Itzik Ben-Gan’s database. It does not include Sales.Shippers, Stats.Scores and Stats.Tests, but s is more than enough for us to look at for now. We have another post here that looks at this database in Excel. Have a look at the post called Itzik Ben Gan’s Database.

The Orders table is used in several examples in his book, so shown below is just the first few rows of data from the Sales.Orders table. The data is not in any particular order. The orderid is a primary key. You can see that the custid and the empid have repeating values. They are foreign keys. custid is a primary key. It has 830 rows.

Here is a screenshot of the Sales.Customers table. It has 91 rows.

Below is a screenshot of the entire HR.Employees table. It has 9 rows. empid is a primary key,.

Below is a screenshot of part of the Sales.OrderDetails table. It has 2155 rows. It has a composite primary key comprised of orderid and productid. A composite key is a combination of two or more columns in a table that can be used to uniquely identify each row in the table when the columns are combined uniqueness is guaranteed, but when it taken individually it does not guarantee uniqueness.