Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

/ * * * * * * * * * * * * * * * * * * * * * * * *

/********************************************************
* 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?\r
\r
Features:\r
\r
* New features:\r
* Thicker bridge block\r
*3-ply parchment pick guard\r
* Tinted neck', '699.00','30.00','2014-10-3009: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 hardshe

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

Power Bi And Azure Integrating Cloud Analytics For Scalable Solutions

Authors: Kiet Huynh

1st Edition

B0CMHKB85L, 979-8868959943

More Books

Students also viewed these Databases questions