Project: System. A Database Is A Collection of Structured Information Like The 200 Order Forms, All With

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Project

Submission: In the root of your home directory on the network drive you should create a directory
named hct211prac2013. Inside this directory create a sub directory after your registration number.
NB these directory names must be specified in lowercases e.g. hct211prac2013/r0020101. Save all
your solutions in the sub folder that you created.

Below is Mr Owens’ experience in one of the companies he worked for. Go through it and
help fix his problems.
***************************************************************************
***
One of my summer jobs during high school was working for a company called Plastronics in
Kwekwe. They made packaging for all kinds of different products. The founder of the
company, Mr Gift, was the first manufacturer of the styrofoam peanut. He was also my
father's golf buddy (which is how I acquired this stimulating summer position). Usually, I
worked in the factory cutting up styrofoam with big frames of hot wires, but one day, I was
asked to come and work in the Office. I was given the task of sorting about 200 order forms,
and typing the various pieces of information on those forms into a paper grid on a typewriter.
Now, computers did exist at that time, but Plastronics did not have one. So, all order
processing was done manually.

A computer would have saved me much time. But then, I didn't really mind typing when the
alternative was burning my fingers on hot wires. Nonetheless, what I needed was a database
system. A database is a collection of structured information; like the 200 order forms, all with
the same information. Contrast this to unstructured information, like the text of a book.
A database system would have allowed me to enter my information into a grid, but it would
have been stored in a computer, rather than on paper. Once stored, I could sort the orders,
organize and manipulate the data anyway I like, print various reports based on conditions
such as: "print the name, phone number and order size for all orders where total_amount >
$1000000". This would represent our biggest customers, and potential new golf buddies for
Mr. Gift and my father. In database terminology, the grid is called a table. The information
corresponding to one order (or row in the grid) would be stored in a record. The individual
data elements, for example, name, phone number, order size (stored in the columns) are
called fields.
Most databases consist of more than one table. In fact, it is the norm to have multiple tables
in order to, among other things, avoid storing redundant data. For example, maybe several of
the 200 Plastronics orders are all from the same customer. It's inefficient to store the name,
address, and other contact information multiple times.
***************************************************************************
***

i. Identify entities, attributes and relationships from Mr Owens’ experience.


[3]

ii. Using MySQL Workbench, draw the entity relation diagram for this company. [5]
iii. Convert the ERD to relational schema. [5]

iv. Decompose the relational schema to BCNF showing all the steps involved.
[8]

v. Given the following relations


Customer(CustomerNumber, Name, Address, Phone)

Order(OrderNumber, CustomerNumber)

Items(ItemNumber, Price)

ItemDetails(OrderNumber, ItemNumber, Count)

Using MySQL Workbench;

a. Create a database called plastronics


[1]

b. Create tables for above listed relations


[4]

NB. Auto generated primary keys must starting at 1

c. Enter the following data into the tables and show each table after data entry.
[8]

Customer
CustomerNumber Name Address Phone
Joe Boo 123 West 412-773-5322
Rich Wrack 332 East 412-773-8374
Ken Bend 225 Main 412-773-9822
Kim Slim 415 Bent 412-773-6721
Tom Plom 633 North
Items
Order OrderNumbe CustomerNumber
ItemNumber Price r
6666 4
7000 3
450 4
1200 1
2
ItemDetails 1
OrderNumb ItemNumb Count 2
er er 3
1 4 12 4
1 3 56 5
2 1 10
3 2 43
3 4 16
4 2 87
5 1 62
5 2 48
5 3 5
6 3 87
7 2 32
7 1 27
8 4 91
9 2 34
9 3 72
10 4 2

d. Queries

i. Show name and phone number from customers whose number is


greater than 3.
[2]

ii. Show order numbers for item details with count greater than 25.
[2]

iii. Show everything from customer table.


[1]

iv. Find all orders that include item #4 (only list the order numbers once).
[2]

v. Show all orders for customer #2.


[2]

e. Add the following to orders table

OrderNumber CustomerNumber
10
11

i. Combine the orders and customer tables using the customer number,
showing the resulting tables after, inner join and left join. [3]

ii. Can you list the total amount for each order as well as the sum of the
item counts? This requires a join along with GROUP BY. [4]

**************************************************************************

You might also like