CoolTunes Media 1. See comments in the report 2. Grade: 74/80 Alex Herreid Austin Carrillo Collin Parker Will Greenburg BMIS441 Fall 2012 - Group 1 Alex Herreid Collin Parker Austin Carrillo Will Greenburg CoolTunes Media Scenario: For our term project, we will be creating a database for a company called CoolTunes Media. The business is similar to that of an online record store, like iTunes or Spotify. We chose to tackle a music company because it is something that we all use regularly and we wanted to better understand the back end of an application like this. I. Planning: Our company is more of an Indie based company to try to differentiate us from more of the mainstream music distribution companies. With a focus more on these smaller artists, we will hopefully be the company people look to so they can find the next “hit” artist. We will start in the Seattle area and then work our way down the west coast into California eventually. Since our artists aren’t as mainstream as most of the songs on iTunes we are able to save on costs and offer these songs at a lower price than iTunes is able to. You can choose to purchase downloadable content or a physical album to be shipped to the customer. Our goal is to create a simple but well organized database that can hold all of the information necessary to record the purchases and purchasing history or our customers as well as the data about them. We also need to record information about our artists and the label that they have. II. Analysis: Now we will discuss the different entities in our database. This is necessary to understand the basis of our database before displaying the diagram of the relationships The CUSTOMER table will hold the basic information for our customers. The attributes will be Customer#, LastName, FirstName, and Email. The Customer# attribute will be the primary key and a unique number for each customer. This is just the baseline data about our customers, the rest of their information will be included in other entities. The BILLINGINFO table will include Customer#, Address, City, State, Zip, and CardType. The customer# attribute will be a foreign key in the table linking to the CUSTOMERS table. This will also include their billing information in case it is different from their shipping information. 1 The SHIPPINGINFO table will include their Customer#, Address, City, State, and Zip Code. This entity is very similar to the BILLINGINFO table in that it is essentially just used to hold their information with the Customer# as a reference. This table allows us not only to have our customers purchase downloadable content but also the physical albums. The ORDERS table will include Order#, Customer#, OrderDate, OrderType, and ShipDate. This will keep track of which orders our customers have placed and when. Because our customers can purchase both physical and digital copies of our songs we need the OrderType attribute to indicate which one it is. If the OrderType is digital then the ShipDate will be NULL. This will help us with keeping track of how often they purchase as well as other things. With this information we can dive deeper to really keep track on the purchasing patterns of our customers. In this entity Order# will be the primary key and customer# will be the foreign key. The ORDERITEMS table will only have one purpose, which is to have a detailed list of what exactly customers have purchased in each of their orders. We will also be able to have a record of what a customer was supposed to receive if there is ever a time were an order is lost or damaged in the shipping process. The PRODUCTS table keeps track of each product, a product can be a either a song or an album. Item_ID will be the primary key for this entity. The rest of the attributes in this entity will be Artist_ID, title, ItemType, Price, and Track_Qty. Artist_ID is a foreign key from the ARTISTS table that we will discuss next. ItemType will specify whether the product is an individual song or a whole album. The ARTISTS table will include Artist_ID, ArtistName, Genere, and Label_ID. Artist_ID is the primary key for this table and Label_ID is a foreign key. This would just be recording basic information about the artists that will be pulled from when people are search for music from our company. The LABELS table will mainly be used for internal company purposes; it will include Label_ID, LabelName, ContactName, and ContactEmail. This will list the information for our company contacts at the various labels we are in business with. This will mainly be for communicating any issues with tracks that they have released to us and other administrative issues. With the way we have it organized there are many possibilities of what we can do with it. We think we have planned for a system that will work effectively and have been able to foresee at least the majority of issues that we might eventually run into. III. Design: In the design phase we have created eight different tables that we have just discussed. There are many queries we can design that would produce useful information to help both our customers and everyone else we work with. This will help our business running smoothly and hopefully help us save a lot of rework that may be caused by a less well organized database. 2 Relations Diagram (Original) Customer Billing Info: Customer# Address City State Zip CardType Customer Shipping Info: Customer# Address City State Zip Customer Info: Customer# LastName FirstName Email Orders Table: Order# Customer# OrderDate OrderType ShipDate Order Items: Order# Item_ID Products: Item_ID Artist_ID Title ItemType Price Track_Qty Artists: Artist_ID ArtistName Genre Label_ID LabelName ContactName ContactEmail Labels: Label_ID 3 Relations Diagram (Revised with Normalization) 4 NRT Dependency Diagram Customers Customer# You need to illustrate the process of “Normalization” and they are all in 3 NF LastName FirstName Email Customer# OrderDate OrderType ShipDate Address City State Zip Address City State Zip Artist_ID Title ItemType Price ArtistName Genre Label_ID LabelName ContactName ContactEmail Orders Order# BillingInfo Customer# CardType ShippingInfo Customer# OrderItems Order# Item_Id Products Item_ID Artists Artist_ID Labels Label_ID 5 Track_Qty IV. Implementation: We will now display the code that we have developed for our database, first we will show the table creation code and then the functional queries. Table creation: We have posted our code below. Because of the dependencies, we had to enter the tables in the following order: LABELS, ARTISTS, PRODUCTS, CUSTOMERS, BILLINGINFO, SHIPPINGINFO, ORDERS, ORDERITEMS. Some of these could be switched because it might not matter which one was entered first but this is the way we have decided to enter it into our database. DROP DROP DROP DROP DROP DROP DROP DROP DROP TABLE BILLINGINFO CASCADE CONSTRAINTS; TABLE CUSTOMERS CASCADE CONSTRAINTS; TABLE SHIPPINGINFO CASCADE CONSTRAINTS; TABLE ORDERS CASCADE CONSTRAINTS; TABLE ORDERITEMS CASCADE CONSTRAINTS; TABLE PRODUCTS CASCADE CONSTRAINTS; TABLE ARTISTS CASCADE CONSTRAINTS; TABLE LABELS CASCADE CONSTRAINTS; SEQUENCE orders_order#_seq; CREATE TABLE LABELS (LABEL_ID NUMBER(4), LABELNAME VARCHAR2(40), CONTACTNAME VARCHAR2(25) NOT NULL, CONTACTEMAIL VARCHAR2(40), CONSTRAINT LABELS_LABEL_ID_PK PRIMARY KEY(LABEL_ID)); INSERT INTO LABELS VALUES(8000,'Island Records', 'Jack Oliver', 'jack@islandrecords.com'); INSERT INTO LABELS VALUES(8001,'RCA Music', 'Eva Green', 'E_Green@RCAMusic.com'); INSERT INTO LABELS VALUES(8002,'Sony Music', 'Tony Stark', 'T.Stark@Sonymusic.com'); INSERT INTO LABELS VALUES(8003,'Warner Brothers Group', 'Bradley Johnson', 'Johnson.Bradley@WarnerBrothers.com'); INSERT INTO LABELS VALUES(8004,'Sub Pop Records', 'Frank Reynolds', 'Frank.Reynolds@SubPop.com'); INSERT INTO LABELS VALUES(8005,'Sin City Music', 'Edward Jetson', 'J_Edward@SinCity.com'); 6 CREATE TABLE ARTISTS (ARTIST_ID NUMBER(4), LABEL_ID NUMBER(4) NOT NULL, ARTISTNAME VARCHAR2(30), GENRE VARCHAR2(15), CONSTRAINT ARTISTS_ARTIST_ID_PK PRIMARY KEY(ARTIST_ID), CONSTRAINT ARTISTS_LABEL_ID_FK FOREIGN KEY (LABEL_ID) REFERENCES LABELS (LABEL_ID)); INSERT INTO ARTISTS VALUES(6000, 8004, 'Pink', 'Pop'); INSERT INTO ARTISTS VALUES(6001, 8004, 'Johan Flozart', 'Classical'); INSERT INTO ARTISTS VALUES(6002, 8005, 'Rihanna', 'Pop'); INSERT INTO ARTISTS VALUES(6003, 8005, 'Avicii', 'Electronic'); INSERT INTO ARTISTS VALUES(6004, 8000, 'Muse', 'Rock'); INSERT INTO ARTISTS VALUES(6005, 8002, 'Katy Perry', 'Pop'); INSERT INTO ARTISTS VALUES(6006, 8000, 'Spice Girls', 'Pop'); INSERT INTO ARTISTS VALUES(6007, 8002, 'The Eagles', 'Death Metal'); INSERT INTO ARTISTS VALUES(6008, 8001, 'Led Zeppelin', 'Rock'); INSERT INTO ARTISTS VALUES(6009, 8003, 'Swag', 'Classical'); INSERT INTO ARTISTS VALUES(6010, 8001, 'Dillon Francis', 'Electronic'); INSERT INTO ARTISTS VALUES(6011, 8003, 'The Bone Heads', 'Rock'); CREATE TABLE PRODUCTS (ITEM_ID NUMBER(4), ARTIST_ID NUMBER(4), TITLE VARCHAR2(50) NOT NULL, ITEMTYPE CHAR(2) NOT NULL, PRICE NUMBER(5,2) NOT NULL, TRACK_QTY NUMBER(2), CONSTRAINT PRODUCTS_ITEM_ID_PK PRIMARY KEY(ITEM_ID), CONSTRAINT PRODUCTS_ARTIST_ID_FK FOREIGN KEY (ARTIST_ID) REFERENCES ARTISTS (ARTIST_ID), CONSTRAINT PRODUCTS_ITEMTYPE_CK CHECK (ITEMTYPE IN ('A','S'))); INSERT INTO PRODUCTS VALUES(3000, 6000, 'This Is Real Life', 'A', 10.99, 13); INSERT INTO PRODUCTS VALUES(3001, 6000, 'Vote Or Die', 'A', 8.99, 16); 7 INSERT INTO PRODUCTS VALUES(3002, 6000, 'The Whole Shabang', 'A', 10.99, 13); INSERT INTO PRODUCTS VALUES(3003, 6000, 'This Is Real Life Vol. 2', 'A', 13.99, 12); INSERT INTO PRODUCTS VALUES(3004, 6001, 'Shadows', 'A', 15.99, 7); INSERT INTO PRODUCTS VALUES(3005, 6001, 'Nature', 'A', 15.99, 8); INSERT INTO PRODUCTS VALUES(3006, 6001, 'Volcano', 'A', 15.99, 8); INSERT INTO PRODUCTS VALUES(3007, 6002, 'Back To Back', 'A', 11.99, 13); INSERT INTO PRODUCTS VALUES(3008, 6002, 'Yes, Yes, Yes', 'A', 11.99, 14); INSERT INTO PRODUCTS VALUES(3009, 6003, 'Sequel', 'A', 10.99, 12); INSERT INTO PRODUCTS VALUES(3010, 6003, 'Prequel', 'A', 10.99, 12); INSERT INTO PRODUCTS VALUES(3011, 6004, 'Showbiz', 'A', 12.99, 14); INSERT INTO PRODUCTS VALUES(3012, 6004, 'Origin Of Symmetry', 'A', 12.99, 11); INSERT INTO PRODUCTS VALUES(3013, 6004, 'Absolution', 'A', 12.99, 13); INSERT INTO PRODUCTS VALUES(3015, 6005, 'Hey There', 'A', 9.99, 10); INSERT INTO PRODUCTS VALUES(3016, 6005, 'Ball So Hard', 'A', 11.99, 16); INSERT INTO PRODUCTS VALUES(3017, 6005, 'Ecstasy', 'A', 11.99, 12); INSERT INTO PRODUCTS VALUES(3018, 6005, 'Essentially', 'A', 12.99, 12); INSERT INTO PRODUCTS VALUES(3019, 6006, 'Spice World', 'A', 8.99, 13); INSERT INTO PRODUCTS VALUES(3020, 6006, 'Man Oh Man', 'A', 7.99, 13); INSERT INTO PRODUCTS VALUES(3021, 6007, 'Peace and Love', 'A', 11.99, 15); INSERT INTO PRODUCTS VALUES(3022, 6007, 'San Bernardino', 'A', 11.99, 14); INSERT INTO PRODUCTS VALUES(3023, 6007, 'Heart On', 'A', 13.99, 14); INSERT INTO PRODUCTS VALUES(3024, 6008, 'Turkey Police', 'A', 9.99, 18); INSERT INTO PRODUCTS VALUES(3025, 6008, 'Mothership', 'A', 10.99, 14); INSERT INTO PRODUCTS VALUES(3026, 6009, 'Me And Your Sister', 'A', 13.99, 19); INSERT INTO PRODUCTS VALUES(3027, 6009, 'All Up In It', 'A', 13.99, 19); INSERT INTO PRODUCTS 8 VALUES(3028, 6009, 'Worldwide Swag', 'A', 15.99, 19); INSERT INTO PRODUCTS VALUES(3029, 6010, 'Smash It', 'A', 6.99, 10); INSERT INTO PRODUCTS VALUES(3030, 6010, 'Working alone', 'A', 7.99, 10); INSERT INTO PRODUCTS VALUES(3031, 6010, 'Condolences', 'A', 8.99, 10); INSERT INTO PRODUCTS VALUES(3032, 6011, 'Skeletons Everywhere', 'A', 8.99, 13); INSERT INTO PRODUCTS VALUES(3033, 6011, 'Wasabi', 'A', 8.99, 13); INSERT INTO PRODUCTS VALUES(3034, 6000, 'Blow Me One Last Kiss', 'S', 0.99, 1); INSERT INTO PRODUCTS VALUES(3035, 6000, 'Your Mother', 'S', 0.99, 1); INSERT INTO PRODUCTS VALUES(3036, 6001, 'Barney', 'S', 0.99, 1); INSERT INTO PRODUCTS VALUES(3037, 6001, 'Salamanders In Moonlight', 'S', 0.99, 1); INSERT INTO PRODUCTS VALUES(3038, 6002, 'Diamonds', 'S', 0.99, 1); INSERT INTO PRODUCTS VALUES(3039, 6002, 'Pon De Replay', 'S', 0.99, 1); INSERT INTO PRODUCTS VALUES(3040, 6003, 'Levels', 'S', 0.99, 1); INSERT INTO PRODUCTS VALUES(3041, 6003, 'My Feelings For You', 'S', 0.99, 1); INSERT INTO PRODUCTS VALUES(3042, 6004, 'Stockholm Syndrome', 'S', 0.99, 1); INSERT INTO PRODUCTS VALUES(3043, 6004, 'Escape', 'S', 0.99, 1); INSERT INTO PRODUCTS VALUES(3044, 6005, 'Alien Attack', 'S', 0.99, 1); INSERT INTO PRODUCTS VALUES(3045, 6005, 'Over The Hedge', 'S', 0.99, 1); INSERT INTO PRODUCTS VALUES(3046, 6006, 'Spice Up Your Life', 'S', 0.99, 1); INSERT INTO PRODUCTS VALUES(3047, 6006, 'Spice Cube', 'S', 0.99, 1); INSERT INTO PRODUCTS VALUES(3048, 6007, 'Get It On', 'S', 0.99, 1); INSERT INTO PRODUCTS VALUES(3049, 6007, 'Hotel Colorado', 'S', 0.99, 1); INSERT INTO PRODUCTS VALUES(3050, 6008, 'Whole Lotta Love', 'S', 0.99, 1); INSERT INTO PRODUCTS VALUES(3051, 6008, 'Stairway To Heaven', 'S', 0.99, 1); INSERT INTO PRODUCTS VALUES(3052, 6009, 'Nothing But A G Thang', 'S', 0.99, 1); INSERT INTO PRODUCTS VALUES(3053, 6009, 'Pimp Juice', 'S', 0.99, 1); 9 INSERT INTO PRODUCTS VALUES(3054, 6010, 'Sharing Is Caring', 'S', 0.99, 1); INSERT INTO PRODUCTS VALUES(3055, 6010, 'Womp Womp Womp', 'S', 0.99, 1); INSERT INTO PRODUCTS VALUES(3056, 6011, 'Dance Like A Maniac', 'S', 0.99, 1); INSERT INTO PRODUCTS VALUES(3057, 6011, 'Apple Sauce', 'S', 0.99, 1); CREATE TABLE CUSTOMERS (CUSTOMER# NUMBER(4), LASTNAME VARCHAR2(20), FIRSTNAME VARCHAR2(20), EMAIL VARCHAR2(50), CONSTRAINT CUSTOMERS_CUSTOMER#_PK PRIMARY KEY(CUSTOMER#)); INSERT INTO CUSTOMERS VALUES(1000,'Rowe','Sabrina','Rowe@gmail.com'); INSERT INTO CUSTOMERS VALUES(1001,'Theriault','Anita','Theriault@gmail.com'); INSERT INTO CUSTOMERS VALUES(1002,'Laflamme','Travis','Laflamme@gmail.com'); INSERT INTO CUSTOMERS VALUES(1003,'Cushman','Billy','Cushman@msn.com'); INSERT INTO CUSTOMERS VALUES(1004,'Salyer','Brandi','Salyer@comcast.net'); INSERT INTO CUSTOMERS VALUES(1005,'Highsmith','Brian','Highsmith@gmail.com'); INSERT INTO CUSTOMERS VALUES(1006,'Parker','Collin','Parker@gmail.com'); INSERT INTO CUSTOMERS VALUES(1007,'Greenberg','William','Greenberg@hotmail.com'); INSERT INTO CUSTOMERS VALUES(1008,'Herreid','Alexander','Herreid@yahoo.com'); INSERT INTO CUSTOMERS VALUES(1009,'Mounts','Katrina','Mounts@msn.com'); INSERT INTO CUSTOMERS VALUES(1010,'Resnick','Janie','Resnick@gmail.com'); INSERT INTO CUSTOMERS VALUES(1011,'Ojeda','Ronald','Ojeda@msn.com'); INSERT INTO CUSTOMERS VALUES(1012,'Huff','Melody','Huff@gmail.com'); INSERT INTO CUSTOMERS VALUES(1013,'Carrillo','Austin','Carrillo@msn.com'); INSERT INTO CUSTOMERS VALUES(1014,'Musser','Vincent','Musser@comcast.net'); INSERT INTO CUSTOMERS VALUES(1015,'Wilde','Thelma','Wilde@msn.com'); INSERT INTO CUSTOMERS VALUES(1016,'Passmore','James','Passmore@gmail.com'); INSERT INTO CUSTOMERS 10 VALUES(1017,'Bonnell','Adam','Bonnell@gmail.com'); INSERT INTO CUSTOMERS VALUES(1018,'Engelhardt','Carl','Engelhardt@gmail.com'); INSERT INTO CUSTOMERS VALUES(1019,'Anderson','Eric','Anderson@gmail.com'); INSERT INTO CUSTOMERS VALUES(1020,'Smith','Joe','Smith@gmail.com'); CREATE TABLE BILLINGINFO (CUSTOMER# NUMBER(4) NOT NULL, ADDRESS VARCHAR2(40) NOT NULL, CITY VARCHAR2(15) NOT NULL, STATE CHAR(2) NOT NULL, ZIP NUMBER(5) NOT NULL, CARDTYPE VARCHAR2(4), CONSTRAINT BILLINGINFO_CARDTYPE_CK CHECK (CARDTYPE IN ('MC', 'VISA', 'AMEX')), CONSTRAINT BILLINGINFO_CUSTOMER#_FK FOREIGN KEY (CUSTOMER#) REFERENCES CUSTOMERS (CUSTOMER#)); INSERT INTO BILLINGINFO VALUES(1000,'1571 Green Willow Alley','Milwaukee','WI','53201','MC'); INSERT INTO BILLINGINFO VALUES(1001,'1723 Honey Wood','Boston','MA','02163','VISA'); INSERT INTO BILLINGINFO VALUES(1002,'3137 Quiet Subdivision','DC', 'DC','20001','AMEX'); INSERT INTO BILLINGINFO VALUES(1003,'3296 Cinder Pine Edge','Omaha','NE','68106','MC'); INSERT INTO BILLINGINFO VALUES(1004,'3290 Silent Maze','Fairfield','CT','06825','VISA'); INSERT INTO BILLINGINFO VALUES(1005,'9597 Sleepy Valley','Milwaukee','WI','53201','MC'); INSERT INTO BILLINGINFO VALUES(1006,'6121 Trimble Ave','Bainbridge Is.','WA','98110','VISA'); INSERT INTO BILLINGINFO VALUES(1007,'4210 Dewy Shadow Crescent','Chico','CA','95926','MC'); INSERT INTO BILLINGINFO VALUES(1008,'1061 Quaking Berry Landing','Dallas','TX','75201','AMEX'); INSERT INTO BILLINGINFO VALUES(1009,'1707 Golden Pony Orchard','Wichita','KS','67201','MC'); INSERT INTO BILLINGINFO VALUES(1010,'1029 Emerald Common','Arlington','TX','76001','AMEX'); INSERT INTO BILLINGINFO VALUES(1011,'9676 Shady Ledge','Topeka','KS','66618','VISA'); 11 INSERT INTO BILLINGINFO VALUES(1012,'3639 Pleasant Deer View', 'Sunriver','OR','97707','AMEX'); INSERT INTO BILLINGINFO VALUES(1013,'9116 Foggy Spring Corners','Columbus ','OH','43085','MC'); INSERT INTO BILLINGINFO VALUES(1014,'1283 Old Place','Cheyenney','WY','82001','VISA'); INSERT INTO BILLINGINFO VALUES(1015,'4691 Cozy Blossom Trace','Montpeliere','VT','83254','VISA'); INSERT INTO BILLINGINFO VALUES(1016,'5618 Little Log Hill','Bend','OR','97701','AMEX'); INSERT INTO BILLINGINFO VALUES(1017,'7020 Colonial End','Jackson','MS','39201','MC'); INSERT INTO BILLINGINFO VALUES(1018,'6723 Bright Run','Oklahoma City','OK','73101','VISA'); INSERT INTO BILLINGINFO VALUES(1019,'1387 Amber River Road','Louisville','KT','40223','AMEX'); INSERT INTO BILLINGINFO VALUES(1020,'4780 Sunny Gate Key','Lincoln','NE','68501','AMEX'); CREATE TABLE SHIPPINGINFO (CUSTOMER# NUMBER(4) NOT NULL, ADDRESS VARCHAR2(40) NOT NULL, CITY VARCHAR2(15) NOT NULL, STATE CHAR(2) NOT NULL, ZIP NUMBER(5) NOT NULL, CONSTRAINT SHIPPINGINFO_CUSTOMER#_FK FOREIGN KEY (CUSTOMER#) REFERENCES CUSTOMERS (CUSTOMER#)); INSERT INTO SHIPPINGINFO VALUES(1000,'1571 Green Willow Alley','Milwaukee','WI','53201'); INSERT INTO SHIPPINGINFO VALUES(1001,'1723 Honey Wood','Boston','MA','02163'); INSERT INTO SHIPPINGINFO VALUES(1002,'3137 Quiet Subdivision','DC', 'DC','20001'); INSERT INTO SHIPPINGINFO VALUES(1003,'3296 Cinder Pine Edge','Omaha','NE','68106'); INSERT INTO SHIPPINGINFO VALUES(1004,'3290 Silent Maze','Fairfield','CT','06825'); INSERT INTO SHIPPINGINFO VALUES(1005,'9597 Sleepy Valley','Milwaukee','WI','53201'); INSERT INTO SHIPPINGINFO VALUES(1006,'6121 Trimble Ave','Bainbridge Is.','WA','98110'); INSERT INTO SHIPPINGINFO VALUES(1007,'4210 Dewy Shadow Crescent','Chico','CA','95926'); 12 INSERT INTO SHIPPINGINFO VALUES(1008,'1061 Quaking Berry Landing','Dallas','TX','75201'); INSERT INTO SHIPPINGINFO VALUES(1009,'1707 Golden Pony Orchard','Wichita','KS','67201'); INSERT INTO SHIPPINGINFO VALUES(1010,'1029 Emerald Common','Arlington','TX','76001'); INSERT INTO SHIPPINGINFO VALUES(1011,'9676 Shady Ledge','Topeka','KS','66618'); INSERT INTO SHIPPINGINFO VALUES(1012,'3639 Pleasant Deer View', 'Sunriver','OR','97707 '); INSERT INTO SHIPPINGINFO VALUES(1013,'9116 Foggy Spring Corners','Columbus ','OH','43085'); INSERT INTO SHIPPINGINFO VALUES(1014,'1283 Old Place','Cheyenney','WY','82001'); INSERT INTO SHIPPINGINFO VALUES(1015,'4691 Cozy Blossom Trace','Montpeliere','VT','83254'); INSERT INTO SHIPPINGINFO VALUES(1016,'5618 Little Log Hill','Bend','OR','97701'); INSERT INTO SHIPPINGINFO VALUES(1017,'7020 Colonial End','Jackson','MS','39201'); INSERT INTO SHIPPINGINFO VALUES(1018,'6723 Bright Run','Oklahoma City','OK','73101'); INSERT INTO SHIPPINGINFO VALUES(1019,'1387 Amber River Road','Louisville','KT','40223'); INSERT INTO SHIPPINGINFO VALUES(1020,'4780 Sunny Gate Key','Lincoln','NE','68501'); CREATE SEQUENCE orders_order#_seq INCREMENT BY 1 START WITH 4000 NOCACHE NOCYCLE; CREATE TABLE ORDERS (ORDER# NUMBER(4), CUSTOMER# NUMBER(4) NOT NULL, ORDERTYPE CHAR(4) NOT NULL, ORDERDATE DATE NOT NULL, SHIPDATE DATE, CONSTRAINT ORDERS_ORDERTYPE_CK CHECK (ORDERTYPE IN ('DIGI', 'PHYS')), CONSTRAINT ORDERS_ORDER#_PK PRIMARY KEY(ORDER#)); CREATE TABLE ORDERITEMS (ORDER# NUMBER(4), ITEM_ID NUMBER(4), CONSTRAINT ORDERITEMS_ORDER#_FK FOREIGN KEY (ORDER#) 13 REFERENCES ORDERS (ORDER#), CONSTRAINT ORDERITEMS_ITEM_ID_FK FOREIGN KEY (ITEM_ID) REFERENCES PRODUCTS (ITEM_ID)); INSERT INTO ORDERS VALUES (orders_order#_seq.NEXTVAL,1000,'DIGI',TO_DATE('10/20/2012','MM/ DD/YYYY'),NULL); INSERT INTO ORDERITEMS VALUES (orders_order#_seq.CURRVAL,3015); INSERT INTO ORDERITEMS VALUES (orders_order#_seq.CURRVAL,3018); INSERT INTO ORDERS VALUES (orders_order#_seq.NEXTVAL,1005,'PHYS',TO_DATE('10/15/2012','MM/ DD/YYYY'),TO_DATE('10/17/2012','MM/DD/YYYY')); INSERT INTO ORDERITEMS VALUES (orders_order#_seq.CURRVAL,3000); INSERT INTO ORDERITEMS VALUES (orders_order#_seq.CURRVAL,3005); INSERT INTO ORDERS VALUES (orders_order#_seq.NEXTVAL,1008,'DIGI',TO_DATE('10/31/2012','MM/ DD/YYYY'),NULL); INSERT INTO ORDERITEMS VALUES (orders_order#_seq.CURRVAL,3010); INSERT INTO ORDERS VALUES (orders_order#_seq.NEXTVAL,1010,'PHYS',TO_DATE('10/15/2012','MM/ DD/YYYY'),TO_DATE('10/17/2012','MM/DD/YYYY')); INSERT INTO ORDERITEMS VALUES (orders_order#_seq.CURRVAL,3030); INSERT INTO ORDERITEMS VALUES (orders_order#_seq.CURRVAL,3023); INSERT INTO ORDERS VALUES (orders_order#_seq.NEXTVAL,1015,'PHYS',TO_DATE('11/15/2012','MM/ DD/YYYY'),TO_DATE('11/17/2012','MM/DD/YYYY')); INSERT INTO ORDERITEMS VALUES (orders_order#_seq.CURRVAL,3022); INSERT INTO ORDERS VALUES (orders_order#_seq.NEXTVAL,1011,'DIGI',TO_DATE('08/25/2012','MM/ DD/YYYY'),NULL); INSERT INTO ORDERITEMS VALUES (orders_order#_seq.CURRVAL,3040); INSERT INTO ORDERITEMS VALUES (orders_order#_seq.CURRVAL,3050); INSERT INTO ORDERS 14 VALUES (orders_order#_seq.NEXTVAL,1007,'PHYS',TO_DATE('06/02/2012','MM/ DD/YYYY'),TO_DATE('06/05/2012','MM/DD/YYYY')); INSERT INTO ORDERITEMS VALUES (orders_order#_seq.CURRVAL,3002); INSERT INTO ORDERITEMS VALUES (orders_order#_seq.CURRVAL,3006); INSERT INTO ORDERS VALUES (orders_order#_seq.NEXTVAL,1013,'PHYS',TO_DATE('02/07/2012','MM/ DD/YYYY'),TO_DATE('02/10/2012','MM/DD/YYYY')); INSERT INTO ORDERITEMS VALUES (orders_order#_seq.CURRVAL,3038); INSERT INTO ORDERS VALUES (orders_order#_seq.NEXTVAL,1013,'DIGI',TO_DATE('02/07/2012','MM/ DD/YYYY'),NULL); INSERT INTO ORDERITEMS VALUES (orders_order#_seq.CURRVAL,3035); INSERT INTO ORDERITEMS VALUES (orders_order#_seq.CURRVAL,3055); INSERT INTO ORDERS VALUES (orders_order#_seq.NEXTVAL,1012,'PHYS',TO_DATE('12/05/2012','MM/ DD/YYYY'),TO_DATE('12/10/2012','MM/DD/YYYY')); INSERT INTO ORDERITEMS VALUES (orders_order#_seq.CURRVAL,3045); INSERT INTO ORDERS VALUES (orders_order#_seq.NEXTVAL,1020,'DIGI',TO_DATE('04/12/2012','MM/ DD/YYYY'),NULL); INSERT INTO ORDERITEMS VALUES (orders_order#_seq.CURRVAL,3047); INSERT INTO ORDERITEMS VALUES (orders_order#_seq.CURRVAL,3048); INSERT INTO ORDERS VALUES (orders_order#_seq.NEXTVAL,1003,'PHYS',TO_DATE('12/19/2012','MM/ DD/YYYY'),TO_DATE('12/21/2012','MM/DD/YYYY')); INSERT INTO ORDERITEMS VALUES (orders_order#_seq.CURRVAL,3029); INSERT INTO ORDERITEMS VALUES (orders_order#_seq.CURRVAL,3027); INSERT INTO ORDERS VALUES (orders_order#_seq.NEXTVAL,1009,'PHYS',TO_DATE('05/01/2012','MM/ DD/YYYY'),TO_DATE('05/06/2012','MM/DD/YYYY')); INSERT INTO ORDERITEMS VALUES (orders_order#_seq.CURRVAL,3010); INSERT INTO ORDERS 15 VALUES (orders_order#_seq.NEXTVAL,1018,'DIGI',TO_DATE('09/25/2012','MM/ DD/YYYY'),NULL); INSERT INTO ORDERITEMS VALUES (orders_order#_seq.CURRVAL,3056); INSERT INTO ORDERITEMS VALUES (orders_order#_seq.CURRVAL,3055); INSERT INTO ORDERS VALUES (orders_order#_seq.NEXTVAL,1018,'DIGI',TO_DATE('09/25/2012','MM/ DD/YYYY'),NULL); INSERT INTO ORDERITEMS VALUES (orders_order#_seq.CURRVAL,3037); INSERT INTO ORDERITEMS VALUES (orders_order#_seq.CURRVAL,3031); INSERT INTO ORDERS VALUES (orders_order#_seq.NEXTVAL,1002,'DIGI',TO_DATE('01/27/2012','MM/ DD/YYYY'),NULL); INSERT INTO ORDERITEMS VALUES (orders_order#_seq.CURRVAL,3035); INSERT INTO ORDERS VALUES (orders_order#_seq.NEXTVAL,1003,'PHYS',TO_DATE('03/29/2012','MM/ DD/YYYY'),TO_DATE('04/03/2012','MM/DD/YYYY')); INSERT INTO ORDERITEMS VALUES (orders_order#_seq.CURRVAL,3046); INSERT INTO ORDERITEMS VALUES (orders_order#_seq.CURRVAL,3003); INSERT INTO ORDERS VALUES (orders_order#_seq.NEXTVAL,1006,'PHYS',TO_DATE('08/01/2012','MM/ DD/YYYY'),TO_DATE('08/06/2012','MM/DD/YYYY')); INSERT INTO ORDERITEMS VALUES (orders_order#_seq.CURRVAL,3000); INSERT INTO ORDERS VALUES (orders_order#_seq.NEXTVAL,1004,'DIGI',TO_DATE('07/22/2012','MM/ DD/YYYY'),NULL); INSERT INTO ORDERITEMS VALUES (orders_order#_seq.CURRVAL,3057); INSERT INTO ORDERITEMS VALUES (orders_order#_seq.CURRVAL,3043); INSERT INTO ORDERS VALUES (orders_order#_seq.NEXTVAL,1006,'DIGI',TO_DATE('03/30/2012','MM/ DD/YYYY'),NULL); INSERT INTO ORDERITEMS VALUES (orders_order#_seq.CURRVAL,3009); INSERT INTO ORDERITEMS VALUES (orders_order#_seq.CURRVAL,3005); 16 COMMIT; Functional Queries This code is the queries we have for our database so that we can make the data that we have into useful information. SQL> SQL> SQL> SQL> that SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> 2 3 4 -- Oracle SQL, Group Project: Group 1 -- BMIS441 Business Database Systems -- 1. --Display the Artist name, album name and price for albums are greater than 10$. Please list them in descending order SET LINESIZE 75 SET PAGESIZE 45 COLUMN Artistname FORMAT A15 HEADING 'Artist Name' COLUMN title FORMAT A35 HEADING 'Album Title' COLUMN Price FORMAT $99.99 HEADING 'Price' SELECT a.ARTISTNAME, p.Title, p.Price FROM ARTISTS a JOIN PRODUCTS p USING (Artist_ID) WHERE Price > 10 ORDER by Price DESC; Artist Name --------------Johan Flozart Johan Flozart Johan Flozart Swag Swag Swag Pink The Eagles Muse Katy Perry Muse Muse The Eagles Rihanna Rihanna The Eagles Katy Perry Katy Perry Avicii Pink Led Zeppelin Avicii Pink Album Title Price ----------------------------------- ------Shadows $15.99 Nature $15.99 Volcano $15.99 Worldwide Swag $15.99 All Up In It $13.99 Me And Your Sister $13.99 This Is Real Life Vol. 2 $13.99 Heart On $13.99 Origin Of Symmetry $12.99 Essentially $12.99 Absolution $12.99 Showbiz $12.99 San Bernardino $11.99 Yes, Yes, Yes $11.99 Back To Back $11.99 Peace and Love $11.99 Ecstasy $11.99 Ball So Hard $11.99 Prequel $10.99 This Is Real Life $10.99 Mothership $10.99 Sequel $10.99 The Whole Shabang $10.99 17 23 rows selected. SQL> --2. SQL> --Display the average time it takes for the order to ship in hours. SQL> SELECT (AVG(shipdate-orderdate)*24) "Shipping_Delay_Hours" 2 FROM orders 3 WHERE (shipdate-orderdate) IS NOT NULL; Shipping_Delay_Hours -------------------81.6 SQL> SQL> view SQL> SQL> 2 3 4 5 6 7 8 9 10 11 12 --3. --Create a view that only displays digital orders. In this please include the Order#, Item_ID, ORDERDATE, and price. CREATE VIEW Digital_Orders AS SELECT Order#, Item_ID, Price, Orderdate, ROUND( Price/ (SELECT SUM(Price) FROM ORDERS JOIN ORDERITEMS USING (ORDER#) JOIN Products USING (ITEM_ID) WHERE ORDERTYPE = 'DIGI'),3) AS "% of Revenue" FROM ORDERS JOIN ORDERITEMS USING (ORDER#) JOIN Products USING (ITEM_ID) WHERE ORDERTYPE = 'DIGI' GROUP by Order#, Item_ID, Orderdate, Price; View created. SQL> SQL> DROP VIEW Digital_Orders; View dropped. SQL> --4. SQL> --Display all the orders that were placed during the summer. Please include the title of the album, orderdate, and the full name of the customer. SQL> COLUMN Full_Name FORMAT A15 SQL> COLUMN title FORMAT A25 HEADING 'Album Title' SQL> COLUMN Orderdate FORMAT A15 SQL> SELECT title, orderdate, Firstname ||' '|| Lastname "Full_Name" 2 FROM Customers JOIN Orders USING (Customer#) 3 JOIN Orderitems USING (Order#) 4 JOIN Products USING (ITEM_ID) 5 WHERE orderdate BETWEEN '21-JUN-12'and'21-SEP-12'; 18 Album Title ------------------------This Is Real Life Levels Escape Whole Lotta Love Apple Sauce SQL> SQL> SQL> SQL> 2 3 4 5 6 ORDERDATE --------------01-AUG-12 25-AUG-12 22-JUL-12 25-AUG-12 22-JUL-12 Full_Name --------------Collin Parker Ronald Ojeda Brandi Salyer Ronald Ojeda Brandi Salyer --5. --How much revenue has come from Customer# 1006? COLUMN SUM(Price) FORMAT $99.99 HEADING 'Revenue' (SELECT SUM(Price) FROM ARTISTS a JOIN PRODUCTS p USING (Artist_ID) JOIN Orderitems USING (Item_ID) JOIN Orders USING (Order#) JOIN Customers USING (Customer#) WHERE Customer# = '1006'); Revenue ------$37.97 SQL> spool off V. Maintenance: We will be very diligent in making sure that our database is up to date and functioning properly. We will have routine checks that there aren’t any issues and problem solve when issues arise. Being proactive in our maintenance of our database is very important to us so when we can we will try to predict upcoming issues and solve them before they become a problem. VI. Growth and Change: In the future we may have to create a larger database in case there are different entities that are needed to be created if we expand into other areas such as audiobooks and movies. We will always be looking for better ways for our business to do things especially as we start to become a larger business. VII. Conclusion The creation of this database has allowed our group to learn about all the work that goes into database creation and really apply the knowledge that we have gained over the semester to a real world situation. It was interesting to see how much thought has to go into a project like this to ensure that it is done correctly and going through this thought process was a learning experience in itself. There were revisions that had to be made at many points throughout the process but they all led to a very well organized final product that we are very proud of. We think that this process has prepared us very well to confidently say that we are proficient in knowledgeable. 19 See comments/summary below G1 Time Mgt SDLC YES Database A- ER-D YES Functional Dep NO (not in ppt) Yes, in the report Normalization NO (not in ppt) NO (not in report) Queries (4-5) YES # of Add. Queries Written Report A- Presentation B+ FINAL GRADE A(74/80) 20