Detailed Explanation of Part 2

advertisement
DBS201 Assignment 1 - (7 Marks)
DataBase Implementation - Super Dave’s Video
Due Date: Tuesday June 22, 2010
In this assignment you will:
1.
2.
3.
4.
Create a DB2 database with several tables.
Insert data into the database.
Create views.
Prepare some reports using tables and views
Please Note:
This assignment is to be done in groups of 2 or 3 students. Group work is one of the
specific learning outcomes of DBS201. Submissions done by a single student will incur a
penalty of 20%. Late penalties are 20% per school day. Please include each group
member’s names on an: Assignment Submission Form . The appearance of a student’s
name on this document will be considered as his/her signature.
Submission Requirements - There are 7 parts to be handed-in:
Part 1: The Assignment Submission Form
Part 2: The Table Physical Design Sheets. (1 per table)
Part 3: The CREATE TABLE commands. (1 per table)
Part 4: The CREATE VIEW commands. (1 per view)
Part 5: The reports showing the contents of each table. (1 report per table).
Part 6: The reports using the VIEWs (1 report per view)
Part 7: For part 7, indicate the i-series account, password, and the collection name where your
professor can mark your work.
You will develop your SQL commands on the i-series computer. When you are sure that your
SQL command is working, copy and paste it into an Open Office Writer document (or a
Microsoft Word document). Copy all answers into a single document. Attach your document to
an email and send it to your professor.
This assignment must be handed-in using email.
The Subject line must be: DBS201-A1.
All SQL commands must be properly formatted.
The submission should be well-organized and follow appropriate naming conventions.
Assign. 2
1 of 6
Description of the Operations of Super Dave’s Video Store
The Super Dave’s Video Store was created to address the pent-up demand of students (and
their families) living in near-by residences and has been modelled on the same principles that
have made Blockbusters and Rogers Video such successful operations. The stores offer
rentals of new and not-so-new DVDs and VHS films, Playstation and Nintendo games. The
stores also sell ‘junk’ food items such as soft drinks, chips and candy, making them one-stop
entertainment centers. Attached are 2 examples of the Video Store Rental Agreement. For all
intents and purposes, this Rental Agreement is like a Sales Invoice, the only difference being
that the store expects the rentals to be returned. In order to support this rental agreement, eight
(8) separate tables are necessary.
Note that for each rental agreement, there can be more than one rental as identified by the Item
number, and that a rental can appear on more than one rental agreement provided it does not
occur on the same day.
SUPER DAVE’S VIDEO STORE RENTAL AGREEMENT
(Sample 1)
STORE PHONE:
416-555-2222
AGREEMENT #:
MEMBERSHIP#:
CUST PHONE#:
SALESPERSON:
725
AGREEMENT DATE:
June 7, 2010
1241
NAME:
Maria Valdez
(416)491-5050
ACCT#: 04123-1943-2588
14, Donnie Osmond
RENTALS:
TYPE ITEM
DVD 154
DVD 78
VHS
133
VHS
98
PURCHASES:
NAME
Twizzlers
Diet Coke
TITLE
Tailor of Panama
Die Harder
Emperor’s New Groove
Mulan
SIZE
300 g
600 ml
CATEGORY
New Release
Regular
New Release
Children
QUANTITY
1
2
METHOD OF PAYMENT: Cash / MC / VISA
DUE DATE
2010/06/08
2010/06/12
2010/06/08
2010/06/14
EACH
1.99
1.00
CHARGE
1.99
2.00
SUBTOTAL: $16.95
HST:
2.20
====
TOTAL:
19.15
=====
PAYMENT: $19.15
BALANCE DUE:
Assign. 2
CHARGE
3.99
2.49
3.99
2.49
$0.00
2 of 6
SUPER DAVE’S VIDEO STORE RENTAL AGREEMENT (Sample 2)
STORE PHONE:
416-555-2222
AGREEMENT #:
MEMBERSHIP#:
CUST PHONE#:
SALESPERSON:
726
1138
(647)342-1539
12, Zhi Huang
RENTALS:
TYPE ITEM TITLE
VHS
155
Tailor of Panama
DVD 13
Bambi
PURCHASES:
PRODUCT
Twizzlers
SIZE
300 g
AGREEMENT DATE:
June 7, 2010
NAME:
Olga Putin
ACCT#: 04123-1943-2543
CATEGORY DUE DATE CHARGE
New Release 2010/06/08 3.99
Children
2010/06/14 2.49
QUANTITY
2
EACH
1.99
CHARGE
3.98
SUBTOTAL:
HST:
METHOD OF PAYMENT: Cash / MC / VISA
$10.46
1.36
=====
TOTAL:
$11.82
=======
PAYMENT:
$11.82
BALANCE DUE:
Assign. 2
$0.00
3 of 6
Detailed Explanation of Part 1:
In Open Office or WORD, include the 8 Physical Design Sheets - (1 per table)
Before we create the tables we first prepare a physical schema. There we define the attributes,
with their data types, field sizes and constraints. This step allows the designer to concentrate on
what type of data the table will contain and what constraints will be needed so that the database
can support the user’s needs.
The constraints that you must consider in this design include the following:
a)
b)
c)
d)
e)
Primary Key ( the unique identifier of all attributes on a relation)
Foreign Key ( a non-key attribute that references the primary key of another table)
Not Null ( a required field or attribute)
Unique ( a value that cannot be repeated in a column)
Check (validation; a restriction on the data that can be entered in this column)
Table Name:
Column Name
Type
Length
PK
FK
Req’d
Unique
Validation
(Please feel free to copy this model for your physical layout)
Assign. 2
4 of 6
The following relations form part of the database for Dave’s Video.
The COLLECTION name is DAVxxx where xxx is the last 3 characters of your dbs201 account
on the i-series.
Table Name
Attributes
Agreement
[Agreement#, AgreementDate, Memb#(FK),
SalesPerson#(FK), PaymentMethod, PaymentAmt]
Member
[Member#, MemFName, MemLName, MemPhone,
Account#]
SalesPerson
[SalesPerson#, EmpFName, EmpLName]
Rental_Item
[RentalItem#, RentalType, Title, Category(FK), Due Date]
Category
[CategoryId, CategoryDesc, Charge]
RentAgreement_Purchase [Agreement#, Product#, Qty]
Product
[ProductId, PdtName, PdtSize, PdtUnitPrice ]
Agreement_Rental
[ Agreement#, RentalItem# ]
Assign. 2
5 of 6
Detailed Explanation of Part 2:
In your Open Office or WORD document, include the CREATE TABLE commands for the 8
tables. Choose a group member i-Series account and create a collection named DAVxxx (where
xxx is the last 3 characters of your userid). Create the eight tables defined above. Column
names must be the same as those shown in the physical schema. Use proper
formatting(indenting).
Detailed Explanation of Part 3:
In your Writer or WORD document, provide the CREATE VIEW commands for the following two
views:
A. A view called AGREEMENTINFO which will contain all the attributes shown on
agreements for all orders. (see sample agreements above). Think about how many joins
you will need. Use proper formatting(indenting).
B. A view called AGREEMENTINFO725 which can be used to produce all the attributes
on Agreement Number 725 . Use proper formatting(indenting).
Detailed Explanation of Part 4:
In your Writer or WORD document, provide the syntax to insert the data shown on the two
sample agreements shown above.
Detailed Explanation of Part 5:
In your Writer or WORD document, provide screen shots of the contents of each table (all rows)
Detailed Explanation of Part 6:
In your Writer or WORD document, provide screen shots when you run a
SELECT * from ‘viewname’ command for both views created above.
You will not be producing a formatted agreement, but your output will show all the column
names and data values.
Detailed Explanation of Part 7:
In your Writer or WORD document , indicate the collection name, i-series account, and
password and the where your professor can mark your work
Assign. 2
6 of 6
Download