Sei sulla pagina 1di 12

ADVANCED

DATABASE CONCEPTS
Submission 1

Crazy Cat Pubs Database

UP872413 ADVANCED DATABASE CONCEPTS | Submission 1 Page 0 of 11


Table of Contents
Identified entities ........................................................................................................................................................... 2
Assumptions ................................................................................................................................................................... 2
ERD................................................................................................................................................................................ 4
Transaction analysis ...................................................................................................................................................... 5
Physical design .............................................................................................................................................................. 7
RDBMS ...................................................................................................................................................................... 7
Hardware ................................................................................................................................................................... 7
Database File System (DBFS) ................................................................................................................................... 8
Security ...................................................................................................................................................................... 8
Bibliography................................................................................................................................................................. 10
Appendices ................................................................................................................................................................... 11

ADVANCED DATABASE CONCEPTS | Submission 1 Page 1 of 11


Crazy Cat Pubs Database
Identified entities
Analysing the scenario for Crazy Cat Pubs, the following entities (Figure 1) were identified. However, some
of the entities are outside of the scope of the database or requires more clarification from the client. All the
assumptions leading to this design will be listed below.

Figure 1 - Identified entities

Assumptions
Note: The blue coloured entities are entities identified for future development and/or not covered by this case study.
Sales (Orders) – The main scope of this database is to record sales of food and drink, ORDER table and
ORDER_DETAILS table will record the sales.
Beverages – Because they are only two types of beverages will make more sense to record the drinks in same table
with an attribute (e.g. beverage type) and have an ENUM data type (VARCHAR2 with CHECK in Oracle) as ‘ALC’ and
‘NON-ALC’.
Food – I’m assuming that a customer can order additional elements to the menu. In this table will be stored individual
foods with their prices (e.g. chips, salad, bread etc.). Selecting from individual food items they can be added to the
order which can contain one or more menus, beverages and individual products.
Employees – I’m assuming that the CCP will record all employees details (e.g. name, address, contact etc.) regarding
of the employment type (full-time/FT or part-time/PT), a single table with employee details and an ENUM attribute as
staff type with the values of FT/PT should suffice. However, if the employment schema is more complicated I would
clarify this with the CCP.
SHIFTS - I’m assuming that a part-time staff (e.g. cleaners) can have different shifts in different locations in the same
area (e.g. CCP could have several locations in Portsmouth) or having double shift at the same location.
Figure 2 - Example staff shift

Therefore, a cleaner can have a rota like in Figure 2. Figure 3 - Shift overlap example
However, recording the shifts could generate shifts
overlapping and also an M: M relationship because staff can have multiple shifts at one location and a location would
have multiple staff with multiple shifts.

ADVANCED DATABASE CONCEPTS | Submission 1 Page 2 of 11


