Você está na página 1de 19

DATABASE SERVER MANAGEMENT

Oracle SQL

Ifthikar 1629275

Afaz 1629348

BSc (Hons) in Computing


Database Server Management | IFTHI & AFAZ

Contents
Logical Diagram ............................................................................................................................................. 3
Relational Diagram........................................................................................................................................ 4
QUERIES ........................................................................................................................................................ 5
A. The below imgae is showing the group by function. All category ordering the result by name. ......... 5
B. The below query shows the all the parent category. ........................................................................... 5
C. Category along with parent category ................................................................................................... 6
F. Specific product from a specific category ............................................................................................. 8
G. All Customer who joined in 2017 ......................................................................................................... 8
H. Top 10 orders in year 2016 based on the total amount of order......................................................... 9
L. Final Amount between 2 Days .............................................................................................................. 9
O. Customer’s name who is name starts with “M”. ................................................................................. 9
Q. Retrieve all the payment methods. .................................................................................................... 10
R. Orders which are ready for the delivery. ............................................................................................ 10
S. Orders which were delivered last month............................................................................................ 11
Triggers........................................................................................................................................................ 11
TR1 .......................................................................................................................................................... 11
TR2 .......................................................................................................................................................... 12
TR3 .......................................................................................................................................................... 13
DATA INSERT ............................................................................................................................................... 14
Employee Table ....................................................................................................................................... 14
Customer Table ....................................................................................................................................... 14
Category Table ........................................................................................................................................ 15
Views ........................................................................................................................................................... 16
Sales summary ........................................................................................................................................ 16
Customer summary................................................................................................................................. 17
Sales Report ............................................................................................................................................ 18

IFTHI & AFAZ 1


Database Server Management | IFTHI & AFAZ

Image Captions
Figure 1 - Logical Diagram ............................................................................................................................. 3
Figure 2 - Relational Diagram ........................................................................................................................ 4
Figure 3 - Accessed Sub Category Table ....................................................................................................... 5
Figure 4 - Accessed Product Table ................................................................................................................ 5
Figure 5 - Used Inner Join ............................................................................................................................. 6
Figure 6 - Accessed Product Table ................................................................................................................ 7
Figure 7 - Accessed Prodcut Table ................................................................................................................ 8
Figure 8 - Accessed Customer Table ............................................................................................................. 8
Figure 9 – Accessed Order Table................................................................................................................... 9
Figure 10 - Accessed Order Table ................................................................................................................. 9
Figure 11 - Accessed Customer Table ........................................................................................................... 9
Figure 12 - Accessed Payment Table .......................................................................................................... 10
Figure 13 - Accessed Order Table ............................................................................................................... 10
Figure 14 - Accessed Order Table ............................................................................................................... 11
Figure 15 - Trigger 1 .................................................................................................................................... 11
Figure 16 - Trigger 2 .................................................................................................................................... 12
Figure 17 - Trigger 3 .................................................................................................................................... 13
Figure 18 - Insert Data to Employee Table ................................................................................................. 14
Figure 19 - Insert Data to Customer Table .................................................................................................. 14
Figure 20 - Insert Date to Category Table ................................................................................................... 15
Figure 21 - Sales Summary View ................................................................................................................. 16
Figure 22 - Customer Summary View ......................................................................................................... 17
Figure 23 - Sales Report View ..................................................................................................................... 18

IFTHI & AFAZ 2


Database Server Management | IFTHI & AFAZ

Logical Diagram

Figure 1 - Logical Diagram

This is our system’s Logical Diagram, To get this type diagram we did normalization and finally got this
output.

IFTHI & AFAZ 3


Database Server Management | IFTHI & AFAZ

Relational Diagram

Figure 2 - Relational Diagram

To get this relational diagam, We did forward engineering to get this relational diagram.

IFTHI & AFAZ 4


Database Server Management | IFTHI & AFAZ

QUERIES
A. The below imgae is showing the group by function. All category ordering the result by
name.

Figure 3 - Accessed Sub Category Table


Here it displays the categories ordering by name, Also this is in ascending order.

B. The below query shows the all the parent category.

