Mysql Inventory Database
Mysql Inventory Database
:
:
:
:
:
:
:
:
:
CP 533
System Analysis Design
Second
02, February 2016
11, February 2016
Estelito R. Medallada, Jr., CpE
Nino Rhadney E. Cabachete
nrecabachete@gmail.com
09064709359
TABLE OF CONTENTS
Contents
CHAPTER I
Page No.
Business rules
Normalization
...
EER Diagram
...
Data Dictionary
CHAPTER II
CHAPTER III
CHAPTER IV
REFERENCES
10
13
CHAPTER I
Database Design
Business Rules
Electronic Inventory System
The idea is to keep information about products, costumers and inventory in a system in
which you can identify what product you want to buy, make list of customers name and
address, and ensure a basic inventory at all times. Here is a suggestion for some of the
object which should be modeled in the system:
Normalization
Table Product
P_ID
P_Name P_Pric
e
P_Status
Table Customers
Cus_I
D
Cus_Name Cos_Add
P_ID P_QTY
Table Inventory
I_ID
P_ID RMN_STK
I_ID
Data Dictionary
Table
Attributes
P_ID
P_NAME
PRODUCT
P_PRICE
P_STATUS
T_ID
T_ID
TYPE
P_Type
CUS_ID
Description
Product
Identification
Number
Product
Name
Product Price
Availability
Status
Type
Identification
No.
Product type
identification
number
Product Type
Customer
identification
number
CUSTUMER
CUS_NAME Customers
name
CUS_ADD
Customer
Address
CUS_ID
Customer
identification
number
CUSTOMER_HAS P_ID
Product
_PRODUCT
identification
number
P_QTS
Product
quantity
Type
INT
Size Constraint
11
Auto_Increment
PK
VARCHAR 20
Not NULL
DECIMAL 8, 2
VARCHAR 10
Not NULL
INT
11
Not NULL
FK
INT
11
Auto_Increment
PK
VARCHAR 20
Not NULL
Unique
Auto_Increment
PK
INT
11
VARCHAR
25
Not NULL
VARCHAR 45
Not NULL
INT
11
Not NULL
PK FK
INT
11
Not NULL
PK FK
INT
20
Not NULL
I_ID
INVENTORY
RMN_STK
P_ID
Inventory
identification
number
Remaining
Stocks
Product
Identification
number
INT
11
Auto_Increment
PK
INT
11
INT
11
Not NULL,
Unique
Not NULL
FK
CHAPTER II
Implementation and Loading
List all CREATE, INSERT commands used to develop the database
(inclusive PK and FK)
INSERT INTO
INVENTORY(P_ID,PURCHASE_QTY,PURCHASE_PRICE,SOLD_QTY,UNIT_P
RICE) VALUES
(1,100,25.00,25,33.00),
(2,100,20.01,12,25.23),
(3,100,7.03,50,10.97),
(4,100,10.11,22,15.56),
(5,100,170.89,44,250.11),
(6,100,215.11,25,300.12),
(7,100,825.12,23,1000.11),
(8,100,800.56,34,1000.16),
(9,100,220.90,77,350.05),
(10,100,370.88,66,500.58),
(11,100,150.44,20,225.65),
(12,100,190.90,20,300.45),
(13,100,99.20,80,125.45),
(14,100,330.23,31,400.12),
(15,100,99.90,60,160.34),
(16,100,89.12,21,100.89),
(17,100,850.34,43,1000.33),
(18,100,39.90,10,50.99),
(19,100,4525.77,20,6000.89),
(20,100,90.99,10,180.66),
(21,100,80.67,20,100.33),
(22,100,39.89,41,50.34),
(23,100,3090.78,19,4000.22),
(24,100,4454.88,11,5238.12),
(25,100,169.67,50,235.21),
(26,100,91.32,60,150.32),
(27,100,1880.65,12,2000.00),
(28,100,99.78,32,135.00),
(29,100,723.12,10,800.93),
(30,100,3990.78,90,4350.22),
(31,100,4878.34,32,5005.88),
(32,100,998.78,21,1500.11),
(33,100,58.11,45,75.00),
(34,100,189.32,34,225.80),
(35,100,667.23,23,750.21),
(36,100,1987.89,22,2500.12),
(37,100,99.90,87,150.51);
CHAPTER III
Testing and Evaluation
Write 15 different queries on your database, using the SELECT, FROM, AND WHERE
keyword. Your 15 queries should preferably illustrate six (6) different aspects of
database querying as below:
TWO (2) queries involving relation from two tables.
Queries involving each of aggregate functions (SUM, COUNT, AVG, MAX, MIN.)
ONE (1) query involving complicated selects and joins from three or more tables.
TWO (2) queries involving NOT and BETWEEN functions.
TWO (2) queries involving GROUP BY and HAVING functions.
TWO (2) queries that require the use of the DISTINCT and ORDER BY
keywords.
Two queries involving relation from two tables.
First query:
SELECT
P_NAME AS 'Product Name',
P_TYPE AS 'Type'
FROM
PRODUCT,
TYPE
WHERE PRODUCT.T_ID = TYPE.T_ID;
Second query:
SELECT
P_NAME AS 'Product Name',
RMN_STK AS 'Remaining Stocks'
FROM
PRODUCT,
INVENTORY
WHERE PRODUCT.P_ID = INVENTORY.P_ID ;
Queries involving each of aggregate functions (SUM, COUNT, AVG, MAX, MIN)
Query using SUM aggregate function
SELECT SUM(RMN_STK) FROM INVENTORY;
Query using COUNT aggregate function
SELECT COUNT(*) FROM CUSTOMER;
Query using AVG aggregate function
SELECT AVG(P_Price) FROM PRODUCT;
Query using MAX aggregate function
SELECT MAX(P_Price) FROM PRODUCT;
Query using MIN aggregate function
SELECT MIN(P_Price) FROM PRODUCT;
Query involving complicated selects and joins from three or more tables.
SELECT
P_NAME AS 'Product Name',
P_Type AS 'Type',
RMN_STK AS 'Remaining Stock'
FROM
PRODUCT p,
TYPE t,
INVENTORY i
WHERE
p.`T_ID` = t.`T_ID`
AND p.`P_ID` = i.`P_ID`;
Second query:
SELECT
P_TYPE AS 'Product Type' ,
COUNT(P_NAME) AS 'Product per type'
FROM
PRODUCT p,
TYPE t
WHERE p.`T_ID` = t.`T_ID`
GROUP BY t.`P_TYPE`
HAVING COUNT(P_NAME) > 1;
TWO (2) queries that require the use of the DISTINCT and ORDER BY keywords.
First query:
SELECT DISTINCT
P_NAME AS 'Product',
P_Type AS 'Product Type',
RMN_STK AS 'Remaining Stocks'
FROM
PRODUCT p,
TYPE t,
INVENTORY i
CHAPTER IV
Future Enhancement
While the system itself is almost comprehensive at as it is, there are a lot of
rooms for improvement. First is to add an attribute to determine the description of the
product. It helps to identify which product should be brought.
For visual purposed, a photo attribute should also be included for the product
entity. This guide the selection process for particular situation.
Some product doesnt last long enough like the inks so it is also important to add
another attribute for the date of expiration. This will not only serves as guide in
refreshing the stocks but also exclude the product from selling expired products.