Vous êtes sur la page 1sur 13

UNITED STATES INTERNATIONAL

UNIVERSITY-AFRICA
COURSE TITLE

: DATABASE MANAGEMENT
SYSTEMS

COURSE CODE

: IST 4030

SEMESTER/YEAR

: SPRING/2013

TASK

: BEAUTY PRODUCTS
ENTERPRISE SYSTEM

PRESENTED TO

: DR. PATRICK KANYI WAMUYU


(Ph.D.)

BY

: SHADRACK BENARD
KWEINGOTI

ID NO

: 631448

ANALYSIS AND DESIGN


The Login Process:
The system has been designed with an emphasis on security features whereby only authorized users can
use it. The administrator creates the prospective users and gives them their respective access rights and
privileges to allow them to use the system accordingly. Created users are assigned a unique password and
username so that they can login to the system. Validity checks include: A username, unique password,
and privileges. In this case, the system allows the company manager and sales representatives, and the
administrator himself to be able to login and use it.
The Administrator: Logs in as the main designer of the system and can carry out a variety of functions
in accordance with the business requirements of the system. This range from changing and continuous
improvement of the system. He also creates new users, assigns them different access levels into the
system.
The Manager: He She is the one in charge of the business and knows all the requirements. He registers
new sales representatives, and has full access to all other information which includes the sales
representatives information, items, orders, customers, and ordered items details. He acts as an overseer in
the entire process of customers needs getting fulfilled by ensuring that enough and competent sale
representatives are hired and their information is kept into the database of the company for reference.
The Sales Representative: He represents the customers, entering their information into the system and
processing orders on their behalf.
DATABASE DESIGN
THE EXTENDED ENTITY RELATIONSHIP DIAGRAM
Diagram 1 below depicts the EERD of the Beauty Products Enterprise. The Sales Representative acts on
behalf of the customer in the entire process of placing orders. He represents the customer. The company
has many sales representatives who represent the customers. A customer places an order. The Order
contains Ordered Items which in turn has an item. The company has three items which include: Beauty
Products, Appliances, and Sporting Goods.

REP NO (PK)

CUST_NO

NAME

NAME
ADDRESS

REP_NO (FK)
SALES REP

CUSTOMER

Represents

Places

ORDER
NO (FK)

ORDER
ITEM

ORDER

Contains

Has

BEAUTY
PRODUCT

ITEM

APPLIANCE

SPORTING
GOODS

Diagram 1: EERD of the Beauty Products Enterprise System

1.1.1. RELATIONAL SCHEMA DIAGRAM


SALES REPRESENTATIVE
REP NO (PK)

NAME

CUSTOMER
CUST NO (PK)

NAME

ADDRESS

REP NO (FK)

ORDER
ORDER NO (PK)

ORDER DATE

CUST NO (FK)

ORDER ITEM
ORDER NO (FK)

ITEM NO (FK)

NUM ORDERED

QUOTED PRICE

ITEMS
ITEM NO (PK)

DESCRIPTION

PRICE

LOGIN
USERNAME

PASSWORD

PRIVILEDGE

Diagram 2: Relational Schema of the Beauty Products Enterprise System


1.1.2. ACCESS CONTROL: RIGHTS TO THE SYSTEM USERS
OBJECT/SUBJECT

ADMIN
MANAGER
SALES REPS

SALES
REPRESENTATIVES
TABLE
ALL
SELECT,NSERT,
UPDATE,DELETE
NONE

CUSTOMERS
TABLE

ORDERS
TABLE

ALL
SELECT,UPDATE
DELETE
SELECT
INSERT
UPDATE

ALL
SELECT

ORDER
ITEMS
TABLE
ALL
SELECT

SELECT
INSERT
UPDATE

SELECT
INSERT
UPDATE

Table 1: Access Control: Rights to the system users.

ITEMS
TABLE
ALL
SELECT,INSERT
UPDATE,DELETE
SELECT
INSERT
UPDATE

1.2. IMPLEMENTATION
1.2.1. DATABASE DESIGN USING ORACLE
A. SEQUENCE USED
I.)

Customer Number Sequence:

CREATE SEQUENCE "CUST_NO_SEQ" MINVALUE 1 MAXVALUE 1000 INCREMENT BY 1 START


WITH 41 CACHE 20 NOORDER NOCYCLE ;
II.)

Sales Representative Number Sequence:

CREATE SEQUENCE "REP_NO_SEQ" MINVALUE 1001 MAXVALUE 2000 INCREMENT BY 100 START
WITH 2001 CACHE 20 NOORDER NOCYCLE ;

B. LIST OF SQL DDL COMMANDS USED