Figure 4 - Accessed Product Table

Retrieves all the parent category in product table.

IFTHI & AFAZ 5


Database Server Management | IFTHI & AFAZ

C. Category along with parent category

Figure 5 - Used Inner Join

Here it shows the categories along with parent category. It allows to see the sub category of each
category.

IFTHI & AFAZ 6


Database Server Management | IFTHI & AFAZ

E. products from a specific category

Figure 6 - Accessed Product Table

This retrieve the specific category. To do this we used where clause and we given the data name of
retrieve the output.

IFTHI & AFAZ 7


Database Server Management | IFTHI & AFAZ

F. Specific product from a specific category

Figure 7 - Accessed Prodcut Table

The above output shows the specific brand. In here we selected pr_id, pr_name, pr_brand to display the
data.

G. All Customer who joined in 2017

Figure 8 - Accessed Customer Table

The above output shows the who joined in 2017, to get this output we used TO_CHAR function.

This can be used in the real time situations, This is very important thing in the system.

IFTHI & AFAZ 8


Database Server Management | IFTHI & AFAZ

H. Top 10 orders in year 2016 based on the total amount of order.

Figure 9 – Accessed Order Table

The above output shows the top 10 orders in based on the total amount of order. To do this we used
ROWNUM by desc.

L. Final Amount between 2 Days

Figure 10 - Accessed Order Table

This output shows the 2 day’s total order, This done using BETWEEN.

Here it displays ord_id, ord_date, tbl_customer_cus_id, ord_tot, ord_dis, ord_date, ord_famnt.

O. Customer’s name who is name starts with “M”.

Figure 11 - Accessed Customer Table

The below output shows whose name is starting with “M”. To get this output we used LIKE operator.

This is much suitable operator to display the name which is starting with “M”.

IFTHI & AFAZ 9


Database Server Management | IFTHI & AFAZ

Q. Retrieve all the payment methods.

Figure 12 - Accessed Payment Table


In this system, We allocated two payment methods. For that we used new table and given a id. Its easy
to see the status of payment.

R. Orders which are ready for the delivery.

Figure 13 - Accessed Order Table

Here it displays the processing orders, which should be delivered.

Using this table we can see the order status of each order.

IFTHI & AFAZ 10


Database Server Management | IFTHI & AFAZ

S. Orders which were delivered last month.

Figure 14 - Accessed Order Table

Here it displays the delivered order which were delivered last month. This helps to see the delivered
order in last month.

To do this we used TO_CHAR function to get it.

Triggers
TR1

Figure 15 - Trigger 1

This we used to INSERT, UPDATE and DELETE in customer details.

IFTHI & AFAZ 11


Database Server Management | IFTHI & AFAZ

TR2

Figure 16 - Trigger 2

The above screenshot shows the trigger, Which were created to insert update and delete processes.

IFTHI & AFAZ 12


Database Server Management | IFTHI & AFAZ

TR3

Figure 17 - Trigger 3

This is our 3rd trigger this trigger also created to insert, update and delete, Once this done the record will
store in aud_rec.

IFTHI & AFAZ 13


Database Server Management | IFTHI & AFAZ

DATA INSERT
Employee Table
This is how we inserted data into Employee Table.

Figure 18 - Insert Data to Employee Table

Customer Table
This is the way that we inserted data to Customer Table.

Figure 19 - Insert Data to Customer Table

IFTHI & AFAZ 14


Database Server Management | IFTHI & AFAZ

Category Table
This is the way that we inserted data to Customer Table.

Figure 20 - Insert Date to Category Table

IFTHI & AFAZ 15


Database Server Management | IFTHI & AFAZ

Views
Sales summary
We created a sales summary.

Figure 21 - Sales Summary View

This view shows the sales details, This gives a overall summary details of sale.

IFTHI & AFAZ 16


Database Server Management | IFTHI & AFAZ

Customer summary
We created a sales summary.

Figure 22 - Customer Summary View

IFTHI & AFAZ 17


Database Server Management | IFTHI & AFAZ

Sales Report

Figure 23 - Sales Report View

This is sales report view.

IFTHI & AFAZ 18

Você também pode gostar