Answered step by step
Verified Expert Solution
Question
1 Approved Answer
/ * * * * * * * * * * * * * * * * * * * * * * * *
This script creates the database named myguitarshop
DROP DATABASE IF EXISTS myguitarshop;
CREATE DATABASE myguitarshop;
USE myguitarshop;
create the tables for the database
CREATE TABLE categories
categoryid INT PRIMARY KEY AUTOINCREMENT,
categoryname VARCHAR NOT NULL UNIQUE
;
CREATE TABLE products
productid INT PRIMARY KEY AUTOINCREMENT,
categoryid INT NOT NULL,
productcode VARCHAR NOT NULL UNIQUE,
productname VARCHAR NOT NULL,
description TEXT NOT NULL,
listprice DECIMAL NOT NULL,
discountpercent DECIMAL NOT NULL DEFAULT
dateadded DATETIME DEFAULT NULL,
CONSTRAINT productsfkcategories
FOREIGN KEY categoryid
REFERENCES categories categoryid
;
CREATE TABLE customers
customerid INT PRIMARY KEY AUTOINCREMENT,
emailaddress VARCHAR NOT NULL UNIQUE,
password VARCHAR NOT NULL,
firstname VARCHAR NOT NULL,
lastname VARCHAR NOT NULL,
shippingaddressid INT DEFAULT NULL,
billingaddressid INT DEFAULT NULL
;
CREATE TABLE addresses
addressid INT PRIMARY KEY AUTOINCREMENT,
customerid INT NOT NULL,
line VARCHAR NOT NULL,
line VARCHAR DEFAULT NULL,
city VARCHAR NOT NULL,
state VARCHAR NOT NULL,
zipcode VARCHAR NOT NULL,
phone VARCHAR NOT NULL,
disabled TINYINT NOT NULL DEFAULT
CONSTRAINT addressesfkcustomers
FOREIGN KEY customerid
REFERENCES customers customerid
;
CREATE TABLE orders
orderid INT PRIMARY KEY AUTOINCREMENT,
customerid INT NOT NULL,
orderdate DATETIME NOT NULL,
shipamount DECIMAL NOT NULL,
taxamount DECIMAL NOT NULL,
shipdate DATETIME DEFAULT NULL,
shipaddressid INT NOT NULL,
cardtype VARCHAR NOT NULL,
cardnumber CHAR NOT NULL,
cardexpires CHAR NOT NULL,
billingaddressid INT NOT NULL,
CONSTRAINT ordersfkcustomers
FOREIGN KEY customerid
REFERENCES customers customerid
;
CREATE TABLE orderitems
itemid INT PRIMARY KEY AUTOINCREMENT,
orderid INT NOT NULL,
productid INT NOT NULL,
itemprice DECIMAL NOT NULL,
discountamount DECIMAL NOT NULL,
quantity INT NOT NULL,
CONSTRAINT itemsfkorders
FOREIGN KEY orderid
REFERENCES orders orderid
CONSTRAINT itemsfkproducts
FOREIGN KEY productid
REFERENCES products productid
;
CREATE TABLE administrators
adminid INT PRIMARY KEY AUTOINCREMENT,
emailaddress VARCHAR NOT NULL,
password VARCHAR NOT NULL,
firstname VARCHAR NOT NULL,
lastname VARCHAR NOT NULL
;
Insert data into the tables
INSERT INTO categories categoryid categoryname VALUES
'Guitars'
'Basses'
'Drums'
'Keyboards';
INSERT INTO products productid categoryid productcode, productname, description, listprice, discountpercent, dateadded VALUES
'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 sstyle logo Includes select alder body, fret maple neck with your choice of a rosewood or maple fretboard, singlecoil pickups, vintagestyle tremolo, and diecast 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 blockr
ply parchment pick guardr
Tinted neck', ::
'lespaul', 'Gibson Les Paul', 'This Les Paul guitar offers a carved top and humbucking pickups. It has a simple yet elegant design. Cuttingyetrich tone?the hallmark of the Les Paul?pours out of the R and T 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started