Os DDD

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 54

1

Unit 5.2
Database design and development
OSAMA ARSHAD | 19/04/2021
Module leader: Miss Loraine Annie

localhos
2

Contents
Task 1......................................................................................................................................4
Identifying Entities and their attributes..............................................................................................4
Mapping/ Cardinality.........................................................................................................................6
Entity relationship Diagram for the scenario......................................................................................7
1.b) Normalise the data to 3rd normal form........................................................................................7
Normalisation.....................................................................................................................................7
1.c) Produce design documentation in response to the client brief ensuring this shows the design of
the tables, constraints, SQL queries, forms and security measures..................................................12
This provides evidence for LO2- [2.2]................................................................................................12
Data Dictionary.................................................................................................................................12
Data Dictionary Tables:....................................................................................................................13
Constraints.......................................................................................................................................15
Entity Integrity Constraints...............................................................................................................15
INDEX...............................................................................................................................................16
TRIGGER...........................................................................................................................................16
FORMS..............................................................................................................................................17
SECURITY MEASURES (DAC,MAC,RBAC)............................................................................................18
i. RBAC (Role Based Access Control)..............................................................................................................18
ii. DAC (Discretionary Access Control)............................................................................................................19
MAC (Mandatory Access Control)........................................................................................................................20

Task 2....................................................................................................................................22
2.a) Implement the database using the designs you have created in Task 1. Ensure that your
database includes all the features you designed in activity one.......................................................22
Screen shots of all tables..................................................................................................................22
Screen shots of all constraints. Foreign Key(similarly screenshots of all constraints)........................28
Implement a suitable graphical user interface..................................................................................30
Task 3....................................................................................................................................31
Trigger test.......................................................................................................................................31
Revoke test:......................................................................................................................................32
Grant test.........................................................................................................................................33
Edit privileges: User account 'root'@'localhost'....................................................................33
Primary key test:..............................................................................................................................34

localhos
3

Unique key test................................................................................................................................35


Foreign key test:...............................................................................................................................36
Login page........................................................................................................................................37
Book displaying table test................................................................................................................38
Order report.....................................................................................................................................39
Task 4.............................................................................................................................................41

Figure 1 - ERD – Entity Relationship Diagram..............................................................................................7

Figure 2 er diagram normalised data.........................................................................................................12

Figure 3 Database connection code...........................................................................................................17

Figure 4 Admin login (connection code )...................................................................................................18

Figure 5 RBAC model.................................................................................................................................19

Figure 6 MAC flowchart.............................................................................................................................21

Figure 7 Pioneer books database...............................................................................................................22

Figure 8 Book table....................................................................................................................................22

Figure 9 Book relation with other tables...................................................................................................23

Figure 10 Customer table..........................................................................................................................24

Figure 11 Customer address detail table...................................................................................................24

Figure 12 Order detail table.......................................................................................................................25

Figure 13 Order items table.......................................................................................................................25

Figure 14 Payment type table....................................................................................................................26

Figure 15 Staff table..................................................................................................................................26

Figure 16 Supplier table.............................................................................................................................27

Figure 17 Books table foregin key.............................................................................................................28

Figure 18 Customer table foregin key........................................................................................................28

Figure 19 order table foreign key..............................................................................................................29

Figure 20 Staff table..................................................................................................................................44

Figure 21 Supplier table.............................................................................................................................44

Figure 22 Book connection........................................................................................................................45

Figure 23 dataware house.........................................................................................................................48

localhos
4

Figure 24 ODBC..........................................................................................................................................50

Task 1
Using the information you have been provided with and some additional external research,

1.a) Plan and produce a design for a complex relational database based on a response to the

client brief.

Identifying Entities and their attributes

There are 6 Entities in the database the data is stored unnormarlised, below are the
detail of entities and attributes with their constraint keys.
Entity 1 (Books)
It has 10 fields with Book_ID being the primary key.

Attribute 1 book_id (Primary)


Attribute 2 book name
Attribute 3 author name
Attribute 4 year
Attribute 5 publish date
Attribute 6 description genre
Attribute 7 page count
Attribute 8 price
Attribute 9 Supplier id
Attribute 10 Staff id

Entity 2 (customer)
It has 9 fields with cust_id being the primary key

Attribute 1 cust_id (Primary)


