Question: MySQL: I have a database set up, but I have no idea what my professor expects me to do with this question: Create 5 queries

MySQL: I have a database set up, but I have no idea what my professor expects me to do with this question: Create 5 queries that pull data from your database. Make sure to include calculated fields and joins in your queries.

Attached is the plain text version of my database (very small). Will link to the sql file as well: https://www.dropbox.com/s/j91g0ot0w5cigeq/Database%20v3.sql?dl=0

DROP DATABASE IF EXISTS my_restaurant;

CREATE DATABASE my_restaurant;

USE my_restaurant;

CREATE TABLE categories(

category_id INT PRIMARY KEY AUTO_INCREMENT,

category_name VARCHAR(255) NOT NULL

);

CREATE TABLE suppliers(

supplier_id INT PRIMARY KEY AUTO_INCREMENT,

category_id INT,

supplier_name VARCHAR(255) NOT NULL,

supplier_contact VARCHAR(255),

supplier_address VARCHAR(255) NOT NULL,

supplier_phone_number VARCHAR(12) NOT NULL,

supplier_contract_date VARCHAR(255),

CONSTRAINT supplier_fk_category

FOREIGN KEY(category_id)

REFERENCES categories(category_id)

);

CREATE TABLE invoices(

invoice_id INT PRIMARY KEY AUTO_INCREMENT,

category_id INT NOT NULL,

supplier_id INT NOT NULL,

invoice_due_date VARCHAR(255),

invoice_supplier VARCHAR(255) NOT NULL,

invoice_contact VARCHAR(255) NOT NULL,

invoice_amount INT,

invoice_paid BOOL,

CONSTRAINT invoice_fk_supplier

FOREIGN KEY(supplier_id)

REFERENCES suppliers(supplier_id),

CONSTRAINT invoice_fk_category

FOREIGN KEY(category_id)

REFERENCES categories(category_id)

);

CREATE TABLE member_rewards(

member_id INT PRIMARY KEY AUTO_INCREMENT,

category_id INT,

member_fname VARCHAR(255) NOT NULL,

member_lname VARCHAR(255) NOT NULL,

member_birthday VARCHAR(255) NOT NULL,

member_phone_number VARCHAR(12),

member_points INT DEFAULT 0,

CONSTRAINT member_fk_category

FOREIGN KEY(category_id)

REFERENCES categories(category_id)

);

CREATE TABLE employees(

employee_id INT PRIMARY KEY AUTO_INCREMENT,

employee_fname VARCHAR(255),

employee_lname VARCHAR(255),

employee_start_pay INT NOT NULL,

employee_current_pay INT NOT NULL,

employee_start_date VARCHAR(255),

employee_referrals VARCHAR(50),

member_id INT DEFAULT NULL,

CONSTRAINT employees_fk_member

FOREIGN KEY(member_id)

REFERENCES member_rewards(member_id)

);

INSERT INTO categories(category_id, category_name) VALUES

(1, 'suppliers'),

(2, 'invoices'),

(3, 'member_rewards'),

(4, 'employees'),

(5, 'TBA');

INSERT INTO suppliers(supplier_id, category_id, supplier_name, supplier_contact, supplier_address, supplier_phone_number, supplier_contract_date) VALUES

(1, 1, "Pepsi", 'James Hatfield', '500 Pepsi Way, Raleigh, NC 23089', '800-897-7905', '08-09-2016'),

(2, 2, "Ragu", 'Mike Richards', '101 Pasta Drive, Hallifax, VA 15390', '800-745-3421', '08-09-2016'),

(3, 3, "Miguel's Produce", 'Miguel Profesa', '457 Main Street, Brooklyn, NY 93048', '847-234-9823', '08-09-2016'),

(4, 4, "Butch's Butcher Shop", 'Rick Santana', '66 Chopper Way, Yonkers, NY 93024', '347-234-5634', '08-09-2016'),

(5, 5, "Cafe Carmen", 'Carmen San Diego', '1234 Hoops Avenue, Upper East Side, NY 92041', '358-413-7312', '08-09-2016');

INSERT INTO invoices(category_id, supplier_id, invoice_supplier, invoice_due_date, invoice_contact, invoice_amount, invoice_paid) VALUES

(2, 1, "Pepsi", '12-24-2017', 'James Hatfield', 23500, FALSE),

(2, 2, "Ragu", '12-20-2017', 'Mike Richards', 8650, FALSE),

(2, 3, "Miguel's Produce", '12-18-2017', 'Miguel Profesa', 6750, FALSE),

(2, 4, "Butch's Butcher Shop", '12-15-2017', 'Rick Santana', 9550, FALSE),

(2, 5, "Cafe Carmen", '12-04-2017', 'Carmen San Diego', 1250, FALSE);

INSERT INTO member_rewards(category_id, member_fname, member_lname, member_birthday, member_phone_number, member_points) VALUES

(3, 'John', 'Smith', '03-31-1975', '401-234-3194', 500),

(3, 'Karen', 'Smith', '05-12-1948', '413-233-4956', 35),

(3, 'Mike', 'Lawrence', '09-13-1985', '508-234-0923', 215),

(3, 'Judd', 'Hurst', '12-24-1999', NULL, 0),

(3, 'Amy', 'Michaels', '01-23-1994', '978-234-8403', 1350);

INSERT INTO employees(employee_fname, employee_lname, employee_start_date, employee_start_pay, employee_current_pay, employee_referrals) VALUES

('Will', 'Smith', '09-30-2014', 14.00, 17.25, 'None'),

('Bill', 'Larson', '09-30-2014', 14.00, 17.25, 'None'),

('Phil', 'Parson', '09-30-2014', 14.00, 17.25, 'None'),

('Jill', 'Donalley', '09-30-2014', 14.00, 17.25, 'None'),

('Dill', 'Roberts', '09-30-2014', 14.00, 17.25, 'None');

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!