In Figure 3 we can observe two examples of
overlapping, where same employee (1) is
allocated at the same location (1), on same date
but overlapping hours (shift 1&2). The
employee is also allocated at a different
location (2) at the same date/time with location
1. In the above example only shift id 1 & 4
should be valid and shift id 2 & 3 should fail on
INSERT/UPDATE. To overcome this problem, a
trigger would be implemented (Figure 4) based
on Staff ID, Location ID, Date & Time which
will solve the overlapping and the M: M
Figure 4 - Shift trigger example
relationship. The trigger can be extended if it is
required to add 1-2 hours travel time for the
same date and same staff. For example, 1st shift is from 09 AM to 12PM. Hence, the 2nd shift cannot be sooner than 2
PM if is on a different location, but can start immediately if is on same location. Additionally, the trigger can be
configured to consider that a shift can also end after midnight (e.g. 10 PM – 4 AM). Therefore, that employee should
not be scheduled on a next day shift starting at 7 AM. However, if CCP has a more complicated shift management I
would clarify with them before implementation.
Region – Because in scenario is stated that soon Crazy Cat Pubs (CCP) will buy another large chain that will allow
them to expand into different regions, a new entity was introduced in ERD as REGION. At this stage of development
inserting a region entity will not have any impact over the performance of the database.
Stock Control – This requirement is outside of this database scope. The stock management alone is a very complex
subject and without more information about business logistic and management it cannot be implemented at this time
in this database. CCP could use a 3rd party application for stock management, but if this is a crucial requirement it can
be implemented after is clarified in detail with CCP. For an abstract representation of the stock management, please
see Appendix A.
Customers – Taking into account the new GDPR rules, the privacy issues that may arise and without knowing in
detail business logistic, managing the records for customers is a very complex subject. It must be careful considered
how and when to introduce customer details in the database. Perhaps a reservation system may be implemented, where
customers insert themselves their details. For this matter I would clarify this aspect with CCP.
Social Media - Instagram, Twitter or Facebook social media platforms have their own management systems and the
customer services team would manage these accounts directly on the media platforms. Introducing any aspect in the
database is irrelevant for this case study. Should the CCP desires a different approach a clarification must be brought.
Ratings - Companies as Trip Advisor are independent rating companies. In order to publish their ratings on the
business website this can be done through a plugin (widget) provided by the company (TripAdvisor, n.d.). No records
are necessary in the database. If CCP desires to create their own rating system (e.g. for each menu) this must be
clarified with CCP.
Other - Using mobile devices for taking order requires a mobile application development approach. For analysing this
feature a mobile development team should be consulted first. The mobile devices will require an interface (implicit
coding) in order to make possible communication between the database and the mobile device. At this point of the
case study, this feature is outside of the database scope.
- In order to determine who will have the rights to view/access the database, to add/view/edit orders or shifts I
need to clarify several aspects with CCP. As an example, the shifts can be added by the venue manager, human
resources department (if any) at the HQ or other designed employee. This clarification is a must in order to implement
the appropriate security measures.
- Payments are made through electronic tills and they are outside of the database scope.

ADVANCED DATABASE CONCEPTS | Submission 1 Page 3 of 11


ERD

Figure 5 - Crazy Cat Pubs ERD

UP872413 ADVANCED DATABASE CONCEPTS | Submission 1 Page 4 of 11


Transaction analysis
NOTE: Because the business rules are minimal described in the scenario, without identifying the business
needs, this transaction analysis was conducted using several assumptions.

Figure 6 - Entity vs Process Matrix


In Figure 6 we can observe a CRUD (CREATE, READ, UPDATE, DELETE) analysis of the CCP database.

I’m assuming that REGION and LOCATION entities will be very rarely U/D. Therefore, no analysis was
conducted because it will not have any impact over database performance.
In Figure 7 we can notice the transaction analysis form for the busiest transaction of the database, placing an
order. This analysis is done assuming that every location has 30 orders/h in peak times (30 orders x 60 locations),
creating a total number of transactions of 1800/h, with a total number of 14400/h references.
For the transaction ’adding a shift’ to the database, I’m assuming that is done well in advance and the
transactions will not run frequently. I’m assuming that the entries will be once per month with minimum updates
during the month. Therefore, it will not have any significant performance impact to the daily use of the database.

UP872413 ADVANCED DATABASE CONCEPTS | Submission 1 Page 5 of 11


TRANSACTION ANLYSIS FORM

Transaction: Placing an order by selecting location, shift, menu, beverage and food

TRANSACTION VOLUME
Average: 600/hour
Peak 1: 1800/hour (between 07AM – 10AM)
Peak 2: 1800/hour (between 12PM – 2PM)
Peak 3: 1800/hour (between 6PM – 8PM)

Transaction usage map

Number of reference
Type of
No. Name Per
Access Per Tran.
Period
1 Entry-requisition ORDER C 1 1800
2 Requisition LOCATION R 1 1800
3 Requisition SHIFT R 1 1800
4 Entry-requisition ORDER_DETAILS C 1 1800
5 Requisition MENU R 1 1800
6 Requisition BEVERAGE R 1 1800
7 Requisition FOOD R 1 1800
8 COMMIT write 1 1800
Total number of references 8 14400
Figure 7 - Transaction analysis form

ADVANCED DATABASE CONCEPTS | Submission 1 Page 6 of 11