Attribute 2 first name
Attribute 3 last name
Attribute 4 phone

localhos
5

Attribute 5 email
Attribute 6 zip code
Attribute 7 City
Attribute 8 DOB
Attribute 9 Book id

Entity 3 (order)
It has 6 fields with order ID being the primary key

Attribute 1 ordere_id
Attribute 2 Order date
Attribute 3 ordere items qty
Attribute 4 price
Attribute 5 cust_id
Attribute 6 Book id

Entity 4 (staff)
It has 5 fields with staff ID being the primary key

Attribute 1 staff_id
Attribute 2 Staff name
Attribute 3 Email
Attribute 4 Phone
Attribute 5 salary

Entity 5 (supplier)
It has 4 fields with supplier ID being the primary key

Attribute 1 supplier_id
Attribute 2 name
Attribute 3 Email
Attribute 4 Company
address

Entity 6 (payment)

localhos
6

It has 4 fields with payment type ID being the primary key

Attribute 1 Payment type


Attribute 2 Customer id
Attribute 3 qty
Attribute 4 Order id

Identify the relationships

Each table has a constraint key (primary / foreign) that links them together.
Because the supplier company distributes the books to the pioneer book library, the books t
able is linked to the supplier table. 
The books table, on the other hand, contains orders placed by customers and is maintained 
by staff. 
The staff checks the order and places it for the customer, 

 The pioneer book library receives books from a supplier.


 Order is placed by the customer.
 Customer makes a payment
 The staff member is in responsible of the orders.
 The books table and the supplier table were managed by the staff.

Mapping/ Cardinality

Mapping cardinalities is most useful when describing binary relationship sets. Although
they can contribute to the complexity of relationship sets, they are not very useful in
describing complex relationships.

There are four different mapping cardinalities for a binary relationship set R on an entity
set A and B. The following are some of them:
1. One to one (1….1)
2. One to many (1….M)
3. Many to one (M….1)
4. Many to many (M….M)

Poineer books library ERD relationship:

One book contains many order (one to many)


One supplier can supplies many books (one to many)

localhos
7

One staff can manage many books (one to many)


One customer can place many orders (one to many)
One payment can make by one customer (one to one)
One staff member can manage many orders (one to many)

Entity relationship Diagram for the scenario

Figure 1 - ERD – Entity Relationship Diagram

This is the (UNF data)Entity relationship model for the database Pioneer books library. As you
can see there is 6 tables with un-normlaised form data. Which can be difficult for the admin/staff
to modify, delete , update and inserting data and retrieve data.

Steps:
 The pioneer book library receives books from a supplier.
 Order is placed by the customer.
 Customer makes a payment
 The staff member is in responsible of the orders.
 The books table and the supplier table were managed by the staff.

localhos
8

1.b) Normalise the data to 3rd normal form.

Normalisation

1. Book table
UNF 1NF 2NF 3NF

1 B_ ID Book id (pk) Book id (pk) Book id (fk)


1 Book author Book name Book name Book name
1 Book name Book author Book author Book author
1 page count Word count Word count
1 genre Genre Genre
1 Book price Publish date Word count Publish date
1 publish date Year Genre Year
1 year Book Price Publish date price
1 supplier id Supplier id (fk) Year
1staff id Staff id (fk) Price

Book id (fk)

Supplier id (fk) Book id (fk)

Supplier id (fk)

Staff id (fk)

2. Customer table
UNF 1NF 2NF 3NF

2 C_ID C_ID(PK) C_ID(PK) C_ID(PK)


2 F_NAME F_NAME F_NAME F_NAME
2 L_NAME L_NAME L_NAME L_NAME
2 PHONE PHONE PHONE Phone
2 EMAIL EMAIL EMAIL Email

localhos
9

2 B_ID B_ID(FK) - Zip code(fk)


2 Zip code Zip code Zip code (pk)

2 city City City Zip code (pk)

2 dob dob dob City

dob

Here above 2 customer table, we removed the BOOK ID attribute the repeating data so that we
can have customer table information stored separately. In addition customer id is primary that
can be linked with other tables to retrieve the data.

3. Staff table

UNF 1NF 2NF 3NF

3 S_ID S_ID (PK) S_ID (PK) S_ID (PK)


