
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Instructions
Using the data provided in the Ch13_SaleCo;
(Hint: In Problems 5–11, use the ROLLUP command.)
Below is the Schema for the database:
Problem 7
What is the SQL command to list the total sales by region and customer, with subtotals by region and a grand total for all sales? Figure P13.7 shows the result of the query.

Transcribed Image Text:**Figure 13.20: SaleCo Snowflake Schema**
This figure illustrates the "SaleCo Snowflake Schema," which is a type of database schema used in data warehousing environments. It visually represents how data is organized and related in multiple tables through a series of relationships.
**Tables and Relationships:**
1. **DWREGION**
- **Primary Key (PK):** REG_ID
- **Attributes:**
- REG_NAME
2. **DWCUSTOMER**
- **Primary Key (PK):** CUS_CODE
- **Attributes:**
- CUS_LNAME
- CUS_FNAME
- CUS_INITIAL
- CUS_STATE
- REG_ID
- **Foreign Key (FK1):** REG_ID links to DWREGION
3. **DWTIME**
- **Primary Key (PK):** TM_ID
- **Attributes:**
- TM_YEAR
- TM_MONTH
- TM_DAY
- TM_QTR
4. **DWSALESFACT**
- **Primary & Foreign Keys (PK, FK):**
- TM_ID (FK2)
- CUS_CODE (FK1)
- P_CODE (FK3)
- **Attributes:**
- SALE_UNITS
- SALE_PRICE
5. **DWVENDOR**
- **Primary Key (PK):** V_CODE
- **Attributes:**
- V_NAME
- V_AREACODE
- V_STATE
6. **DWPRODUCT**
- **Primary Key (PK):** P_CODE
- **Attributes:**
- P_DESCRIPT
- P_CATEGORY
- V_CODE
- **Foreign Key (FK1):** V_CODE links to DWVENDOR
**Explanation:**
- The schema consists of several tables, each representing a different dimension or fact related to sales.
- **DWREGION** and **DWCUSTOMER** are linked through the REG_ID attribute, indicating a relationship between the customer data and regional data.
- **DWSALESFACT** serves as a fact table, connecting **DWTIME**, **DWCUSTOMER**, and **DWPRODUCT** to provide detailed sales data.
- **DWPRODUCT** is linked to **DWVENDOR** through the V_CODE.
- Each table has attributes that provide specific details relevant to its

Transcribed Image Text:### Data Table Explanation
The table represents sales data with three columns: `REG_ID`, `CUS_CODE`, and `TOTSALES`.
#### Columns:
1. **REG_ID**: This stands for the region identifier. It indicates the specific region associated with each sales entry.
2. **CUS_CODE**: This is the customer code, providing a unique identifier for each customer.
3. **TOTSALES**: This column displays the total sales amount for each record, measured in monetary units.
#### Observations:
- The table includes several rows where `CUS_CODE` or `REG_ID` is `NULL`, denoting missing data for those fields.
- The row highlighted in red draws attention, potentially indicating a specific point of interest or anomaly.
- The note on the side, "Some records omitted in output shown," suggests that not all data entries are displayed in the current view.
This table can be used for analyzing sales distribution across different regions and customers, helping to identify trends and areas for strategic adjustments.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- What are the steps for changing a table's structure in SQL? Which of these important shifts should be taken into account? To put these changes into effect, what commands must be executed?arrow_forwardIn what scenarios can the UNPIVOT function be beneficial for data transformations in SQL?arrow_forwardQUICK SQL REQUEST (beginner level...) Back at work on Monday morning, the Vice President of Purchasing asks you to help him with the analysis of in-process storage. He asks you to pull information regarding the number of products per storage location. The result of the query should show: - The name of the warehouse (Location) - The number of different products per storage location - The total quantity of products found at this storage location - The average price of all products found at this storage location He mentions that for the moment he is only interested in the locations that have more than 50 distinct products because he wants to start inventorying the biggest locations first. Show the locations in order of smallest to largest number of distinct products. My request is linked to the question but i'm having trouble executing it I would love to know how to do it, thanks in advance.arrow_forward
- Using the relations in the appendix, write the following queries in SQL:i. Display a list of all instructors, showing each instructor’s ID and the number of sections taught. Your query should use an outer join, and should not use sub-queries.ii. Write the same query as in part a, but using a scalar subquery and not using outer join.iii. Display the list of all course sections offered in spring 2018, along with the ID and name of each instructor teaching the section. If a section has more than one instructor, that section should appear as many times in the result as it has instructors. If a section does not have any instructor, it should still appear in the result with the instructor name set to “—”.iv. Display the list of all departments, with the total number of instructors in each department, without using sub-queries. Make sure to show departments that have no instructors, and list those departments with an instructor count of zero.arrow_forwardHow do you ensure that user-defined functions in SQL maintain data consistency?arrow_forwardA pipe allows you to... ...send the same input to multiple commands. ...type multiple commands at one prompt. ...send the output of a command to a file. ...send the output of one command to another.arrow_forward
- These are queries that use the full Red Cat Database as shown in Figure 3.1. To do these queries you cannot use the SimplifiedSales database. You must use the full Red Cat tables of Customer, Sale, SaleItem, Product, Manufacturer, and Employee tables. For each information request below, formulate a single SQL query to produce the required information. In each case, you should display only the columns requested. Be sure that your queries do not produce duplicate records unless otherwise directed. List the information in the SaleItem table concerning green sneakers. Use the first letter of each table name as alias names. (Note: Colors are capitalized while categories are not. ) Note: Your answer should dynamically include all current columns in the saleItem table and any future changes to columns.arrow_forwardUse the Pine Valley Furniture (PVF) database for this question. Write a SQL query to display the customer ID and total number of orders placed for those customers who placed more than one order.arrow_forwarduse sql to answer the following question To perform below tasks, refer to tables in the JustLee Book database. Create a list that display the title of each book and the name and phone number of the contact at the publisher’s office for reordering each book. Which books were written by an author with the Last Name-First Name (BAKER JACK)? Perform the search using author’s last name/first name. Determine which book(s) purchased by customer Steve Schell. Perform the search using the customer name & last name, not the customer number. If he/she has purchased multiple copies of the same book, unduplicated(DISCTINC) the result.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education