Physical design
Note: For this case study the cost factor wasn’t taken in consideration and assumed that the business will prioritise
performance over the cost.
RDBMS
Despite the fact that MySQL is an open source with free download and can be more attractive for small-
medium business, for this case study, an Oracle RDBMS with the latest version 18c, was chosen and the factors
leading to this decision will follow.
At this point, as is stated in the case study, Crazy Cat Pubs “owns approximately 60 locations in the most
popular areas of large cities in the UK”. Soon they will buy another large chain allowing them to expand even to more
locations, creating a very busy environment querying the database from hundreds possible locations. With a single
integrated backend, Oracle supports multiple data models (e.g. documents, graphs, relational and key-value).
Supporting several types of indexes and OLTP (online transaction processing), Oracle offers a better performance and
flexibility over long term along with a very large support for other programming languages (e.g. PHP, Java, Perl,
FORTRAN, COBOL, Scala, Visual Basic etc.). All these features makes Oracle DB the perfect candidate for any
DBMS. With the Oracle RAC (Real Application Clusters) interconnection between several servers, will make any
transition for the multi-site database easier and perfect compatible. The management can be easily done with Oracle
Clusterware, a management solution integrated with Oracle database.
Another reason to choose Oracle as a database vendor, is the fact that it supports BEFORE & AFTER triggers
at row-level and statement-level (Zaniolo, et al., 1997) being very effective for data manipulation and controlling
INSERT|DELETE|UPDATE at the database level rather than application level.

On another note, in the future, CCP could plan to implement a data warehouse for analytic purposes (a
decision support system). Hence, investing in a different DBMS will not be necessary, because Oracle offers full
support for data warehousing (Oracle, 2017).
If we are looking at the transaction analysis we can notice that on average (at this point) the database perform
240 references per minute in peak time, and adding substantially more locations will increase the number of
transactions. Oracle RDBMS supports on average 100,000 transactions per minute with a top performing benchmark
of over 4m transactions per minute (Burleson, 2017). However, we must be aware that the high performance of a
database is closely linked to the hardware performance and hardware type (e.g. a SSD storage will be significantly
faster than an HDD storage type or an 8 core CPU will have a better performance than a 4 core CPU both of them with
the same speed).
Hardware
Oracle offer all-in-one solution with their own servers, optimized hardware, Intel® Xeon® Processor with up
to 24 cores, an average of 32GB RAM memory/core and 6 TB of main memory (Oracle, 2017). The servers can be
rented or bought. Therefore, investing time and money in new servers/config will be unnecessary. However, if CCP
decides that they would prefer to build their own servers from other brands/manufacturers, in order to optimize the
costs, Oracle RDBMS can be installed on any server configuration (Windows/Linux/AIX/HP-UX etc.) with a
minimum hardware requirements of 1GB RAM, HDD 5.22 GB (not taking in account the business required storage)
and a CPU with 550MHz. We can notice that the minimum requirements are very low and we must be aware that a
low performance system (server) will have impact over the overall database functionality. BMC, a very experience
company in IT management, states that the recommended hardware configuration for Oracle RDBMS should contain
at least 16 GB RAM and a CPU with 2.2 GHz with 4 cores and 16 threads (BMC, 2016).
Both approaches have advantages and disadvantages that must be discussed and clarified with CCP such as
using oracle server will have an initial low cost but on the long run can be proven very expensive, where using own
servers can have and initial very high cost but can save money overtime.
However, for CCP business I would recommend Oracle Server X7-8 System which is a modular system,
perfect compatible with Oracle RDBMS, prebuilt security features (e.g. prevents buffer overflow attacks; private
secure communication; hardware-enforced data execution prevention) and many more (Oracle, 2017). Adding
additional storage space at any point is very easy because the Oracle Server X7-8 System offers hot-swap
functionality.

ADVANCED DATABASE CONCEPTS | Submission 1 Page 7 of 11


