29
University of Salford Msc(Hons) Business with Information Technologies Data Management Module1 2010/2011 1 | Page

Report oracle Frederico Costa

Embed Size (px)

DESCRIPTION

Report about Oracle Database created by Frederico Costa

Citation preview

Page 1: Report oracle Frederico Costa

University of SalfordMsc(Hons) Business with Information TechnologiesData Management Module12010/2011

Frederico Costa @00255034

University of Salford Year 1

1 | P a g e

Page 2: Report oracle Frederico Costa

Introduction

HyperAV is a company inserted in the cinema and hi-tech market. In this Individual Assignment, based on Oracle I created a Database (from now on known as DB) that could be used by this company in order to be helpful to run and organise the business itself.The DB includes all the stores based in London, Manchester, York, Newcastle, Cardiff and the warehouse located in Birmingham.It also shows useful information about sales, staff, customers, suppliers, products and stock.For this assignment I created random names and addresses, phone numbers and products.I would like to thank my lecturer Andrew Schofield for all the support and patience, advice and instructions.This Assignment is divided in Section A, Section B and Section C and this report will follow the same structure.

LOGIN and PASSWORD

BZA764descobreagr

SECTION A

Entity Relationship Diagram (ERD)

A customer places an order in a store. It is created an order, a form is given to a customer and a staff sells an item. (Customer_Order Table ; Customer Table; Location Table; Stock Table).

A product is chosen by a customer and is sold by a store, taken from that store. A supplier is contacted to supply this product. A order is made by the store to the supplier, which delivers it in the

2 | P a g e

Customer

Customer Order

Stock

Product

Location

Supplier

Supplier Order

Staff

Places

Is placed by

Sold by

Makes sale

Is for

Part of

Works at

Staffed by

Stores

Located at

Is instance of

Has items of

Supplies

Is supplied by

Supplies

Is supplied byPart of

Consists of

Page 3: Report oracle Frederico Costa

warehouse (Birmingham) and then is sent to the store that ordered the product.( Stock Table ; Product Table ; Supplier Table; Supplier_Order Table).

It works as a group of tables that have an incremental primary key. Various primary keys become foreign keys in different tables.

Entity Relationship on Database

This represents the attributes and system design. All the primary keys and foreign keys are specified by colour and the same happens with any related value (i.e. “Location_ID”).

Many staff works in a Store – a store is a workplace for many Staff

Many Customers goes to many stores – a store takes many customers

3 | P a g e

Page 4: Report oracle Frederico Costa

A customer chooses many products – many products can be chosen by many customers

Many customers places many orders – many orders can be placed by a customer

Many stores stocks many products – many products are stocked by many stores

A Stock controller controllers many products – each product is controlled by a stock controller

A supplier supplies one and a product (each supplier supplies only one) – a product is supplied by one and only one supplier.

This Database consists in 8 Tables.

Table 1: HYPERAV_CUSTOMER

4 | P a g e

Page 5: Report oracle Frederico Costa

Taken from a customer form, Customers give their details to become part of the Database.

CUST_ID – Increments a customer by time order (e.g. first customer have ID 1) ;

CUST_TITLE – Identifies a customer as Mr, Mrs, Miss, Dr, Dra ; ALL THE OTHER DATA IS RELATED WITH ADDRESS AND CONTACTS

Table 2

CUSTOMER ORDER

5 | P a g e

Page 6: Report oracle Frederico Costa

CUST_ORDER_ID – Increments a new order made by a customer

CUST_ORDER_DATE – Indicates the date that the order was made

CUST_PAYMENT_METHOD – Shows the method used to purchase the item(s)

CUST_ORDER_NOTES – notes relative to order (e.g. Delivery)

CUST_ID – Foreign Key from CUSTOMER table

STAFF_ID – Foreign key from STAFF table

Table 3

LOCATION

6 | P a g e

Page 7: Report oracle Frederico Costa

LOCATION_ID – Gives an ID to every single store

ALL THE OTHER DATA IS RELATIVE TO ADDRESS

Table 4

PRODUCT TABLE

7 | P a g e

Page 8: Report oracle Frederico Costa

PRODUCT_ID – Defines an ID to a product

PRODUCT_PRICE – Defines a price for a product

SUPPLIER_ID – Foreign Key from SUPPLIER_ID

ALL THE OTHER ARE RELATED WITH THE TYPE AND COMPANY FOR THE PRODUCT

