The Queen Anne Curiosity Shop Project Questions (p.236) - Excerpted The Queen Anne Curiosity Shop PROJECT QUESTIONS (p.236) - Excerpted The Queen Anne Curiosity Shop PROJECT QUESTIONS (p.236) - Excerpted The Queen Anne Curiosity Shop SELLING ANTIQUES AND CURRENT-PRODUCTION HOUSEHOLD ITEMS
TO DIVERSE CUSTOMERS
The Queen Anne Curiosity Shop Project Questions (p.236) - Excerpted The Queen Anne Curiosity Shop
The Queen Anne Curiosity Shop sells both antiques and current-production household items that complement or are useful with the antiques. For example, the store sells antique dining room tables and new tablecloths. The antiques are purchased from both individuals and wholesalers, and the new items are purchased from distributors. The store’s customers include individuals, owners of bed-and-breakfast operations, and local interior designers who work with both individuals and small businesses. The antiques are unique, although some multiple items, such as dining room chairs, may be available as a set (sets are never broken).
The new items are not unique, and an item may be reordered if it is out of stock. New items are also available in various sizes and colors (for example, a particular style of tablecloth may be available in several sizes and in a variety of colors). Read each question stated below and write SQL statements for this database as follows: Find tables in page 237, 238 and 239. Write SQL CREATE TABLE and SQL INSERT statements data for:
SQL statements for Table 1 (p. 237) – QACS CUSTOMER
SQL statements for Table 2 (p. 238) – QACS EMPLOYEE
SQL statement for Table 3 (p. 240) – QACS ITEM
SQL statement for Table 4 (p. 241) – QACS SALE
2. Write SQL statements to list all columns for all tables.
3. Write an SQL statement to list ItemID and ItemDescription for all items that cost $1000 or more.
4. Write an SQL statement to list LastName, FirstName, and Phone of the customer who made the purchase with SaleID 1. Use a subquery.
5. Write an SQL statement to list LastName, FirstName, and Phone of the customers who made the purchase with SaleIDs 1, 2, and 3. Use a subquery.
6. Write an SQL statement to list LastName, FirstName, and Phone of customers who have made at least one purchase with SubTotal greater than $500. Use a subquery.
7. Write an SQL statement to list LastName, FirstName, and Phone of customers who have purchased an item that has an ItemPrice of $500 or more. Use a subquery.
8. Write SQL CREATE TABLE statement for table VENDOR (p. 239) and insert the data (the first three rows only) into the VENDOR table.
9. Write an SQL statement to modify the vendor with CompanyName of Linens and Things to Linens and Other Stuff.
Paper For Above instruction
This paper addresses the comprehensive database design and querying requirements for the Queen Anne Curiosity Shop, which sells antiques and current-production household items to a diverse customer base. The goal is to create a structured relational database, populate it with sample data, and formulate SQL queries to retrieve specific information based on given criteria. This process involves defining tables, inserting data, and writing SQL queries for data retrieval and manipulation, emphasizing understanding of SQL syntax, subqueries, and data relationships.
Database Tables Creation and Data Insertion
The first step involves designing and creating four primary tables: CUSTOMER, EMPLOYEE, ITEM, and SALE, based on the provided page references and descriptions. The CUSTOMER table stores information about shoppers, including their names, contact details, and customer type. The EMPLOYEE table records employee details such as names and hire dates. The ITEM table catalogs both antiques and new items, including descriptions, prices, sizes, and colors. The SALE table records sales transactions, linking customers, employees, and items with transaction details like date and subtotal.
The CREATE TABLE statements are crafted to include appropriate data types and primary keys, ensuring data integrity and efficient querying. Sample INSERT statements populate these tables with realistic data, including diverse customer and employee records, descriptive items, and sales transactions. This setup forms the foundation for executing advanced SQL queries to analyze sales, customer behavior, and inventory details.
Listing All Columns of All Tables
A simple SQL query, such as SELECT * FROM , retrieves all columns from each table, affording a complete view of the database structure and data.
Queries for Specific Data Retrieval
Query to list ItemID and ItemDescription for items costing $1000 or more:
SELECT ItemID, ItemDescription FROM ITEM
WHERE ItemPrice >= 1000;
Query to find contact details of the customer who made the sale with SaleID 1:
SELECT LastName, FirstName, Phone FROM CUSTOMER
WHERE CustomerID = (
SELECT CustomerID FROM SALE
WHERE SaleID = 1
);
Query to find contact details of customers with SalesID 1, 2, or 3:
SELECT LastName, FirstName, Phone FROM CUSTOMER
WHERE CustomerID IN ( SELECT CustomerID FROM SALE
WHERE SaleID IN (1, 2, 3) );
Query to list customers with at least one sale subtotal greater than $500:
SELECT LastName, FirstName, Phone FROM CUSTOMER
WHERE CustomerID IN ( SELECT CustomerID FROM SALE
WHERE SubTotal > 500
);
Query to list customers who purchased items priced at $500 or more:
SELECT LastName, FirstName, Phone FROM CUSTOMER
WHERE CustomerID IN ( SELECT SALE.CustomerID FROM SALE
JOIN ITEM ON SALE.ItemID = ITEM.ItemID
WHERE ITEM.ItemPrice >= 500
);
Vendor Table Creation and Update
The VENDOR table is created with relevant fields, and initial data is inserted for the first three vendors. To update a specific vendor’s name, an UPDATE statement modifies the CompanyName where the current name matches "Linens and Things" to "Linen and Other Stuff".
Conclusion
This comprehensive approach ensures a well-structured database that supports complex queries and data analysis for the Queen Anne Curiosity Shop. Proper table design, data insertion, and SQL querying enable
efficient inventory management, sales analysis, and customer relationship handling, vital for business insights and decision-making.
References
Elmasri, R., & Navathe, S. B. (2015). Database Systems (6th ed.). Pearson.