In order to estimate the initial disk space requirement a simple calculation was made as follow:
Average data size is 80Kib (including index value size) and assuming an average of 300 orders per day for
each location, multiplied with 60 locations then multiplied with average opening days of 350 days (80Kib x 300 x 60
x 350) results approximatively 42Gb/Year space requirement. This is a rough estimation without considering staff,
location records, backups and assuming that the locations are closed 15 days/year (bank holydays, Christmas, etc.). By
rounding up the estimated disk size for one year would be around 50GB. An initial 1TB disk space should cover the
business needs for next 2-3 years (soon they will buy another large chain and number of records will increase
exponentially). For a more precise calculation, an analysis of their past orders, business logistic and rules is required.
Database File System (DBFS)
Using the right indexing method is a crucial process for achieving high performance in modern on-line
transaction processing databases. A group of researchers from Brown University highlighted the high efficiency of the
hybrid indexes, a dual-stage index architecture that achieves both space efficiency and high performance (Andersen, et
al., n.d.). To increase database performance, query optimisation and storage overhead, several indexes will be added to
the database, a hybrid indexing. Having many entries during the day, using unordered records (Heap Files) will speed
up the insert process, which is a very efficient way because the last disk block of the file is copied into a buffer, the
new record is added, and the block is then rewritten back to disk and the address of the last file block is kept in the file
header (Elmasri & Navathe, 2011). On the other hand, searching will be an expensive procedure because any search
condition will involve a linear search but ORDERS will be mostly INSERT statement, using Heap Files is an
acceptable compromise. Using a spanned organization at certain intervals will improve data access.
Oracle Database can full scan the index instead of the table (Saxon, 2017) and in order to make a compromise
between making the queries as fast as possible and overall system impact, using a balanced B-Tree index is the most
practical solution. However, we must note that Oracle Database reads an index starting with its leftmost (“first”)
column (e.g. col1, col2, col3) and then moves onto the 2 nd, 3rd. So having index on col3, will have a performance
impact. Optimising columns order by placing the index leftmost, will increase overall performance. Compressing an
index will effectively remove duplicates in its leading column(s). This can shrink the size of an index drastically,
saving disk space meaning that there will be less data to scan when querying (Gillenson, et al., 2008).
Security
As any other DB in the world, CCP database is vulnerable to attacks. Yet, taking into account the potential
threats we can reduce the risk but not totally eliminate them because is a well-known fact that no database is “hack-
proof”. Hacking is the only one of the many security risks that a database is exposed along with physical damage, data
corruption, natural disasters, data degradations, hardware failure, 3rd party integrated software, users (regular users and
administrators) or even design flaws. Some of the results of the security breaches of a database would be: loss of
privacy, integrity, availability, confidentiality or theft and fraud (Connolly & Begg, 2015).
The access to the database needs to be limited and only the person with the right authorisation must be able to
input/edit or delete data. It is imperative to not confuse the authentication with authorization. Authentication will
allow the user to login to the system where authorization will constrain what to access into the system (privileges).
Oracle recommends that the database to be configured to prevent any regular users (non-DBA) exercising ANY
system privileges such as modifying data dictionary (Oracle, n.d.). Therefore, managing user privileges and roles is a
must for the CCP database. No user should be granted more access than is necessary (e.g. a cleaner should have access
only at the shifts time-table and not to the orders). In other words, a multi-level security measure by classifying the
data and users into various access levels and then implementing the appropriate security policy of the organization.
Keeping track of the logging session on the database along with all operations through the system log is a
method of monitoring and recovery in case of a system crash or transaction failure (Elmasri & Navathe, 2011).
Last but not least, a physical security is a must for the location where database is stored. In a research paper
published by the SANS Institute, Hutter highlights that physical security it is often overlooked because most of the
business are focused only on technology-oriented security countermeasures (Hutter, 2016) in order to prevent hacking
attacks, but they are doing very little to prevent physical access to a server. Therefore, the investments into physical
security should be equally important as cybersecurity, including CCTVs, security gates with key access cards etc.

ADVANCED DATABASE CONCEPTS | Submission 1 Page 8 of 11