8 | P a g e

Page 9: Report oracle Frederico Costa

Table 5

STAFF TABLE

STAFF_ID – Generates an ID for a Staff member

STAFF_SALARY – shows the salary paid for each Staff member, it varies on the Location;

LOCATION_ID – Foreign Key from LOCATION Table

ALL THE OTHER ARE RELATED TO STAFF ADDRESS

9 | P a g e

Page 10: Report oracle Frederico Costa

Table 6

STOCK TABLE

STOCK_ID – Generates an ID for every order made by a store (or for a store) to a Supplier

CUST_ORDER_ID – Foreign Key from Customer Order Table

PRODUCT_ID – Foreign Key from Product Table

LOCATION_ID – Foreign Key from Location Table

10 | P a g e

Page 11: Report oracle Frederico Costa

Table 7

SUPPLIER TABLE

SUPPLIER_ID – Generates an ID to identify the product Supplier

ALL THE OTHER ARE RELATED TO SUPPLIER DETAILS

NOTE: Supplier table has a “one to many” relationship with the SUPPLIER_ORDER. A supplier gets many orders but just delivers one type of product.

11 | P a g e

Page 12: Report oracle Frederico Costa

Table 8

SUPPLIER_ORDER

SUPPLIER_ORDER_ID – Generates an ID to an order from a store to a supplier

SUPPLIER_ID – Foreign Key from SUPPLIER Table

PRODUCT_ID - Foreign Key from Product Table

LOCATION_ID - Foreign Key from Location Table

SUPPLIER_ORDER_QUANTITY – shows number of items ordered to every different product. This Stock is delivered in the Warehouse (Birmingham) to be re-sent to fulfil stock in other stores.

12 | P a g e

Page 13: Report oracle Frederico Costa

Assuptions

All the tables are populated with no more than 10 fields.

Although not all the data might be real, there are some assumptions that were made and needs to be considered in this report.

Customer Orders

All the orders are updated until the end of October.

Products

The products are categorized in 4 groups:

TV

Mobile

Computer

Accessories

Store

There’s only a cashier per store, the other 2 (or 1 in some cases, explained in the Store’s assumptions) are sales assistants and Supervisor, so only 1 member of staff per store makes the sale (i.e. Simon in London).

Supplier Order

The quantity of items ordered from the suppliers depends on the sales that the company had on the previous month. The figures in Supplier_order table determine how many items the company can store.

Staff

Birmingham Warehouse allocates a employee to ensure all the stock transfers and deliveries.

Birmingham as been set as a store too.

Stock

The stock is updated until the end of October.

There’s a table that shows how many items can be stored.

13 | P a g e

Page 14: Report oracle Frederico Costa

Total Stock

Stock_London Stock_Cardiff Stock_York

Stock_Newcastle

StockWarehouse

Stock_Manchester

97 29 3 5 10 30 20195 77 18 20 20 30 3073 40 10 3 5 10 5999 400 100 80 20 300 99             

Total Room for Stock

Total Room for Stock London

Total Room for Stock Cardiff

Total Room for Stock York

Total Room for Stock Newcastle

Total Room for Stock Warehouse

Total Room for Stock Manchester

100 30 5 5 10 30 20200 80 20 20 20 30 3090 40 10 5 15 10 101000 400 100 80 20 300 100

This table shows that London and Manchester are bigger stores and that’s why they have more staff and more room for stock (it doesn’t mean that the sales have to be better).

Procedures description

A customer goes to a store to buy something. The customer is helped to choose the best item for himself by a sales assistant or Supervisor and pays on the till. The cashier check if the item is available in the store. If it is not available it is ordered from the warehouse.

The system is updated and the Stock Controller orders the sold item from the supplier to replace the item sold so the company can always have it’s maximum stock always available.

The customer’s order is inserted on the system and delivered (if required).The delivery is free. For every customer is created an ID and the same is automatically done for the order too.

14 | P a g e

Page 15: Report oracle Frederico Costa

SECTION B

QUERIES

a)      Create SQL code to list all staff members and the branch at which they work.

 Select * from HYPERAV_STAFF  NATURAL INNER JOIN HYPERAV_LOCATION ;

In this Query it was select ‘everything’ from HYPERAV_STAFF and was used a NATURAL INNER JOIN to relate with HYPERAV_LOCATION. This way all staff members were listed and related to its branch.