3 PHONE PHONE PHONE PHONE
3 ADDRESS ADDRESS ADDRESS ADDRESS
3 EMAIL EMAIL EMAIL EMAIL

4. supplier table

UNF 1NF 2NF 3NF

4 supplier id supplier id (pk) supplier id (pk) supplier id (pk)


4 supplier name supplier name supplier name supplier name
4 supplier company supplier company supplier company supplier company
add add address code address code
4 phone phone Delivery date Delivery date
4 supplier delivery supplier delivery date phone phone
date

localhos
10

5. order table

UNF 1NF 2NF 3NF

5 ORDER ID ORDER ID (PK) ORDER ID (PK) ORDER ID (PK)


5 ORDER DATE ORDER DATE ORDER DATE ORDER DATE
5 C_ID C_ID (FK) C_ID (FK) C_ID (FK)
5 STAFF_ID STAFF_ID (FK) STAFF_ID (FK) STAFF_ID (FK)
5 order items qty Order items qty Order items qty Order items qty
5 book id Book id (fk) Book id(fk) Payment type (fk)

5 payment type Payment type (fk) Payment type (fk)

5 customer address Customer address Customer add O_ID(FK)

5 customer email Customer email Customer email C_ID(FK)

Cust add

Cust email

3NF data as you can see we create 2 tables from UNF order data. Staff placed order for
customer with his/her customer ID that is foreign key in order table( related to customer table
where it is primary key), so that staff person can stored the information and placed orders.

6. payment table

UNF 1NF 2NF 3NF

6 PAYMENT TYPE
6 c_id PAYMENT TYPE no. PAYMENT TYPE no. PAYMENT TYPE no.
(pk) (pk) (pk)
6 order item qty Payment type name Payment type name Payment type name
6 order id C_id(fk) C_id(fk)
6 book id Order id(fk) Order id(fk) Payment type no. (fk)

6 cust id Oder item qty Oder item qty C_id

localhos
11

Book id (fk) Book Id (fk) Order qty

Order id

Book id

All main keys have been designated as (PK) in the Normalisation, while foreign keys have been
marked as (FK) (FK).

Now, the data in the assignment and table is not normalized or prepared properly. The data
integrity and functional relationships are not maintained, and the data is not fully normalized.

In order to create the link, normalisation was performed on all tables. To build, several tables
must be separated and primary and foreign keys must be used. The following steps were done
to complete the Normalization:

1. UNF = repeating group data


2. 1NF = Remove repeating group data
3. 2NF = Remove partial key dependencies
4. 3NF = Remove non-key dependencies

So, based on this Figure 1, it’s the (customer table). It’s the 1NF Explanation in this table there
are duplicate data, so I separate them into different table. The figure 2, it’s the 3NF of the table
of customer. You will see that highlighted color I remove all duplicate data (b_id) and create
different table so as I can create the ER diagram.

UNF 1NF 2NF 3NF

2 C_ID C_ID(PK) C_ID(PK) C_ID(PK)


2 F_NAME F_NAME F_NAME F_NAME
2 L_NAME L_NAME L_NAME L_NAME
2 PHONE PHONE PHONE Phone
2 EMAIL EMAIL EMAIL Email
2 B_ID B_ID(FK) - Zip code(fk)
2 Zip code Zip code Zip code (pk)

2 city City City Zip code (pk)

localhos
12

2 dob dob dob City

dob

Screen shot of all the tables task 2.

1.c) Produce design documentation in response to the client brief ensuring this
shows the design of the tables, constraints, SQL queries, forms and security
measures.

This provides evidence for LO2- [2.2]

Figure 2 er diagram normalised data

As you can see the ER diagram that is completely normalised upto 3NF, are linked to each other table by
colored relationship. Here are the 10 entities after normalisation upto 3NF, as you can see books table is
linked with(book_con) table in which Foreign keys are inserted to make a link with other tables to
retrieve a data.

 Customer_add_detail has zip code as a being primary key, which has relation with the customer
detail table where the customer iD is being primary and zip_code attribute is foreign key.

 Staff has staff id bein primary key and relation with cook_con tabke and other order table.

localhos
13

 Supplier has supplier id which in primary key in there, which represent the book supplier by
which supplier has supplied the book. It has relation through book_con table.

 Order table had divided into 2 tables to manage the customer order. In the order detail table,