I. Customer Table:
CREATE TABLE "CUSTOMERS"
(
"CUST_NO" NUMBER,
"NAME" VARCHAR2(20) NOT NULL ENABLE,
"ADDRESS" CHAR(20),
"REP_NO" NUMBER,
PRIMARY KEY ("CUST_NO") ENABLE
) ;ALTER TABLE "CUSTOMERS" ADD FOREIGN KEY ("REP_NO")
REFERENCES "SALES_REPS" ("REP_NO") ENABLE;

II.

Items Table:

CREATE TABLE "ITEMS"


(
"ITEM_NO" CHAR(20),
"DESCRIPTION" VARCHAR2(20),
"PRICE" NUMBER,
PRIMARY KEY ("ITEM_NO") ENABLE
);

III.

Login Table:

CREATE TABLE "LOGIN"


(
"USERNAME" VARCHAR2(20),
"PASSWORD" VARCHAR2(15),
"PRIVILEDGE" VARCHAR2(20)
);

IV.

Order Table

CREATE TABLE "ORDERS"


(
"ORDER_NO" NUMBER,
"ORDER_DATE" DATE,
"CUST_NO" NUMBER,
PRIMARY KEY ("ORDER_NO") ENABLE
) ;ALTER TABLE "ORDERS" ADD FOREIGN KEY ("CUST_NO")
REFERENCES "CUSTOMERS" ("CUST_NO") ENABLE;

V.

Order Items Table


4

CREATE TABLE "ORDER_ITEMS"


(
"ORDER_NO" NUMBER,
"ITEM_NO" CHAR(20),
"NUM_ORDERED" NUMBER,
"QUOTED_PRICE" NUMBER,
"TOTAL_COST" NUMBER,
PRIMARY KEY ("ORDER_NO", "ITEM_NO") ENABLE
) ;ALTER TABLE "ORDER_ITEMS" ADD FOREIGN KEY ("ORDER_NO")
REFERENCES "ORDERS" ("ORDER_NO") ENABLE;ALTER TABLE "ORDER_ITEMS" ADD
FOREIGN KEY ("ITEM_NO")
REFERENCES "ITEMS" ("ITEM_NO") ENABLE;

VI.

Items Table

CREATE TABLE "ITEMS"


(
"ITEM_NO" CHAR(20),
"DESCRIPTION" VARCHAR2(20),
"PRICE" NUMBER,
PRIMARY KEY ("ITEM_NO") ENABLE
);

VII.

Sales Representatives Table

CREATE TABLE "SALES_REPS"


(
"REP_NO" NUMBER,
"NAME" VARCHAR2(20) NOT NULL ENABLE,
PRIMARY KEY ("REP_NO") ENABLE
);

VIII.

Creating users: Manager and Salesrep


Create user manager identified by bpemanager;
Grant connect, resource, create synonym, create view to manager;
Create user salesrep identified by bpesalesrep;
Grant connect, resource,create synonym,create view to salesrep;

C. QUERIES AND SUB QUERIES USED ON THE DATABASE:


INSERTION QUERIES:
query = "INSERT INTO SALES_REPS VALUES(REP_NO_SEQ.NEXTVAL,'"+sales_rep_name+"')";
query = "INSERT INTO CUSTOMERS
VALUES(CUST_NO_SEQ.NEXTVAL,'"+customer_name+"','"+customer_address+"','"+sales_rep_number+"')";
query = "INSERT INTO ORDERS VALUES('"+order_no+"','"+order_date+"','"+customer_no+"')";
query = "INSERT INTO ORDER_ITEMS
VALUES('"+orderno+"','"+itemno+"','"+no_ordered+"','"+quoted_price+"','"+total+"')";
query = "INSERT INTO ITEMS VALUES('"+itemsno+"','"+description+"','"+price+"')";

DATA RETRIEVAL QUERIES:


rs = stmt.executeQuery("SELECT username, password, priviledge FROM login WHERE username =
'"+username+"'");
query = "SELECT * FROM SALES_REPS";
query = "SELECT * FROM CUSTOMER";
query = "SELECT * FROM ITEMS_VIEW";
query = "SELECT * FROM ORDER_ITEMS_VIEW";
query = "SELECT * FROM ORDER_VIEW";

D. VIEWS USED:
i.)
Items_View
This view allows the person to view the existing items and their details to view the existing items in case
they want to refer to the items. CREATE OR REPLACE FORCE VIEW "ITEMS_VIEW" ("ITEM_NO",
"DESCRIPTION", "PRICE") AS select item_no,description,price from items;

ii.)

Order_Items_View

This view allows the person to view the existing ordered items and their details for reference and eventual
use. CREATE OR REPLACE FORCE VIEW "ORDER_ITEMS_VIEW" ("ITEM_NO", "ORDER_NO",
"NUMBER_ORDERED", "QUOTED_PRICE", "TOTAL_COST") AS select
order_no,item_no,num_ordered,quoted_price,total_cost from order_items;

iii.)

Sales_Rep