15 | P a g e

Page 16: Report oracle Frederico Costa

QUERY PLAN

b)      Create SQL code to list all products in stock, the stock level ofeach product and the total value of stock for each product.

Select PRODUCT_ID, PRODUCT_DESCRIPTION, COUNT(STOCK_ID) STOCK_LEVEL, SUM(PRODUCT_PRICE) TOTAL_VALUE from HYPERAV_STOCK  NATURAL INNER JOIN HYPERAV_PRODUCT GROUP BY PRODUCT_ID, PRODUCT_DESCRIPTION ;

This query lists all products in stock (stock level) and total value (note that before it was shown the ideal stock but that is business strategy, not business reality so I assumed the stock on replacing what is sold gets stocked again, that is why the actual stock is only a re-stock of what was sold.

16 | P a g e

Page 17: Report oracle Frederico Costa

QUERY PLAN

c)      Create SQL code to display all products which are in stock at theManchester branch and which have a price of over £500. The outputshould be sorted by price.

SELECT * FROM HYPERAV_LOCATION NATURAL INNER JOIN HYPERAV_STOCK NATURAL INNER JOIN HYPERAV_PRODUCT WHERE LOCATION_TOWN_CITY like 'Manchester' and PRODUCT_PRICE > 500 ORDER BY PRODUCT_PRICE

This query displays all products which are in stock at Manchester Branch with a price over £500.

Note: It could be done with this code too ‘SELECT * FROM  HYPERAV_STOCK NATURAL INNER JOIN HYPERAV_PRODUCT WHERE LOCATION_ID =2 and PRODUCT_PRICE > 500 ORDER BY PRODUCT_PRICE’

17 | P a g e

Page 18: Report oracle Frederico Costa

QUERY PLAN

d)      Create SQL code to prompt the user for a supplier and to thendisplay all products which the chosen supplier offers.

SELECT * FROM HYPERAV_SUPPLIER NATURAL INNER JOIN HYPERAV_PRODUCT WHERE SUPPLIER_ID= :ENTER_ID

This code creates a prompt that gives the opportunity to choose the SUPPLIER_ID and check all its attributes.

18 | P a g e

Page 19: Report oracle Frederico Costa

As an example it was shown all the attributes for SUPPLIER_ID 1.

QUERY PLAN

19 | P a g e

Page 20: Report oracle Frederico Costa

e)      Create SQL code to display information about each customer and theorders that they have placed. The output should include customers thathave not placed any orders. Sort the output by the date of the order.(Note, you should ensure that your sample data properly demonstratesthis query, i.e. that it shows customer with no orders)

SELECT * FROM HYPERAV_CUSTOMER LEFT OUTER JOIN  HYPERAV_CUSTOMER_ORDER ON HYPERAV_CUSTOMER.CUST_ID =HYPERAV_CUSTOMER_ORDER.CUST_ID ORDER BY CUST_ORDER_DATE;

This Query shows all the customers and the orders placed by them.This Database didn’t have a customer without orders because it was assumed that all the customers would fill the form on the first purchase but it was created a “Test” customer, ID 21 to show that the code is working.

20 | P a g e

Page 21: Report oracle Frederico Costa

QUERY PLAN

           

21 | P a g e

Page 22: Report oracle Frederico Costa

SECTION C (APPLICATION BUILDER)

a)      Forms for inputting customer and customer order details

CUSTOMER FORM (Blank)

- To become a customer and be inserted in the system;

22 | P a g e

Page 23: Report oracle Frederico Costa

CUSTOMER ORDER FORM (blank)- To place an order;

23 | P a g e

Page 24: Report oracle Frederico Costa

b)      A report on the products sold by the company, including an analysispage which show a pie chart of the different types of products.

Products sold by the company and report of turnover by product (value obtained).

The Chart cannot be shown in the actual report because it is necessary a SVG viewer and the actual computers cannot download it (no administrator permission in computers in University) but it is available on the Oracle Platform.

24 | P a g e

Page 25: Report oracle Frederico Costa

Conclusion

This report is expected to fulfil all the tasks from section A, B and C for this assignment and to explain the strategy plan for this company (just about the database).

It correspond to the use of queries, input forms and reports but more utilities from an Oracle Platform can be used such as SQL Queries, Application Builders and in a forward stage, connect databases with MYSQL and PHP or to create Retail Databases more developed.

25 | P a g e