Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm having a lot of trouble with this one sql question and need some help. My prof was helpful but i need some more insight

I'm having a lot of trouble with this one sql question and need some help. My prof was helpful but i need some more insight then I got. Half the schema is listed below for the database my_guitar_shop i will list the other half in aother post. I need a explanation along with the answer please. Thank you!!!

image text in transcribed

/******************************************************** * This script creates the database named my_guitar_shop *********************************************************/ DROP DATABASE IF EXISTS my_guitar_shop; CREATE DATABASE my_guitar_shop; USE my_guitar_shop; -- create the tables for the database CREATE TABLE categories ( category_id INT PRIMARY KEY AUTO_INCREMENT, category_name VARCHAR(255) NOT NULL UNIQUE ); CREATE TABLE products ( product_id INT PRIMARY KEY AUTO_INCREMENT, category_id INT NOT NULL, product_code VARCHAR(10) NOT NULL UNIQUE, product_name VARCHAR(255) NOT NULL, description TEXT NOT NULL, list_price DECIMAL(10,2) NOT NULL, discount_percent DECIMAL(10,2) NOT NULL DEFAULT 0.00, date_added DATETIME DEFAULT NULL, CONSTRAINT products_fk_categories FOREIGN KEY (category_id) REFERENCES categories (category_id) ); CREATE TABLE customers ( customer_id INT PRIMARY KEY AUTO_INCREMENT, email_address VARCHAR(255) NOT NULL UNIQUE, password VARCHAR(60) NOT NULL, first_name VARCHAR(60) NOT NULL, last_name VARCHAR(60) NOT NULL, shipping_address_id INT DEFAULT NULL, billing_address_id INT DEFAULT NULL ); CREATE TABLE addresses ( address_id INT PRIMARY KEY AUTO_INCREMENT, customer_id INT NOT NULL, line1 VARCHAR(60) NOT NULL, line2 VARCHAR(60) DEFAULT NULL, city VARCHAR(40) NOT NULL, state VARCHAR(2) NOT NULL, zip_code VARCHAR(10) NOT NULL, phone VARCHAR(12) NOT NULL, disabled TINYINT(1) NOT NULL DEFAULT 0, CONSTRAINT addresses_fk_customers FOREIGN KEY (customer_id) REFERENCES customers (customer_id) ); CREATE TABLE orders ( order_id INT PRIMARY KEY AUTO_INCREMENT, customer_id INT NOT NULL, order_date DATETIME NOT NULL, ship_amount DECIMAL(10,2) NOT NULL, tax_amount DECIMAL(10,2) NOT NULL, ship_date DATETIME DEFAULT NULL, ship_address_id INT NOT NULL, card_type VARCHAR(50) NOT NULL, card_number CHAR(16) NOT NULL, card_expires CHAR(7) NOT NULL, billing_address_id INT NOT NULL, CONSTRAINT orders_fk_customers FOREIGN KEY (customer_id) REFERENCES customers (customer_id) ); CREATE TABLE order_items ( item_id INT PRIMARY KEY AUTO_INCREMENT, order_id INT NOT NULL, product_id INT NOT NULL, item_price DECIMAL(10,2) NOT NULL, discount_amount DECIMAL(10,2) NOT NULL, quantity INT NOT NULL, CONSTRAINT items_fk_orders FOREIGN KEY (order_id) REFERENCES orders (order_id), CONSTRAINT items_fk_products FOREIGN KEY (product_id) REFERENCES products (product_id) ); CREATE TABLE administrators ( admin_id INT PRIMARY KEY AUTO_INCREMENT, email_address VARCHAR(255) NOT NULL, password VARCHAR(255) NOT NULL, first_name VARCHAR(255) NOT NULL, last_name VARCHAR(255) NOT NULL ); -- Insert data into the tables INSERT INTO categories (category_id, category_name) VALUES (1, 'Guitars'), (2, 'Basses'), (3, 'Drums'), (4, 'Keyboards'); INSERT INTO products (product_id, category_id, product_code, product_name, description, list_price, discount_percent, date_added) VALUES (1, 1, 'strat', 'Fender Stratocaster', 'The Fender Stratocaster is the electric guitar design that changed the world. New features include a tinted neck, parchment pickguard and control knobs, and a ''70s-style logo. Includes select alder body, 21-fret maple neck with your choice of a rosewood or maple fretboard, 3 single-coil pickups, vintage-style tremolo, and die-cast tuning keys. This guitar features a thicker bridge block for increased sustain and a more stable point of contact with the strings. At this low price, why play anything but the real thing? Features: * New features: * Thicker bridge block * 3-ply parchment pick guard * Tinted neck', '699.00', '30.00', '2011-10-30 09:32:40'), (2, 1, 'les_paul', 'Gibson Les Paul', 'This Les Paul guitar offers a carved top and humbucking pickups. It has a simple yet elegant design. Cutting-yet-rich tone?the hallmark of the Les Paul?pours out of the 490R and 498T Alnico II magnet humbucker pickups, which are mounted on a carved maple top with a mahogany back. The faded finish models are equipped with BurstBucker Pro pickups and a mahogany top. This guitar includes a Gibson hardshell case (Faded and satin finish models come with a gig bag) and a limited lifetime warranty. Features: * Carved maple top and mahogany back (Mahogany top on faded finish models) * Mahogany neck, ''59 Rounded Les Paul * Rosewood fingerboard (Ebony on Alpine white) * Tune-O-Matic bridge with stopbar * Chrome or gold hardware * 490R and 498T Alnico 2 magnet humbucker pickups (BurstBucker Pro on faded finish models) * 2 volume and 2 tone knobs, 3-way switch', '1199.00', '30.00', '2011-12-05 16:33:13'), (3, 1, 'sg', 'Gibson SG',

Write a SQL query that satisfies the requirements below. Requirements - Use the database my_guitar_shop. - Write a SELECT statement that joins the customers table to the order_items table to the products table - Use explicit inner join syntax. - Do not use table aliases. - Return a resultset that matches the results shown below. Results

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

How To Build A Million Dollar Database

Authors: Michelle Bergquist

1st Edition

0615246842, 978-0615246840

More Books

Students also viewed these Databases questions

Question

Is the following compound optically active? Br H/CI CI'H Br

Answered: 1 week ago