This view is used to view the existing sales representatives and their details for reference. CREATE OR
REPLACE FORCE VIEW "SALES_REP" ("NAME", "REP_NO") AS select name,rep_no from
sales_reps;

iv.)

Order_View

This view is used to view the order items existing in the system for use and reference. CREATE OR
REPLACE FORCE VIEW "ORDER_VIEW" ("ORDER_NO", "ORDER_DATE", "CUSTOMER_NO")
AS select order_no,order_date,cust_no from orders;

E. PROCEDURES USED:
i.)
Items_delete procedure
create or replace procedure items_delete
as
begin
delete from items
where item_no=408;
end;
This procedure deletes the items whose item no is 408 from the items table.

ii.)

Update_price procedure

create or replace procedure update_price


as
begin
update items set price=price*2;
end;
This procedure allow price to be doubled in the items table.
F. SYNONYMS USED:
i.)
SQL> create synonym customers for sheddy.customers;
ii.)
SQL> create synonym orders for sheddy.orders;
The synonyms customer and orders are created by the database administrator to allow outside users across
the network to access the tables customers and orders that he created.
G. TRIGGERS USED:
i.)
Least_quoted_price trigger
CREATE OR REPLACE TRIGGER "LEAST_QUOTED_PRICE"
before insert or update of quoted_price on order_items
for each row
begin
if(:new.quoted_price<1500) then
raise_application_error(-20002,'quoted price below 1500 not allowed.');
end if;
end;
/

This trigger raises an error quoted price below 1500 not allowed when the price of quoted price is
below 1500, and it applies on the order_items table.
ii.)

least_item_price

CREATE OR REPLACE TRIGGER "LEAST_ITEM_PRICE"


before update of price on items

for each row


begin
if(:new.price<300) then
raise_application_error(-20002,'Price below 300 are not allowed.');
end if;
end;
/

This trigger raises an error Price below 300 are not allowed when the item price entered in the items
table is below 300.
H. INDEXES ON THE TABLES
i.)
CUSTOMERS TABLE
CREATE INDEX "CUSTOMERS_IDX1" ON "CUSTOMERS" ("CUST_NO", "NAME", "REP_NO")
;

ii.)

ITEMS TABLE

CREATE INDEX "ITEMS_IDX1" ON "ITEMS" ("ITEM_NO", "DESCRIPTION")


;

I. ALLOWING USER SYSTEM TO USE AND TO ALLOW OTHERS TO MANIPULATE


RECORDS IN ANY OF THE TABLES CREATED.
i.
grant select,insert,update,delete on customer to system with grant option;
ii.
grant select,insert,update,delete on orders to system with grant option;
User system allowing other user ist4030 to access my tables:
grant select,insert,update on orders to ist4030;
J. a.) SHARED LOCKS ON ALL OTHER TABLES
i.)
lock table sales_reps in share mode;
ii.)
lock table order_items in share mode;
iii.)
lock table items in share mode;

b.) EXCLUSIVE LOCKS ON THE TWO TABLES CUSTOMERS & ORDERS THAT USER
SYSTEM HAS PRIVILEGES TO ACCESS THEM:
i.
ii.

lock table customers in exclusive mode;


lock table orders in exclusive mode;

1.2.2.

DESIGN AND CREATION OF THE USER INTERFACE USING JAVA APPLICATION

USER INTERFACE SCREEN SHOTS


Diagram 2. LOGIN FORM: Username Admin, Manager, Sales_Rep & Respective Password.

Diagram 3. CUSTOMERS FORM Customer No, Customer Name, Address, and Sales Rep No

Diagram 4. ORDERS FORM: Order No, Order date, Customer No

Diagram 5. ORDER ITEMS FORM: Item No, Order No, Number Ordered, Quoted Price, Total

10

Diagram 6. ITEMS FORM: Item No, Description, Price

Diagram 7. SALES REPRESENTATIVE FORM: Sales Rep No, Sales Rep Name

11

2.0.

DISCUSSION

Some of the challenges I faced was the limited time I had to plan for, design, and implement the system.
However my learning process was improved through development, in short iterative and consultation
cycles. Overall, I can say that doing this project has been a remarkable learning experience as I have
learnt design and implementation concepts that I can apply in future with emphasis to oracle database and
programming in Java. Oracle has proved to be one of the best database platforms, since one can easily
understand and use it.
3.0. SUMMARY
Beauty Products Enterprise System is a system that aims to place the companys data on a computer
managed by fully featured Data Base Management System, hence ensuring that the data is more current
and more accurate than the present manual system. This will in turn enable the companys management to
generate reports from the database which are more reliable without human error hence accurate. This
system is user friendly, saves time, efficient, easy to use and manage, hence its of great importance. It
has been implemented using Java and SQL which are both cross-platform so as to enhance portability. I
would recommend this system to other institutions and schools of higher learning and welcome any ideas
from other system designers in order to improve the system.

12

Vous aimerez peut-être aussi