order id, order date,, customer id, book id (which book order is placed), ordere QTY ( quantity of
book order), and payment type ( cash/ credit)

 Payment type table which has 2 attribute with payment type code is being primary key to
difference between payment types.

(1- credit)

(2-cash)

 Order checkout table is created to show the report of the order, where you can see order placed
report.

 Green color is used to show the relation from one table to other tables.

 Blue color showed the relation connection between same table.

Data Dictionary

A data dictionary is a set of names, terms, and attributes for various data elements and models.
They are used in databases and other information systems.   The metadata more about
database is the data in a data dictionary. These components are then included into a database,
research project, or information system. Although there is variance, these are the most typical
items found in a data dictionary:

 Attribute_name
 Attribute_type

 Entity-relationship(ER)

 References data

 Rules on validation, schema, or data quality

Data Dictionary Tables:

localhos
14

localhos
15

Constraints

Constraints in a database are used to define rules for the data in a table. Constraints are
used to restrict the types of data that can be entered into a table. This ensures that the data
in the table is accurate and reliable. The action is cancelled if there is a conflict between the
constraint and the data action.

Entity Integrity Constraints


o Null-Rule
 If you did not enter any data into book name you will get the null value
and it occurs error.
o Unique.
 Only unique values, no repeated values are called primary key/
unique key
o Primary Key.
 The primary key in the book table is book_id

 Referential Integrity Rules (Foreign Key)


o Book_id (primary key) in book table is the foreign key in the book_con table.
o staff_id (primary key) in staff table, is the foreign key in the book_con table.
o SUPP_id (primary key) in supplier table, is the foreign key in the book_con
table.
o Zipcode (primary key) in customer_add table, is the foreign key in the
customer table.

localhos
16

INDEX

In the referenced table, you must have specified a primary key (or at least an indexed
column) that will act as the foreign key in the referencing table. We have defined ‘zip
code' as a foreign key in the ‘customer' table in our example. A screenshot of the table
where you can add foreign keys is shown below.

As you can see the constraint action have 3 column in which you have to select the
attribute with real location table, it will automatically entered the primary key to the last
table.

TRIGGER
A trigger is a statement that is created automatically by the system in the first place of a
database alteration. If specific circumstances occur, specify an action to be taken.
Event: modification the database automatically activates trigger (an insertion, deletion,
update)
Condition: when the trigger activates a test or query checked for confirmation. (eg: for a
query: null is false, not null is true)

Example: suppose we have


book : b_id, bname, price
Orders : order id, odate, ocust, final (bool)
Details : order id, b_id, order item qty
Prices : order id, b_id, price

SYNTAX:
CREATE TRIGGER save_price AFTER INSERT ON details REFERENCING NEW
TABLE AS inserted FOR EACH STATEMENT WHEN TRUE BEGIN INSERT INTO
prices(order_id,b_id,price) SELECT I.order_id, I.b_id, P.price FROM inserted I JOIN
products P ON I.b_id = P.b_id END ;

localhos
17

preforming trigger on our pioneer books Database:

create a Staff table where we have attribute, Staff name, staff id, staff email, staff phone
number, staff salary.
Go to the trigger>> add insert trigger>> Syntax
INSERT INTO STAFF VALUES( NULL, NEW.SALARY, ‘INSERTED’);
PRESS GO.

The new table will be create when you add salary it will revoke trigger send a error
message if the value is incorrect.

Output:

FORMS
Db Connection

localhos
18

Figure 3 Database connection code

localhos
19

Figure 4 Admin login (connection code )

SECURITY MEASURES (DAC,MAC,RBAC)


Login:
A form where a client/admin used username and password to login into
their account. It access from the database when they entered his/her
username and password.

GRANT privilage:
The GRANT command can grant a wide range of permissions, including
the power to CREATE tables and databases, READ and WRITE FILES,
and even SHUTDOWN the server.

i. RBAC (Role Based Access Control)

 RBAC is based on the functions they play in a system, rather than a user identity. These
rules are determined by an individual's job profile, responsibilities, and authority inside
an enterprise.
 Users are granted distinct roles based on their duties, either statically or dynamically.
 In some situations, the user executing a specific task or duty dynamically adjusts; as a
result, the job assignment should be adaptable.

