Upload
others
View
3
Download
0
Embed Size (px)
Citation preview
1
INFO 605 – Term Project June 7, 2012 Joseph Healy
Term Project
BigMegaGamingDatabase.com
Joseph Healy
INFO 605 – Intro to Database Management
Professor Frein
Drexel University
June 7, 2012
2
INFO 605 – Term Project June 7, 2012 Joseph Healy
Table of Contents
1. Requirements
2. Entity-Relationship Model
3. Relational Schema
4. Data Dictionary
5. Data Definition Language Statements
6. Data Manipulation Language Statements
7. Sample Queries
8. Certification
3
INFO 605 – Term Project June 7, 2012 Joseph Healy
1. Requirements
The database under construction will be used in conjunction with a video game retailer who is converting to a primarily online retailer. Their
website will be called BigMegaGamingDatabase.com. This company offers for purchase to members video games for all four relevant gaming
platforms (Xbox, PS3, Wii, and PC). Other gaming accessories, such as headsets, controllers, wires, etc. will also be sold by the store.
Anyone can browse the store, but one must be a member to make any purchases. If not a member already, upon checkout the guest will be
required to create a member profile. Members sign up by entering their full first name, middle initial, last name, any suffix/prefix, email
address, and primary phone number. Upon sign up, members will also be forced to choose a Member ID and password. Member IDs must be
unique across all members. They will also need to add a shipping address, billing address, credit/debit card type, name as it appears on card,
number, expiration date, security code, and credit card nickname, alternate phone numbers, birthdate, and gender. No other method of
payment will be accepted other than credit/debit card. The user can then choose from the selection of inventory to make a purchase.
There will also be an option to become part of the mailing list. Members are automatically added to the mailing list (unless they deselect that
option during sign up). To become part of the mailing list (as well as active their membership) the user must enter a valid email address and
then confirm that the address is valid by clicking a link in an email that will be immediately sent to the account that was provided.
Inventory is split into two separate areas: video games and accessories. Video games are associated with item number, platform, game title,
producer, maturity rating, year released, the edition, quantity in stock, retail price, and shipping category (small, medium, or large). The
shipping category information will be used to determine the shipping cost for each item. Accessories are associated with item number,
platform, accessory type, manufacturer, model name, model number, quantity in stock, retail price, and shipping category (same as above).
When a member creates a transaction, the following data will be recorded: Date, Member ID, order number, order total, game/accessory
number, quantity, shipping cost, and tracking number. Order numbers are not repeated and are unique.
Once an order is received, the appropriate items are allocated and their associated quantities are reduced by the number ordered. This
completes the sales cycle.
4
INFO 605 – Term Project June 7, 2012 Joseph Healy
2. ER Model
5
INFO 605 – Term Project June 7, 2012 Joseph Healy
3. Relational Schema using Mapped Translation
Profile (MemberID, PFix, FName, MidIntl, LName, Suffix, PNumber, AltPhone, Email, BirthDate, Gender, DtCreate, IsMail, IsActive)
Shipping (MemberID, SpAddr1, SpAddr2, SpCity, SpState, SpZip, IsPrimary)
Payment (MemberID, CardNum, CardType, ExpDate, SecCode, CardNick, IsPrimary, BLAddr1, BLAddr2, BLCity, BLState, BLZip)
Mailing (MemberID, Email, IsActive)
Orders (OrderSeq, OrderNum, MemberID, DateTime, ItemNum, Qty, ShipCost, TrackNum, TotalPrice)
Item (ItemNum, Price, ShipCat, Platform, StkQty, IsActive)
Game (ItemNum, Title, Producer, MatureRt, YearCt, Edition)
Accessory (ItemNum, AccType, Manuf, ModName, ModNum)
6
INFO 605 – Term Project June 7, 2012 Joseph Healy
4. Data Dictionary
Profile - Contains information related to members.
Attribute Name Description Datatype Domain Nullable PK FK
MemberID Unique identifier for Member VARCHAR2(12) All - Unique value for each member. N Y N
Pfix Prefix of name of member (Mr., Mrs., Ms., etc.). VARCHAR2(4) All Y N N
FName First name of member. VARCHAR2(50) All N N N
MidIntl Middle initial of member. CHAR(1) All Y N N
LName Last name of member. VARCHAR2(50) All N N N
Suffix Suffix of name of member (Jr., Sr., III., etc). VARCHAR2(4) All Y N N
PNumber Preferred phone number of member. CHAR(10) 0 - 9 N N N
AltPhone Alternate phone number of member. CHAR(10) 0 - 9 Y N N
Email Email address of member. VARCHAR2(50) All N N N
BirthDate Birthdate of member. DATE All N N N
Gender Flag indicating gender of member. CHAR(1) "M","F","O","U" Y N N
DtCreate Creation date of member profile. DATE All N N N
IsMail Flag indicating whether member is on mailing list. CHAR(1) "Y","N" - Defaults to "Y" N N N
IsActive Flag indicating whether member is active. CHAR(1) "Y","N" - Defaults to "Y" N N N
7
INFO 605 – Term Project June 7, 2012 Joseph Healy
Shipping - Contains information related to the shipping address(es) of members.
Attribute Name Description Datatype Domain Nullable PK FK
MemberID Unique identifier for Member VARCHAR2(12) All - Unique value for each member. N Y Y
SpAddr1 Shipping address (line 1) of member. VARCHAR2(50) All N N N
SpAddr2 Shipping address (line 2) of member. VARCHAR2(50) All Y N N
SpCity Shipping city of member. VARCHAR2(20) All N N N
SpState Shipping state of member. CHAR(2) All N N N
SpZip Shipping zip code of member. CHAR(5) All N N N
IsPrimary Flag indicating whether shipping address is primary. CHAR(1) "Y","N" - Defaults to "Y" N N N
Payment - Contains payment related information such as payment card(s) and billing address(es).
Attribute Name Description Datatype Domain Nullable PK FK
MemberID Unique identifier for Member VARCHAR2(12) All - Unique value for each member. N Y Y
CardNum Payment card number of member. VARCHAR2(20) All N N N
CardType Flag indicating payment card type of member. CHAR(1) "D","C" N N N
ExpDate Expiration date of card. DATE All N N N
SecCode Security code of card. VARCHAR2(4) All N N N
CardNick Card nickname. VARCHAR2(10) All Y N N
IsPrimary Flag indicating whether payment card is primary. CHAR(1) "Y","N" - Defaults to "Y" N N N
BLAddr1 Billing address (line 1) of member. VARCHAR2(50) All N N N
BLAddr2 Billing address (line 2) of member. VARCHAR2(50) All Y N N
BLCity Billing city of member. VARCHAR2(20) All N N N
BLState Billing state of member. CHAR(2) All N N N
BLZip Billing zip code of member. CHAR(5) All N N N
8
INFO 605 – Term Project June 7, 2012 Joseph Healy
Mailing - Contains infromation on people that subscribe to the mailing list.
Attribute Name Description Datatype Domain Nullable PK FK
MemberID Unique identifier for Member VARCHAR2(12) All - Unique value for each member. N Y Y
Email Email address of member. VARCHAR2(50) All N N N
IsActive Flag indicating whether member is active. CHAR(1) "Y","N" - Defaults to "Y" N N N
Orders - Contains information related to orders placed by members.
Attribute Name Description Datatype Domain Nullable PK FK
OrderSeq Unique and sequencial identifier for order. VARCHAR2(10) All N Y N
OrderNum Order number used to reference order. VARCHAR2(10) All N N N
MemberID Unique identifier for Member VARCHAR2(12) All - Unique value for each member. N N Y
DateTime Date and time order is placed. DATE All N N N
ItemNum Unique identifier for each item. CHAR(6) All N N N
Qty Quantity of item within order. NUMBER(3,0) 1 - 999 N N N
ShipCost Total shipping cost of order. NUMBER(5,2) 0 - 999.99 Y N N
TrackNum Shipping tracking number of order. VARCHAR2(30) All Y N N
TotalPrice Total price of order. NUMBER(6,2) 0 - 9999.99 Y N N
Item - Contains information related to items that can be sold. Items can be either games or accessories.
Attribute Name Description Datatype Domain Nullable PK FK
ItemNum Unique identifier for each item. CHAR(6) All N Y Y
Price Price of item. NUMBER(6,2) 0 - 9999.99 N N N
ShipCat Shipping category of item (1-Sm, 2-Md, 3-Lg). CHAR(1) All N N N
Platform Recommended gaming platform of item. VARCHAR2(4) All N N N
StockQty Quantity of item currently in stock. NUMBER(3,0) 0 - 999 N N N
IsActive Flag indicating whether item is active. CHAR(1) "Y","N" - Defaults to "Y" N N N
9
INFO 605 – Term Project June 7, 2012 Joseph Healy
Game - Contains information about an item if it is a game.
Attribute Name Description Datatype Domain Nullable PK FK
ItemNum Unique identifier for each item. CHAR(6) All N Y Y
Title Title of game. VARCHAR2(50) All N N N
Producer Producer of game. VARCHAR2(50) All N N N
MatureRt Maturity rating of game. VARCHAR2(4) All N N N
YearCt Year game was introduced. CHAR(4) All N N N
Edition Edition of game. VARCHAR2(20) All - Defaults to "1" N N N
Accessory - Contains information about an item if it is an accessory.
Attribute Name Description Datatype Domain Nullable PK FK
ItemNum Unique identifier for each item. CHAR(6) All N Y Y
AccType Type of accessory. VARCHAR2(15) All N N N
Manuf Manufacturer of accessory. VARCHAR2(50) All N N N
ModName Model name of accessory. VARCHAR2(50) All N N N
ModNum Model number of accessory. VARCHAR2(50) All N N N
10
INFO 605 – Term Project June 7, 2012 Joseph Healy
5. Data Definition Language Statements
CREATE TABLE Profile
(
MemberID VARCHAR2(12)
CONSTRAINT profile_pk PRIMARY KEY
CONSTRAINT profile_nn NOT NULL,
PFix VARCHAR2(4),
FName VARCHAR2(50)
CONSTRAINT fname_nn NOT NULL,
MidIntl CHAR(1),
LName VARCHAR2(50)
CONSTRAINT lname_nn NOT NULL,
Suffix VARCHAR2(4),
PNumber CHAR(10)
CONSTRAINT pnumber_nn NOT NULL,
AltPhone CHAR(10),
Email VARCHAR2(50)
CONSTRAINT premail_nn NOT NULL,
BirthDate DATE
11
INFO 605 – Term Project June 7, 2012 Joseph Healy
CONSTRAINT birthdate_nn NOT NULL,
Gender CHAR(1) DEFAULT 'U'
CONSTRAINT gender_ck CHECK(Gender IN ('M','F','O','U')),
DtCreate DATE
CONSTRAINT dtcreate_nn NOT NULL,
IsMail CHAR(1) DEFAULT 'Y'
CONSTRAINT ismail_nn NOT NULL
CONSTRAINT ismail_ck CHECK(IsMail IN ('Y','N')),
IsActive CHAR(1) DEFAULT 'Y'
CONSTRAINT isactive_nn NOT NULL
CONSTRAINT isactive_ck CHECK(IsActive IN ('Y','N'))
)
CREATE TABLE Shipping
(
MemberID VARCHAR2(12)
CONSTRAINT shipping_pk PRIMARY KEY
CONSTRAINT shipping_rf REFERENCES Profile(MemberID)
ON DELETE CASCADE
CONSTRAINT shipping_nn NOT NULL,
SpAddr1 VARCHAR2(50)
12
INFO 605 – Term Project June 7, 2012 Joseph Healy
CONSTRAINT spaddr1_nn NOT NULL,
SpAddr2 VARCHAR2(50),
SpCity VARCHAR2(20)
CONSTRAINT spcity_nn NOT NULL,
SpState CHAR(2)
CONSTRAINT spstate_nn NOT NULL,
SpZip CHAR(5)
CONSTRAINT spzip_nn NOT NULL,
IsPrimary CHAR(1) DEFAULT 'Y'
CONSTRAINT shipprim_ck CHECK(IsPrimary IN ('Y','N'))
CONSTRAINT shipprim_nn NOT NULL
)
CREATE TABLE Payment
(
MemberID VARCHAR2(12)
CONSTRAINT payment_pk PRIMARY KEY
CONSTRAINT payment_rf REFERENCES Profile(MemberID)
ON DELETE CASCADE
CONSTRAINT payment_nn NOT NULL,
13
INFO 605 – Term Project June 7, 2012 Joseph Healy
CardNum VARCHAR2(20)
CONSTRAINT cardnum_nn NOT NULL,
CardType CHAR(1)
CONSTRAINT cardtype_ck CHECK(CardType IN ('D','C'))
CONSTRAINT cardtype_nn NOT NULL,
ExpDate DATE
CONSTRAINT expdate_nn NOT NULL,
SecCode VARCHAR2(4)
CONSTRAINT seccode_nn NOT NULL,
CardNick VARCHAR2(10),
IsPrimary CHAR(1) DEFAULT 'Y'
CONSTRAINT payprim_ck CHECK(IsPrimary IN ('Y','N'))
CONSTRAINT payprim_nn NOT NULL,
BLAddr1 VARCHAR2(50)
CONSTRAINT bladdr1_nn NOT NULL,
BLAddr2 VARCHAR2(50),
BLCity VARCHAR2(20)
CONSTRAINT blcity_nn NOT NULL,
BLState CHAR(2)
CONSTRAINT blstate_nn NOT NULL,
14
INFO 605 – Term Project June 7, 2012 Joseph Healy
BLZip CHAR(5)
CONSTRAINT blzip_nn NOT NULL
)
CREATE TABLE Mailing
(
MemberID VARCHAR2(12)
CONSTRAINT mailing_pk PRIMARY KEY
CONSTRAINT mailing_rf REFERENCES Profile(MemberID)
ON DELETE CASCADE
CONSTRAINT mailing_nn NOT NULL,
Email VARCHAR2(50)
CONSTRAINT maemail_nn NOT NULL,
IsActive CHAR(1) DEFAULT 'Y'
CONSTRAINT mailact_ck CHECK(IsActive IN ('Y','N'))
CONSTRAINT mailact_nn NOT NULL
)
CREATE TABLE Orders
(
15
INFO 605 – Term Project June 7, 2012 Joseph Healy
OrderSeq VARCHAR2(10)
CONSTRAINT orderseq_pk PRIMARY KEY
CONSTRAINT orderseq_nn NOT NULL,
OrderNum VARCHAR2(10)
CONSTRAINT ordernum_nn NOT NULL,
MemberID VARCHAR2(12)
CONSTRAINT ordmemberid_fk REFERENCES Profile(MemberID)
ON DELETE SET NULL
CONSTRAINT ordmemberid_nn NOT NULL,
DateTime DATE
CONSTRAINT datetime_nn NOT NULL,
ItemNum CHAR(6)
CONSTRAINT itemnum_nn NOT NULL,
Qty NUMBER(3,0)
CONSTRAINT qty_ck CHECK(Qty BETWEEN 0 AND 999)
CONSTRAINT qty_nn NOT NULL,
ShipCost NUMBER(5,2)
CONSTRAINT shipcost_ck CHECK(ShipCost BETWEEN 0 AND 999.99),
TrackNum VARCHAR2(30),
TotalPrice NUMBER(6,2)
16
INFO 605 – Term Project June 7, 2012 Joseph Healy
)
CREATE TABLE Item
(
ItemNum CHAR(6)
CONSTRAINT item_pk PRIMARY KEY
CONSTRAINT item_nn NOT NULL,
Price NUMBER(6,2)
CONSTRAINT price_ck CHECK(Price BETWEEN 0 AND 9999.99)
CONSTRAINT price_nn NOT NULL,
ShipCat CHAR(1)
CONSTRAINT shipcat_nn NOT NULL,
Platform VARCHAR2(4)
CONSTRAINT platform_nn NOT NULL,
StockQty NUMBER(3,0)
CONSTRAINT stockqty_ck CHECK(StockQty BETWEEN 0 AND 999)
CONSTRAINT stockqty_nn NOT NULL,
IsActive CHAR(1) DEFAULT 'Y'
CONSTRAINT itemact_nn NOT NULL
CONSTRAINT itemact_ck CHECK(IsActive IN ('Y','N'))
17
INFO 605 – Term Project June 7, 2012 Joseph Healy
)
CREATE TABLE Game
(
ItemNum CHAR(6)
CONSTRAINT game_pk PRIMARY KEY
CONSTRAINT game_rf REFERENCES Item(ItemNum)
ON DELETE CASCADE
CONSTRAINT game_nn NOT NULL,
Title VARCHAR2(50)
CONSTRAINT title_nn NOT NULL,
Producer VARCHAR2(50)
CONSTRAINT producer_nn NOT NULL,
MatureRt VARCHAR2(4)
CONSTRAINT maturert_nn NOT NULL,
YearCt CHAR(4)
CONSTRAINT yearct_nn NOT NULL,
Edition VARCHAR2(20) DEFAULT 1
CONSTRAINT edition_nn NOT NULL
)
18
INFO 605 – Term Project June 7, 2012 Joseph Healy
CREATE TABLE Accessory
(
ItemNum CHAR(6)
CONSTRAINT acc_pk PRIMARY KEY
CONSTRAINT acc_rf REFERENCES Item(ItemNum)
ON DELETE CASCADE
CONSTRAINT acc_nn NOT NULL,
AccType VARCHAR2(15)
CONSTRAINT acctype_nn NOT NULL,
Manuf VARCHAR2(50)
CONSTRAINT manuf_nn NOT NULL,
ModName VARCHAR2(50)
CONSTRAINT modname_nn NOT NULL,
ModNum VARCHAR2(50)
CONSTRAINT modnum_nn NOT NULL
)
19
INFO 605 – Term Project June 7, 2012 Joseph Healy
6. Data Manipulation Language Statements
TABLE: PROFILE
INSERT INTO Profile (MemberID, PFix, FName, MidIntl, LName, Suffix, PNumber, AltPhone, Email, BirthDate, Gender, DtCreate, IsMail, IsActive)
VALUES ('TheDoc','Mr.','Doc','P','Holliday','III','5204891212','5204891213','[email protected]','14-AUG-1851','M','17-JAN-1871','N','N');
INSERT INTO Profile (MemberID, PFix, FName, MidIntl, LName, PNumber, Email, BirthDate, Gender, DtCreate, IsMail, IsActive)
VALUES ('FlynHawaiian','Mr.','Shane','P','Victorino','2154631000','[email protected]','30-NOV-1980','M','06-MAY-2012','Y','Y');
INSERT INTO Profile (MemberID, PFix, FName, MidIntl, LName, PNumber, AltPhone, Email, BirthDate, Gender, DtCreate, IsMail, IsActive)
VALUES ('AgentGibbs','Mr.','Leroy','J','Gibbs','3019321392','3019321393','[email protected]','14-JUN-1951','M','05-MAY-2012','N','Y');
INSERT INTO Profile (MemberID, FName, LName, PNumber, Email, BirthDate, DtCreate, IsMail, IsActive)
VALUES ('AgentBauer','Jack','Bauer','9193824028','[email protected]','18-DEC-1962','13-JAN-2012','Y','Y');
UPDATE Profile
SET AltPhone = ‘4648785495’
WHERE MemberID = ‘FlynHawaiian’;
20
INFO 605 – Term Project June 7, 2012 Joseph Healy
TABLE: SHIPPING
INSERT INTO Shipping (MemberID, SpAddr1, SpAddr2, SpCity, SpState, SpZip, IsPrimary)
VALUES ('TheDoc','1845 Main St.','Apt101','Tombstone','AZ','85638','Y');
INSERT INTO Shipping (MemberID, SpAddr1, SpAddr2, SpCity, SpState, SpZip, IsPrimary)
VALUES ('FlynHawaiian','21 Citizens Bank Park Way','Center Field Apt.','Philadelphia','PA','19019','Y');
INSERT INTO Shipping (MemberID, SpAddr1, SpCity, SpState, SpZip, IsPrimary)
VALUES ('AgentGibbs','101 NCIS Way','Washington','DC','20001','Y');
INSERT INTO Shipping (MemberID, SpAddr1, SpCity, SpState, SpZip, IsPrimary)
VALUES ('AgentBauer','911 CTU Ave','Los Angeles','CA','90001','Y');
UPDATE Shipping
SET SpAddr2 = ‘Apt102’
WHERE MemberID = ‘TheDoc’;
21
INFO 605 – Term Project June 7, 2012 Joseph Healy
TABLE: PAYMENT
INSERT INTO Payment (MemberID, CardNum, CardType, ExpDate, SecCode, CardNick, IsPrimary, BLAddr1, BLAddr2, BLCity, BLState, BLZip)
VALUES ('TheDoc','4548124565851232','C','01-MAR-2013','222','Pistol','Y','1845 Main St.','Apt101','Tombstone','AZ','85638');
INSERT INTO Payment (MemberID, CardNum, CardType, ExpDate, SecCode, CardNick, IsPrimary, BLAddr1, BLCity, BLState, BLZip)
VALUES ('FlynHawaiian','4545656584846868','D','01-JUN-2014','345','GoldGlove','Y','1241 Golden Glove Ave.','Maui','HI','96708');
INSERT INTO Payment (MemberID, CardNum, CardType, ExpDate, SecCode, IsPrimary, BLAddr1, BLCity, BLState, BLZip)
VALUES ('AgentGibbs','1199446878788787','C','01-MAR-2015','425','Y','101 NCIS Way','Washington','DC','20001');
INSERT INTO Payment (MemberID, CardNum, CardType, ExpDate, SecCode, IsPrimary, BLAddr1, BLCity, BLState, BLZip)
VALUES ('AgentBauer','6458946532510215','C','01-JAN-2013','911','Y','911 CTU Ave','Los Angeles','CA','90001');
UPDATE Payment
SET ExpDate = ’01-JAN-2015’
WHERE MemberID = ‘AgentBauer’;
22
INFO 605 – Term Project June 7, 2012 Joseph Healy
TABLE: MAILING
INSERT INTO Mailing (MemberID, Email, IsActive)
VALUES ('FlynHawaiian','[email protected]','Y');
INSERT INTO Mailing (MemberID, Email, IsActive)
VALUES ('AgentBauer','[email protected]','Y');
INSERT INTO Mailing (MemberID, Email, IsActive)
VALUES ('OchoCinco','[email protected]','Y');
INSERT INTO Mailing (MemberID, Email, IsActive)
VALUES ('Popcorn','[email protected]','N');
UPDATE Mailing
SET IsActive = ‘N’
WHERE MemberID = ‘OchoCinco’;
23
INFO 605 – Term Project June 7, 2012 Joseph Healy
TABLE: ORDERS
INSERT INTO Orders (OrderSeq, OrderNum, MemberID, DateTime, ItemNum, Qty, ShipCost, TrackNum, TotalPrice)
VALUES ('1000000001','Z1523-7475','FlynHawaiian','07-MAY-2012','G-1545','1','4.99','1674250453-3289453279','54.98');
INSERT INTO Orders (OrderSeq, OrderNum, MemberID, DateTime, ItemNum, Qty, ShipCost, TrackNum, TotalPrice)
VALUES ('1000000002','Z1523-7475','FlynHawaiian','07-MAY-2012','A-2900','1','8.99','1674250453-3289453279','63.98');
INSERT INTO Orders (OrderSeq, OrderNum, MemberID, DateTime, ItemNum, Qty, ShipCost, TrackNum, TotalPrice)
VALUES ('1000000003','Z1523-7475','FlynHawaiian','07-MAY-2012','A-2122','2','31.98','1674250453-3289453279','457.56');
INSERT INTO Orders (OrderSeq, OrderNum, MemberID, DateTime, ItemNum, Qty, ShipCost, TrackNum, TotalPrice)
VALUES ('1000000004','Z0294-8573','AgentBauer','15-MAY-2012','G-0032','1','4.99','4891651665-4568136123','54.98');
UPDATE Orders
SET TrackNum = '1674250453-3289839479'
WHERE OrderSeq = '1000000002';
24
INFO 605 – Term Project June 7, 2012 Joseph Healy
TABLE: ITEM
INSERT INTO Item (ItemNum, Price, ShipCat, Platform, StockQty, IsActive)
VALUES ('A-2900','54.99','2','PS3','27','Y');
INSERT INTO Item (ItemNum, Price, ShipCat, Platform, StockQty, IsActive)
VALUES ('A-2122','212.79','3','PS3','8','Y');
INSERT INTO Item (ItemNum, Price, ShipCat, Platform, StockQty, IsActive)
VALUES ('A-0074','29.99','1','XBOX','44','Y');
INSERT INTO Item (ItemNum, Price, ShipCat, Platform, StockQty, IsActive)
VALUES ('A-3948','10.99','1','PC','0','N');
UPDATE Item
SET IsActive = ‘N’
WHERE = ItemNum = ‘A-2122’;
25
INFO 605 – Term Project June 7, 2012 Joseph Healy
TABLE: GAME
INSERT INTO Game (ItemNum, Title, Producer, MatureRt, YearCt, Edition)
VALUES ('G-1545','Madden NFL 2012','EA Sports','E10+','2011','10');
INSERT INTO Game (ItemNum, Title, Producer, MatureRt, YearCt, Edition)
VALUES ('G-0032','Call of Duty: Black Ops','Treyarch','M','2011','7');
INSERT INTO Game (ItemNum, Title, Producer, MatureRt, YearCt, Edition)
VALUES ('G-0481','Call of Duty: Modern Warfare 3','Treyarch','M','2012','8');
INSERT INTO Game (ItemNum, Title, Producer, MatureRt, YearCt, Edition)
VALUES ('G-4125','Assassins Creed: Revalations','Ubisoft','M','2011','4');
UPDATE Game
SET MatureRt = ‘T’
WHERE ItemNum = ‘G-4125’;
26
INFO 605 – Term Project June 7, 2012 Joseph Healy
TABLE: ACCESSORY
INSERT INTO Accessory (ItemNum, AccType, Manuf, ModName, ModNum)
VALUES ('A-2900','Controller','Sony','Dual Shock 3','HAF8374');
INSERT INTO Accessory (ItemNum, AccType, Manuf, ModName, ModNum)
VALUES ('A-2122','SteeringWheel','Sony','Precision Steer 2','HAR4839');
INSERT INTO Accessory (ItemNum, AccType, Manuf, ModName, ModNum)
VALUES ('A-0074','Charger','Microsoft','Charge Master','938UE39');
INSERT INTO Accessory (ItemNum, AccType, Manuf, ModName, ModNum)
VALUES ('A-3948','Fan','ThermalTake','TT9000','TT43837-9000');
UPDATE Accessory
SET ModNum = ‘HAR4829’
WHERE ItemNum = ‘A-2122’;
27
INFO 605 – Term Project June 7, 2012 Joseph Healy
7. Sample Queries
To check on our average shipping costs for after a certain date:
SELECT Avg(ShipCost)AS AVGSHIPCOST
FROM Orders
WHERE DateTime > '08-MAY-2012'
Output:
AVGSHIPCOST
-----------
9.98
28
INFO 605 – Term Project June 7, 2012 Joseph Healy
To view the customers that have ordered more than one item from the store:
SELECT p.MemberID, Sum(o.Qty) AS SumQty
FROM Profile p, Orders o
WHERE p.MemberID = o.MemberID AND o.Qty > 1
GROUP BY p.MemberID
ORDER BY Sum(o.Qty) DESC
Output:
MEMBERID SUMQTY
------------ ----------
FlynHawaiian 4
AgentBauer 3
AgentGibbs 2
29
INFO 605 – Term Project June 7, 2012 Joseph Healy
To find our most valuable customer:
SELECT p.MemberID, Sum(o.TotalPrice) AS TotalSpend
FROM Profile p, Orders o
WHERE p.MemberID = o.MemberID AND o.TotalPrice > 0.01
GROUP BY p.MemberID
ORDER BY Sum(o.TotalPrice) DESC
Output:
MEMBERID TOTALSPEND
------------ ----------
FlynHawaiian 686.48
AgentBauer 159.92
AgentGibbs 129.96
30
INFO 605 – Term Project June 7, 2012 Joseph Healy
To find our most popular platform:
SELECT i.Platform AS PForm, Count(i.Platform) AS PlatformCount
FROM Item i, Orders o
WHERE o.ItemNum = i.ItemNum
GROUP BY i.Platform
Output:
PFOR PLATFORMCOUNT
---- -------------
PS3 5
XBOX 2
31
INFO 605 – Term Project June 7, 2012 Joseph Healy
To find our most popular item:
SELECT ItemNum AS Item, Sum(Qty) AS ItemQty
FROM Orders
GROUP BY ItemNum
ORDER BY Sum(Qty) DESC
Output:
ITEM ITEMQTY
------ ----------
A-0074 3
G-0032 3
A-2122 2
G-0481 2
A-2900 1
G-1545 1
32
INFO 605 – Term Project June 7, 2012 Joseph Healy
8. Certification
I certify that:
This project is entirely my own work.
I have not quoted the words of any other person from a printed source or a website without indicating what has been quoted and providing an appropriate citation.
I have not submitted this project to satisfy the requirements of any other course. Signature____Joseph Healy____ Date _____June 7, 2012______