In order to prevent any accidental data deletion a web interface between users and database is a must. Using a
graphical interface to insert/update shifts or orders, would have the advantage to be accessed from any mobile device,
and will suffice one of the requirements to take orders at the tables rather than ordering at the bar.
However, the proposed DB design does not contain any security measures and creating a web interface will
require additional development steps such as modification of the existing ERD. This requires insertion of
authentication methods (username, password), deciding what user will insert/update shifts (creating users categories),
who can read the shifts and who can write (e.g. if a user can see all shifts and orders or for example a cleaner can read
their shift only without access to the orders, where a pub manager can read shifts and orders.). Therefore all these
aspects of the business must be clarified with CCP.

ADVANCED DATABASE CONCEPTS | Submission 1 Page 9 of 11


Bibliography
Andersen, D. G., Zhang, H., Pavlo, A., Kaminsky, M., Ma, L., & Shen, R. (n.d.). Reducing the Storage Overhead of
Main-Memory OLTP Databases with Hybrid Indexes. Retrieved from Brown University:
http://hstore.cs.brown.edu/papers/hstore-hybridindexes.pdf
BMC. (2016, Jan 08). Hardware requirements to support small, medium, and large environments. Retrieved from
BMC.com:
https://docs.bmc.com/docs/display/public/tsim10/Hardware+requirements+to+support+small%2C+medium%
2C+and+large+environments
Burleson, D. (2017). Oracle breaks 60,000 transactions per second barrier. Retrieved from Burleson Consulting:
http://www.dba-oracle.com/oracle_news/news_world_record_tpcc_hp.htm
Connolly, T., & Begg, C. (2015). Database Systems: A Practical Approach to Design, Implementation and
Management. Harlow: Pearson Education Limited.
Elmasri, R., & Navathe, S. B. (2011). Fundamentals of Database Syestems. Boston: Addison-Wesley.
Gillenson, M. L., Ponniah, P., Kriegel, A., Trukhnov, B. M., Taylor, A. G., Powell, G., & Miller, F. (2008).
Introduction to Database Management. Hoboken: Wiley.
Hutter, D. (2016, Jun 10). Physical Security and Why It Is Important. Retrieved from SANS Institute InfoSec Reading
Room: https://www.sans.org/reading-room/whitepapers/physical/physical-security-important-37120
Oracle. (2017). Database Data Warehousing Guide. Retrieved from Oracle.com:
https://docs.oracle.com/database/121/DWHSG/concept.htm#DWHSG-GUID-452FBA23-6976-4590-AA41-
1369647AD14D
Oracle. (2017, Sep). Oracle Server X7-8 System Architecture. Retrieved from Oracle.com:
http://www.oracle.com/us/products/servers/arch-wp-oracle-servers-x7-8-3852568.pdf
Oracle. (n.d.). Managing User Privileges and Roles. Retrieved from Oracle.com:
https://docs.oracle.com/cd/A97630_01/server.920/a96521/privs.htm
Oracle. (n.d.). Oracle Database File System (DBFS). Retrieved from Oracle.com:
https://docs.oracle.com/database/121/VLDBG/GUID-6B5634D3-D539-4D1F-ABA3-
0C903AC28639.htm#VLDBG14099
Saxon, C. (2017, Aug 10). How to Create and Use Indexes in Oracle Database. Retrieved from Oracle.com:
https://blogs.oracle.com/sql/how-to-create-and-use-indexes-in-oracle-database
TripAdvisor. (n.d.). TripAdvisor Widgets. Retrieved from tripadvisor.com: https://www.tripadvisor.co.uk/Widgets
Zaniolo, C., Ceri, S., Faloutsos, C., Snodgrass, R. T., Subrahmanian, V. S., & Zicari, R. (1997). Advanced Database
Systems. San Francisco: Morgan Kaufmann Publishers, Inc.

ADVANCED DATABASE CONCEPTS | Submission 1 Page 10 of 11


Appendices

Appendix A - Stock inventory management (Abstract)

ADVANCED DATABASE CONCEPTS | Submission 1 Page 11 of 11

Potrebbero piacerti anche