localhos
20

RBAC 4 models:

1. RBAC 0: Provides the most capability for the RBAC system.


2. RBAC 1: Provides a Role hierarchy as well as RBAC 0 capabilities.
3. RBAC 2: It includes RBAC 0 functionality as well as Constraints.
4. RBAC 3: This is a consolidated model that combines the features of the previous three
models.

Figure 5 RBAC model

ii. DAC (Discretionary Access Control)

 In DAC (Discretionary Access Control), the data user determines the users' access
control policy.
 The administrator has complete control over who has access to “read, write, execute,
search, create, and delete.”
 DAC is known as a "need-to-know" access model as it needs permits to be provided to
those who require access.
.

localhos
21

• Although DAC is simple to use and understand, it does have several drawbacks, including:

1. Vulnerabilities built-in (Trojan horse)

2. ACL capacity or maintenance

3. Permissions are granted and revoked on a regular basis.

4. Negative authorization power is limited.

MAC (Mandatory Access Control)


 A MAC is a system administrator-defined access control policy. In a MAC policy, users
have no permits to change the access control of a source. Even its resource owner is
powerless to alter the OS's policy.
 The information in MAC is classified according to the level of security that must be
maintained in secure manner. The term "Multilevel Security" refers to the way data is
organized.

Figure 6 MAC flowchart

localhos
22

1. 1. As shown in Figure 6, the first confidentiality and category levels are related to data
and user.
2. 2. The user should then be authenticated.
3. 3. When an user requests data and tries to access it, the operating system examines the
user's data and connects it to the security levels that is  given to data in the permitted
database.
4. If the user's and data's confidentiality and category levels match, access is granted; if they
don't, access is denied.

localhos
23

Task 2
2.a) Implement the database using the designs you have created in Task 1.
Ensure that your database includes all the features you designed in activity
one.

Screen shots of all tables

Figure 7 Pioneer books database

Figure 8 Book table

localhos
24

Figure 9 Book relation with other tables

localhos
25

Figure 10 Customer table

Figure 11 Customer address detail table

localhos
26

Figure 12 Order detail table

Figure 13 Order items table

localhos
27

Figure 14 Payment type table

Figure 15 Staff table

localhos
28

Figure 16 Supplier table

localhos
29

Screen shots of all constraints. Foreign Key(similarly screenshots of all


constraints)
1. Foreign key

Figure 17 Books table foregin key

Figure 18 Customer table foregin key

localhos
30

Figure 19 order table foreign key

2. Unique key duplicate

Book id is already stored.

Error occur when you try to enter the same duplicate key.

localhos
31

Implement a suitable graphical user interface.

localhos
32

Task 3
3.a) Test the database and produce screen shot evidence to show the tests that
have been carried out and explain any errors that need to be resolved. Amend the
database based on the testing.

Trigger test
Test ID : T001

Test : Trigger Test


Name

Steps : Go to book Table->Insert Tab.

Insert Values with `price’ as less than 1.

Test : INSERT INTO `book` (`book_id`, `book name `, `book author`, `year`, `publish date
Input `, `Description genre’, `page count`, `price `)

VALUES (1, 'harry', 'kate', ‘2011’, ‘2011-11-11’, ‘history’, ‘22’, ‘0’)

Expected : Error Message “price cannot be less than 1 “


Result

Actual : Error Message “price cannot be less than 1“


Result

Pass / : PASS
Fail

Screensh :
ot

localhos
33

Revoke test:
Test ID : T002

Test Name : Revoke test

Steps : Go to DB-> drop staff id from book table

Test Input :

Expected : Error Message “  #1829 - Cannot drop column 'staff_id': needed in a foreign key
Result constraint 'order_ibfk_1' of table 'osamadb books.order'

Actual : Error Message “  #1829 - Cannot drop column 'staff_id': needed in a foreign key
constraint 'order_ibfk_1' of table ‘osamadb books.order'
Result

Pass / Fail : PASS

Screenshot :

localhos
34

Grant test

Test ID : T003

Test : Grant test


Name

Steps : Go to database->click on home->user accounts->localhost->edit privilege-


>grant privileges.

Test :
Input

Expected : User account overview


Result

Actual :
Result  Edit privileges: User account 'root'@'localhost'
Pass / : PASS
Fail

