Sql Excel : Purchases Dataset

The purchases dataset contains entities typical of retail purchases; the entities in
this dataset and their relationships are shown in Figure 1.1 (page 11) :
This data captures the important entities associated with retail purchases. The
most detailed information is in OrderLines, which describes each of the items in an
order. To understand the name of the table, think of a receipt. Each line on the
receipt represents a different item in the purchase. In addition, the line has other
information such as the product id, the price, and the number of items, which are
all in this table.
The Products table provides information such as the product group name and the
full price of a product. The table does not contain detailed product names. These
were removed as part of the effort to anonymize the data.
To tie all the items in a single purchase together, each row of OrderLines has an
OrderId. Each OrderId, in turn, represents one row in the Orders table, which has
information such as the date and time of the purchase, where the order was
shipped to, and the type of payment. It also contains the total dollar amount of the
purchase, summed up from the individual items. Each order line is in exactly one
order and each order has one or more order lines. This relationship is described as
a one-to-many relationship between these tables.
Just as the OrderId ties multiple order lines into an order, the CustomerId assigns
orders made at different points in time to the same customer. The existence of the
CustomerId prompts the question of how it is created. In one sense, it makes no
difference how it is created; the CustomerId is simply a given, defining the
customer in the database. Is it is doing a good job? That is, are a single customer s
purchases being tied together most of the time? The aside “The Customer ID:
Identifying Customers Over Time,” discusses the creation of customer IDs.