Upload
umut-izer
View
218
Download
0
Embed Size (px)
Citation preview
8/2/2019 MIS 511 Phase I
http://slidepdf.com/reader/full/mis-511-phase-i 1/18
0
Boğaziçi University MIS Dept.
MIS 511 – Sales and Distribution Database
Instructor: Assist. Prof. Osman Darcan
Abide Coşkun
Ercan Ay
Murat Umut İzer
Phase I
FALL 2011 – 2012
8/2/2019 MIS 511 Phase I
http://slidepdf.com/reader/full/mis-511-phase-i 2/18
1
INDEX
1. APPLICATION DESCRIPTION ................................................................................... 2
1.1. Presentation of the Company and the System.......................................................... 2
1.2. Users of the Database ............................................................................................... 3
1.3. Entities of the Database ........................................................................................... 3
1.4. Inputs of the Database .............................................................................................. 3
1.5. Data Constraints of the Database ............................................................................. 4
1.6. Reports of the Database ........................................................................................... 6
1.7. Operations of the Database ...................................................................................... 6
2. CONCEPTUAL DATA MODEL ................................................................................... 6
2.1. Entity-Relationship Diagram ................................................................................... 7
3. LOGICAL DATA MODEL ............................................................................................ 8
3.1. Normalized Relational Schema................................................................................ 8
3.2. Primary Keys ........................................................................................................... 8
3.3. Referential Integrity Constraints .............................................................................. 9
3.4. Functional Dependencies ......................................................................................... 9
4. PHYSICAL DATA MODEL ........................................................................................ 10
4.1. DDL SQL Statements ............................................................................................ 10
4.1.1. ‘CUSTOMER’ Table ...................................................................................... 10
4.1.2. ‘PRODUCT’ Table ......................................................................................... 11
4.1.3. ‘PERSONNEL’ Table..................................................................................... 12
4.1.4. ‘ORDER’ Table .............................................................................................. 12
4.1.5. ‘WAREHOUSE’ Table ................................................................................... 13
4.1.6. ‘DELIVERY’ Table........................................................................................ 13
4.1.7. ‘INVOICE’ Table ........................................................................................... 14
4.1.8. ‘STORE’ Table ............................................................................................... 14
5. OPERATIONS AND REPORTS ................................................................................. 165.1. DML SQL Statements for Operations ................................................................... 16
5.2. DML SQL Statements for Reports ........................................................................ 16
8/2/2019 MIS 511 Phase I
http://slidepdf.com/reader/full/mis-511-phase-i 3/18
2
1. APPLICATION DESCRIPTION
1.1. Presentation of the Company and the System
The Hayat Group, the share capital of which is under the possession of the Kiğılı
Family, primarily shows activity in the chemicals and wood-based industry. Hayat Group
consists of:
Hayat Chemicals Inc.
Hayat Cleaning and Sanitary Products Corp.
Limaş Port Enterprises Inc.
Yongapan Forestry Products Inc.
Hayat Chemicals Cleaning and Sanitary Products is manufacturing household
cleaning products, baby-care products, feminine hygienic products and personal care
products with its state-of-the-art technology in its İzmit-Yeniköy Integrated
Manufacturing Facilities.
The company uses ERP system built on SAP software. The system consists of several
modules which provide overall control and manageability. The most important modules
are listed below:
MM (Materials Management)
PP (Production Planning)
SD (Sales and Distribution)
Besides the main modules, Hayat Group uses also the assistant SAP modules such as:
FI (Financial Accounting)
CO (Controlling)
PS (Project Systems)
QM (Quality Management)
BW (Business Warehousing)
PM (Plant Maintenance)
8/2/2019 MIS 511 Phase I
http://slidepdf.com/reader/full/mis-511-phase-i 4/18
3
1.2. Users of the Database
In our project, we will create a database for the SD module. In this database, users of
the system are:
Sales personnel
Delivery personnel
Warehousemen
Accountants
Customers
SAP consultants
1.3. Entities of the Database
Entities of the database are:
Order
Personnel
Delivery
Product
Customer
Warehouse
Invoice
1.4. Inputs of the Database
In addition, the inputs of the database are:
Customer data (customer ID, customer name, customer type, customer
address(country, city, street), phone, e-mail, fax)
Personnel data (SSN, name, surname, type, department, salary, address,
phone, e-mail)
Product data (product ID, product name, product type, brand, unit price,
description, status, product weight, product volume)
Order data (order ID, order date, order status)
8/2/2019 MIS 511 Phase I
http://slidepdf.com/reader/full/mis-511-phase-i 5/18
4
Delivery data (delivery ID, delivery date, delivery cost, delivery status,
delivery channel, total weight, total volume)
Invoice data (invoice number, date, sum, total tax)
Warehouse data (warehouse number, location, city, capacity)
Store data(product quantity, stock amount)
1.5. Data Constraints of the Database
Data constraints of the database are as follows:
Attributes having only numerical characters:
o Customer ID(8 digits and not null)
o Customer phone(15 digits)
o Customer Fax(15 digits)
o Product ID (8 digits and not null)
o Unit price (5 digits )
o Product weight (4 digits)
o Product volume (5 digits)
o Order ID (8 digits and not null)
o SSN (7 digits and not null)
o Salary (5 digits)
o Personnel phone(10 digits)
o Delivery ID (8 digits and not null)
o Delivery cost (6 digits)
o Total weight (8 digits)
o Total volume (10 digits)
o Warehouse number (2 digits and not null)
o Capacity (10 digits)
o Invoice number (8 digits and not null)
o Sum (8 digits)
o Total tax (5 digits)
o Product quantity (6 digits)
o Stock amount (6 digits)
8/2/2019 MIS 511 Phase I
http://slidepdf.com/reader/full/mis-511-phase-i 6/18
8/2/2019 MIS 511 Phase I
http://slidepdf.com/reader/full/mis-511-phase-i 7/18
6
1.6. Reports of the Database
Reports produced by the system may include:
Order summary reports
Invoice reports
Customer activity reports
Stock summary reports
1.7. Operations of the Database
Operations that are included in the database are:
Order Entry
Stock Control
Order Delivery
Order Billing
2. CONCEPTUAL DATA MODEL
The system works as follows:
When a customer demands to buy a product, the attributes of the customer are
recorded or updated in the database. An order is created by the sales personnel, the
relevant product data is called by the system. Afterwards, the amount of the relevant
product(s) in the warehouse(s) is controlled by the warehousemen, if it is sufficient, an
invoice is prepared and the relevant product(s) will be delivered with the invoice of the
order. After the delivery step, the warehouse data will be updated and the accountant will
update invoice data.
The limitations of the database may be:
A product without an invoice should not be delivered.
If the amount of a product in the warehouse is insufficient, an order will not
be produced.
Customers will only be able to reach the relevant order information.
8/2/2019 MIS 511 Phase I
http://slidepdf.com/reader/full/mis-511-phase-i 8/18
7
2.1. Entity-Relationship Diagram
8/2/2019 MIS 511 Phase I
http://slidepdf.com/reader/full/mis-511-phase-i 9/18
8
3. LOGICAL DATA MODEL
3.1. Normalized Relational Schema
3.2. Primary Keys
Primary key of each relation are as follows:
Customer_ID
8/2/2019 MIS 511 Phase I
http://slidepdf.com/reader/full/mis-511-phase-i 10/18
9
Order_ID
SSN
Product_ID
Warehouse_No
Delivery_ID
3.3. Referential Integrity Constraints
Referential integrity constraints of the database are:
Customer_ID (FK)Customer_ID (PK)
Order_ID (FK) Order_ID (PK)
Personnel_ID (FK)
SSN (PK)
Product_ID (FK) Product_ID (PK)
Delivery_ID (FK) Delivery_ID (PK)
Warehouse_No (FK)Warehouse_No (PK)
3.4. Functional Dependencies
Functional dependencies of the database are shown below:
CUSTOMER (Customer_ID, C_Name, C_Country, C_City, C_Street,
C_Phone, C_Email, C_Fax)
ORDER (Order_ID, Customer_ID, O_Date, O_Status, Personnel_ID,
Delivery_ID)
PERSONNEL (SSN, Name, Surname, Type, Department, Salary, Address,
Phone, Email)
PRODUCT (Product_ID, P_Name, P_Type, P_Brand, Unit_Price,
Description, Status, P_Weight, P_Volume) WAREHOUSE (Warehouse_No, Location, City, Capacity, Personnel_ID)
DELIVERY (Delivery_No, D_Date, D_Cost, D_Status, D_Channel,
Total_Weight, Total_Volume, Personnel_ID)
INVOICE (Invoice_No, Order_ID, Date, Sum, Tax_Amount, Personnel_ID)
STORE (Order_ID, Product_ID, Warehouse_No, P_Quantity, Stock_Amt)
8/2/2019 MIS 511 Phase I
http://slidepdf.com/reader/full/mis-511-phase-i 11/18
10
4. PHYSICAL DATA MODEL
4.1. DDL SQL Statements
4.1.1. ‘CUSTOMER’ Table
CREATE TABLE CUSTOMER (
Customer_ID int NOT NULL IDENTITY (1,1),
C_Name char (50) NOT NULL,
C_Type char(25) NULL,
Product_ID int <pk> Product_ID int <pk>,<fk1> Warehouse_No int <pk>P_Name char(50) Order_ID int <pk>, <fk2> Personnel_ID int <fk>
P_Type char(25) Warehouse_ID int <pk>, <fk3> Location char(25)
Brand char(25) P_Quantity numeric(6,2) Capacity char(10)
Unit_Price numeric(5) Stock_Amt numeric(6,2) City char(25)
Description varchar(50)
Status char(25)
P_Weight numeric(4,2) FK_PERSONNEL_CONTROLS_WAREHOUSE
P_Volume numeric(5,2)
Order_ID int <pk> SSN int <pk>
Customer_ID int <pk> Customer_ID int <fk> Name char(25)
C_Name char(50) Personnel_ID int <fk> Surname char(25)
C_Type char(25) Delivery_ID int <fk> Type char(25)Country char(25) O_Date datetime Department char(20)
City char(25) O_Status char(10) Salary char(5)
Street char(25) Address char(50)
C_Phone char(15) Phone char(10)
C_Email char(25) Email char(25)
C_Fax char(15) FK_PERSONNEL_CREATES_INVOICE
FK_PERSONNEL_PERFORMS_DELIVERY
Invoice_No int <pk>
Order_ID int <fk>
Personnel_ID int <fk>
Date datetime Delivery_ID int <pk>
Sum numeric(8,2) Personnel_ID int <fk>
Total_Tax numeric(5,2) D_Date datetime
D_Cost numeric(6,2)
D_Status char(25)
D_Channel char(25)
FK_DELIVERY_RECEIVES_ORDER Total_Weight numeric(8,2)
Total_Volume numeric(10,2)
Invoice
FK_ORDER_HAS_INVOICE
Delivery
FK_PERSONNEL_TAKES_ORDER
FK_PRODUCT_IS_STORED
FK_ORDER_IS_STORED
FK_WAREHOUSE_IS_STORED
FK_CUSTOMER_GIVES_ORDER
Order
Product
Customer
Store Warehouse
Personnel
8/2/2019 MIS 511 Phase I
http://slidepdf.com/reader/full/mis-511-phase-i 12/18
11
C_Country char(25) NULL,
C_City char(25) NULL,
C_Street char(25) NULL,
C_Phone char(15) NULL,
C_Email char (25) NULL,
C_Fax char(15) NULL,
CONSTRAINT CustomerPK PRIMARY KEY (Customer_ID)
);
4.1.2. ‘PRODUCT’ Table
CREATE TABLE PRODUCT (
Product_ID int NOT NULL IDENTITY (1,1),
P_Name char(50) NOT NULL,
P_Type char(25) NULL,
P_Brand char(25) NULL,
Unit_Price numeric(5,2) NULL,
Description varchar(50) NULL,
Status char(25) NULL,
P_Weight numeric(4,2) NULL,
P_Volume numeric(5,2) NULL
CONSTRAINT ProductPK PRIMARY KEY (Product_ID),
CONSTRAINT ProductStatusValues (Status IN (‘available’, ‘not available’))
);
8/2/2019 MIS 511 Phase I
http://slidepdf.com/reader/full/mis-511-phase-i 13/18
8/2/2019 MIS 511 Phase I
http://slidepdf.com/reader/full/mis-511-phase-i 14/18
13
ON DELETE NO ACTION ON UPDATE CASCADE,
CONSTRAINT DeliveryFK FOREIGN KEY (Delivery_ID) REFERENCES
DELIVERY (Delivery_ID)
ON DELETE NO ACTION ON UPDATE CASCADE,
CONSTRAINT StatusValues (O_Status IN (‘Accepted’, ‘Rejected’)),
);
4.1.5. ‘WAREHOUSE’ Table
CREATE TABLE WAREHOUSE (
Warehouse_No int NOT NULL IDENTITY (1,1),
Location char(25 ) NULL,
Capacity char(10) NULL,
City char(25) NULL,
CONSTRAINT WarehousePK PRIMARY KEY (Warehouse_No)
CONSTRAINT PerssonnelFK FOREIGN KEY (Personnel_ID) REFERENCES
PERSONNEL(SSN)
ON DELETE SET DEFAULT ON UPDATE CASCADE,
);
4.1.6. ‘DELIVERY’ Table
CREATE TABLE DELIVERY (
Delivery_ID int NOT NULL IDENTITY (1,1),
D_Date datetime NULL,
D_Cost numeric(6,2) NULL,
D_Status char(25) NULL,
D_Channel char(25) NULL,
Total_Weight numeric(8,2) NULL,
8/2/2019 MIS 511 Phase I
http://slidepdf.com/reader/full/mis-511-phase-i 15/18
14
Total_Volume numeric(10,2) NULL,
CONSTRAINT DeliveryPK PRIMARY KEY (Delivery_ID),
CONSTRAINT PersonnelFK FOREIGN KEY (Personnel_ID) REFERENCES
PERSONNEL(SSN)
ON DELETE SET DEFAULT ON UPDATE CASCADE,
CONSTRAINT DstatusValues (D_Status IN (‘delivered’, ‘not delivered’)),
);
4.1.7. ‘INVOICE’ Table
CREATE TABLE INVOICE (
Invoice_No int NOT NULL IDENTITY (1,1),
Date datetime NULL,
Sum numeric(8,2) NULL,
Total_Tax numeric(5,2) NULL,
CONSTRAINT InvoicePK PRIMARY KEY (Invoice_No),
CONSTRAINT OrderFK FOREIGN KEY (Order_ID) REFERENCES ORDER(Order_ID)
ON DELETE SET DEFAULT ON UPDATE CASCADE,
CONSTRAINT PersonnelFK FOREIGN KEY (Personnel_ID) REFERENCES
PERSONNEL(SSN)
ON DELETE SET DEFAULT ON UPDATE CASCADE,
);
4.1.8. ‘STORE’ Table
CREATE TABLE STORE (
Product_ID int NOT NULL IDENTITY (1,1),
Order_ID int NOT NULL, IDENTITY(1,1),
Warehouse_No int NOT NULL, IDENTITY(1,1)
8/2/2019 MIS 511 Phase I
http://slidepdf.com/reader/full/mis-511-phase-i 16/18
15
Stock_Amt numeric(6,2) NULL,
P_Quantity numeric(6,2) NULL,
CONSTRAINT StorePK PRIMARY KEY (Product_ID, Order_ID,
Warehouse_No),CONSTRAINT ProductFK FOREIGN KEY (Product_ID) REFERENCES
PRODUCT(Product_ID),
CONSTRAINT OrderFK FOREIGN KEY (Order_ID) REFERENCES
ORDER(Order_ID),
CONSTRAINT WarehouseFK FOREIGN KEY (Warehouse_No)
REFERENCES WAREHOUSE(Warehouse_No),
);
8/2/2019 MIS 511 Phase I
http://slidepdf.com/reader/full/mis-511-phase-i 17/18
16
5. OPERATIONS AND REPORTS
5.1. DML SQL Statements for Operations
Order Entry:
INSERT INTO ORDER (O_date, O_status, Customer_ID, Personnel_SSN, Delivery_ID)
VALUES (‘2011-11-30 13:10:00’, ‘accepted’, 5, 1, 50);
INSERT INTO STORE (Product_ID, Order_ID, Warehouse_No, P_Quantity)
VALUES (15,10,3, 500);
Stock Control:
UPDATE STORE
SET Stock_Amt = 2500
WHERE Product_ID = 15 and Warehouse_No= 3;
5.2. DML SQL Statements for Reports
Order summary reports:
SELECT Order.OrderID, Order.Year, Order.Month, Order.Gün, Order.Status,
Customer.CustomerID, Delivery.D_Date, Delivery.D_Status
FROM Delivery INNER JOIN (Customer INNER JOIN [Order] ON
Customer.[CustomerID] = Order.[CustomerID]) ON Delivery.[DeliveryID] =
Order.[DeliveryID];
8/2/2019 MIS 511 Phase I
http://slidepdf.com/reader/full/mis-511-phase-i 18/18
17
Invoice reports:
SELECT Invoice.InvoiceNo, Order.OrderID, Invoice.Date, Invoice.Sum,
Invoice.TotalTax, Personnel.SSN, Personnel.Name, Personnel.Surname
FROM (Personnel INNER JOIN Invoice ON Personnel.[SSN] = Invoice.[P_SSN])
INNER JOIN [Order] ON Invoice.[InvoiceNo] = Order.[InvoiceNo];
Customer activity reports:
SELECT Store.OrderID, Customer.CustomerID, Store.ProductID, Order.Year,
Order.Month, Order.Gün, Store.P_Quantity
FROM (Customer INNER JOIN [Order] ON Customer.[CustomerID] =
Order.[CustomerID]) INNER JOIN Store ON Order.[OrderID] = Store.[OrderID];
Stock summary reports:
SELECT Product.ProductID, Product.P_Name, Store.WarehouseNo,
Warehouse.Location, Store.StockAmount
FROM Warehouse INNER JOIN (Product INNER JOIN Store ON Product.[ProductID]
= Store.[ProductID]) ON Warehouse.[WarehouseNo] = Store.[WarehouseNo];