Scaling API-first – The story of a global engineering organization
MSc Business with Information Technologies Data Management Module1 2010/2011 Database for HyperAV cinema company
1. University of Salford
Msc(Hons) Business with Information Technologies
Data Management Module1
2010/2011
Frederico Costa
@00255034
University of Salford Year 1
1|Page
2. 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
BZA764
descobreagr
SECTION A
Entity Relationship Diagram (ERD)
Works at
Customer Staff Location
Staffed by
Places Stores
Makes sale
Is placed Sold by Located at
by
Is for
Customer Stock Supplier
Order Part of
Is instance of Supplies Supplies
Has items Is supplied
Is supplied
of by
Part of by
Product Supplier Order
Consists of
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|Page
3. 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|Page
4. 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|Page
5. 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|Page
6. 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|Page
7. LOCATION_ID – Gives an ID to every single store
ALL THE OTHER DATA IS RELATIVE TO ADDRESS
Table 4
PRODUCT TABLE
7|Page
8. 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|Page
9. 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|Page
10. 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
11. 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
12. 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
13. 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
14. Total Stock
Stoc _Lond Stock_Newcast StockWarehous Stock_Manches
k on Stock_Cardiff Stock_York le e ter
97 29 3 5 10 30 20
195 77 18 20 20 30 30
73 40 10 3 5 10 5
999 400 100 80 20 300 99
Total
Total Room
Roo for
m for Stock Total Room Total Room Total Room for Total Room for Total Room for
Stoc Londo for Stock for Stock Stock Stock Stock
k n Cardiff York Newcastle Warehouse Manchester
100 30 5 5 10 30 20
200 80 20 20 20 30 30
90 40 10 5 15 10 10
1000 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
15. 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
16. QUERY PLAN
b) Create SQL code to list all products in stock, the stock level of
each 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
17. QUERY PLAN
c) Create SQL code to display all products which are in stock at the
Manchester branch and which have a price of over £500. The output
should 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
18. QUERY PLAN
d) Create SQL code to prompt the user for a supplier and to then
display 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
19. As an example it was shown all the attributes for SUPPLIER_ID 1.
QUERY PLAN
19 | P a g e
20. e) Create SQL code to display information about each customer and the
orders that they have placed. The output should include customers that
have not placed any orders. Sort the output by the date of the order.
(Note, you should ensure that your sample data properly demonstrates
this 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
22. 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
24. b) A report on the products sold by the company, including an analysis
page 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
25. 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
26. 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
27. 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