localhos
35

Screensh :
ot

Primary key test:


Test ID : T004

Test : Primary key test


Name

Steps : Go to book table->insert tab-> book_id=1

Test : INSERT INTO `book`(`book_id`, `book name`, `author name`, `year`, `publish
Input date`, `description genre`, `page count`, `price`) VALUES ('1','Alice
grace','soon','2019','2019-12-1','history','44',0)

Expected : Duplicate entry 1 for primary key


Result

Actual : Duplicate entry 1 for primary key


Result

Pass / : PASS
Fail

Screensh :
ot

localhos
36

Unique key test


Test ID : T006

Test Name : Unique key test

Steps : Go to supplier table->insert tab-> supplier phone=355678’

Test Input : INSERT INTO `supplier`(`supp_id`, `s_name` `S_email’, phone no) VALUES
(1,cath,'Xyz',[email protected]', 355678)

Expected : Duplicate entry ‘355678’ for key ‘staff_ph’


Result

Actual : Duplicate entry ‘355678’ for key ‘staff_ph’


Result

Pass / Fail : PASS

Screensho :
t

localhos
37

Foreign key test:


Test ID : T005

Test : foreign key test


Name

Steps : go to OSAMA Db structure-> click on drop

Test :
Input

Expected : Cannot delete or update a parent row: a foreign key constraint fails
Result (`osamadb`.`book_con`, CONSTRAINT `book_con_ibfk_3` FOREIGN KEY
(`O_staff_id `) REFERENCES `staff` (`OS_staff_id`)) ON DELETE CASCADE ON
UPDATE CASCADE)

Actual : Cannot delete or update a parent row: a foreign key constraint fails
(`osamadb`.`book_con`, CONSTRAINT `book_con_ibfk_3` FOREIGN KEY
Result
(`O_staff_id `) REFERENCES `staff` (`OS_staff_id`)) ON DELETE CASCADE ON
UPDATE CASCADE)

Pass / : PASS
Fail

Screensh :
ot

localhos
38

Login page
Test ID : T007

Test : Login page


Name

Steps : Enter username and password

Test Input : Username password form database

Expected : It should redirect to home page


Result

Actual : It should redirect to home page


Result

Pass / Fail : PASS

Screensho :
t

localhos
39

Book displaying table test


Test ID : T008

Test Name : Book categories test

Steps :

Test Input : Go to home page ->click book categories tab

Expected : Book categories page should be displayed


Result

Actual : Book categories page should be displayed


Result

Pass / Fail : PASS

Screenshot :

localhos
40

Order report
Test ID : T009

Test Name : OrderReportView Test

Steps :

Test Input : Reports-> OrderDetails Link

Expected : A form showing the Order details


Result

Actual Result : A form showing the Order details

Pass / Fail : PASS

Screenshot :

Test ID : T010

Test Name : Customer Report View Test

Steps :

Test Input : Reports-> customer Details Link

Expected : A form showing the customer details


Result

Actual Result : A form showing the customer details

Pass / Fail : PASS

Screenshot :

localhos
41

Task 4
4.a) Critically evaluates the design process and documentation that was produced
for Pioneer Books database identifying improvements with the design
documentation where appropriate.
Include the comments provided by Tutor on your first submission about the ER Diagram and
normalization. (Example: The ER diagram went through multiple changes according to the tutor’s

localhos
42

feedback as new relationships were added and some old were changed to remove errors from the
diagram, cardinality included etc….)

4.b) Reviews the database implementation process and explain what was
successful and what you would do differently if you were to do this again.

I begin by creating the database and filling it with tables. Then I began adding attributes and
entering certain tables with data, and the most important thing was to input the correct table
because some will be related to others. For example, I fill data in the book table and book ID is
used as a primary key so I can fill the book connection table. Why do I do this first because later
I will got problem while filling the data in the other table. There are some tables which have
relationship with the main table. Just look down the screenshot to have an overview what I’m
saying.

Figure 20 Staff table

localhos
43

Figure 21 Supplier table

localhos
44

Figure 22 Book connection

So in the above figures you can see the staff table and supplier table had to created first so that
they can link to the book connection table. Where as in the book connection BOOK ID and
STAFF ID, SUPPLIER ID are foreign key which links to the BOOK detail Table.

localhos
45

Future Improvements – if re-do this assign

They may create an Android or iOS app or a website so that their consumers can access their
personal information or information about the pioneer book library at any time. All database
permissions must be granted to the application.

Improve database performance by using a powerful CPU, allocating additional RAM,


defragmenting data, changing disk kinds, and altering the current database model so that the
staff has a new platform on which to operate.

4.c) Evaluates the role of databases within Pioneer Books.

Introduction

A database management system is an integral part of a company's information systems. It is


responsible for the generation, management, and retrieval of business data. Its various functions
are performed in a timely manner.

localhos
46

OLTP:

OLTP is a process that focuses on the integrity, performance, and availability of data. It is mainly
concerned with query processing and multi-access scenarios.

OLAP:
OLAP stands for Online Analytical Processing, and it is a type of software that allows users to evaluate
data from various databases at the same time. It's a tool that allows analysts to obtain and analyze
business data from various perspectives. Data can be pre-calculated and pre-aggregated using OLAP,
which speeds up analysis.

1 or even more cubes are used to split OLAP databases. These cubes are constructed in such a way that
it is simple to create and read reports. Online Analytical Processing (OLAP) is a term that refers to the
process of analyzing data online.

1. What is the mechanism behind it?

A data warehouse extracts data from a variety of sources and formats, including text files, excel sheets,
multimedia files, and so on.

The data is extracted and modified after it has been obtained. Data is fed into an OLAP server (or OLAP
cube), which calculates information ahead of time for future analysis.

DATA WAREHOUSE
Data warehousing (DW) is a method of gathering and analyzing data from many sources in order to get
useful business insights. Typically, a data warehouse is used to integrate and analyze corporate data
from many sources. The data warehouse is the heart of the business intelligence (BI) system, which is
designed to analyze and report on data.

What is a Datawarehouse and how does it work?

A Data Warehouse is a central repository where data through one or more data sources is stored. The
transaction system and certain other relational databases feed data from the data warehouse.

The following are examples of data sources:

1. Organized
2. Structured semi-structure
3. Data that is unstructured

localhos
47

Figure 23 dataware house

4.d) Explains how Pioneer Books can connect the database to other applications
that it may use within the business.

Firstly we have to create a database without any data redundancy, which can be done by doing the data
normalization. Sorting data from table to table 1NF, 2NF, 3NF, so that I can remove the duplicate data
from the table steps by step. From task 1 to task 2, the database is created using the Normalisation
method first, then the database is created and the ERD diagram is obtained. The SQL construct table
task 1(a) demonstrates how I implemented the pioneer books library in the databases. Doing some
study on a database's population and explaining it in the context of the assignment. The next job is to
provide the query as well as the result in two different images. The first goal is to write a basic query to
display the data in each table, which is followed by task 1(a). The ODBC and JDBC drivers in MS- SQL
based Application Programming Interface(API) enables software and programs to connect to databases
through SQL. OBDC allows the window software programs and JDBC allows Java programs to access and
connected to data. By allowing these programs which can connect the database of Pioneer books to
other application, these API’s on a client system to communicate with a data source on the same client
machine or on a different server computer.

localhos
48

You have to following the steps to connect it with other application:

1. Registering the driver


The Class.forName() method used to registering driver class with dynamism.

For example:
Class.forName("oracle.jdbc.odbc.JdbcOdbcDriver");

2. Make connection
The getConnection() function of the DriverManager class is used to create a connection object.
A database url, user name, and password must be provided.
Example : Creating connection with oracle driver
Connection con = DriverManager.getConnection
("jdbc:oracle:thin:@localhost:1534:XE","username","password");
3. Create SQL Statement
The Connection interface gives the createStatement() method to create SQL statement.

Syntax:
public Statement createStatement( ) throws SQLException
4. Execute SQL Queries
The Statement interface provides the executeQuery( ) method to execute SQL statements.

Syntax:
public ResultSet executeQuery(String sql) throw SQLException
5. Closing the Connection
The Connection interface provides close( ) method, used to close the connection. It is invoked
to release the session after execution of SQL statement.  

Syntax:
public void close( ) throws SQLException

Example:
con.close( );

localhos
49

Figure 24 ODBC

4.e) Recommends to Pioneer Books a database management system they can use
to maintain the database you have created.

Data model
As you can see in my ERD graphic, data modelling is the process of establishing a data model for data to
be stored in a database.

localhos
50

There are 11 tables in the databse which have connection related to each other. For example:

Customer Order detail Order checkout

The number of table customer id utilized has a relationship with the number of order detail, which has a
relationship with the order checkout. Now I'll show you how to create a table in the database. First, I'll
input data, then I'll create a foreign key relationship.

Customer data which has unique key (1), (2)

localhos
51

As you can see the customer id is shown in the figure. Unique key of customer id is foreign key in the
order detail table.

Now you can see the, here customer id is linked to two table 1-order detail and 2- order checkout.

Hierarchical

A data model where the data is structured into a tree-like structure is known as a hierarchical database
model. The information is kept in the form of records that are linked together. To obtain data from the a
hierarchical database, you must first traverse the entire tree, beginning at the root node.

The hierarchical model optimizes the performance of queries. Since data is stored in the form of records,
you don't have to contact the database server for every request. You can by-pass the database server,
going right to data that is closer to you on the tree.

localhos
52

Book table

Book_id(pk) name author Date year price Word count

Book id (fk) Staff id (fk) Sup_id(fk)

Supplier Supplier Supplier


id (pk) name address
Staff Staff Staff
id(pk) name email

Figure 23 heirarchical model of pioneer book library (book table)

Recommended model is relational model due to so and so advantages over the


other models. The advantages needs to be elaborated.

I recommend a relational database model as it is a collection of data items organized by defined


relationships for convenient access. The data structures, such as data tables, indexes, and views, are
kept distinct from the physical storage in the relational database paradigm, allowing administrators to
change the physical data storage without impacting the logical data structure. The purpose of creating
pioneer books database is to store, update, and retrieve data by the structure of the database. The data
stored within a database represents a measurable phenomenon and is usually referred to as 'meaningful
data'. The rows/entity are called tuples and each column called in a database table has a unique name. it
is easy to create table without any complex tools. You can add, modify, delete, and inserted a column
whenever you needed. The advantage of rational database that it is flexible that you can join two table
with easily that are related to each other by their constraint keys.

As it has a less drawbacks than hierarchy where you have to adjust each table with their attribute and
column and display relation.

localhos
53

Rational database is most efficient and flexible model. It is advance model database that is use in today
as compare to hierarchy model which is now old.

Some of the advantages:

Data accuracy: Different tables in the pioneer books library can be identified with each other in a
relational database model by utilizing the essential key and unfamiliar key standards. Thus, the
information is non-repetitive. There is no chance of information duplication in the pioneer book
database. Subsequently, data in a relational database is more accurate than data in any other database
system.

Easy to access data: There is no pattern or path for accessing the data, unlike other databases that can
only be accessed by traveling through a tree or hierarchical model. Any table in the relational database
can be queried by anyone who has access to the data.

Normalisation: normalisation is done when the data is unnormalised which make trouble to store ,
update, delete and retrieve data from the table. Pioneer books data is normalised 1NF to 3NF to avoid
all the error that may occur during storing data.

Figure 24 Relational data of book table

localhos
54

References
Advantages, R., 2021. Relational Database Advantages | 8 Advantages of Relational Database. [online]
EDUCBA. Available at: <https://www.educba.com/relational-database-advantages/> [Accessed 24
May 2021].

Shelar, N., 2021. Access Control Policies (MAC, DAC, RBAC, ABAC) | The Polymath Blog. [online] The
Polymath Blog. Available at: <https://neelshelar.com/access-control-policies-mac-dac-rbac-abac/>
[Accessed 24 May 2021].

Tutorialspoint.com. 2021. JDBC - Create Database Example - Tutorialspoint. [online] Available at:


<https://www.tutorialspoint.com/jdbc/jdbc-create-database.htm> [Accessed 24 May 2021].

Guru99.com. 2021. What is Data Warehouse? Types, Definition & Example. [online] Available at:
<https://www.guru99.com/data-warehousing.html#3> [Accessed 24 May 2021].

Guru99.com. 2021. What is OLAP? Cube, Operations & Types in Data Warehouse. [online] Available at:
<https://www.guru99.com/online-analytical-processing.html> [Accessed 24 May 2021].

localhos

You might also like