Вы находитесь на странице: 1из 18

Boazii University MIS Dept.

MIS 511 Sales and Distribution Database


Instructor: Assist. Prof. Osman Darcan
Phase I

Abide Cokun Ercan Ay Murat Umut zer

FALL 2011 2012

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 ................................................................................. 16 5.1. DML SQL Statements for Operations ................................................................... 16 5.2. DML SQL Statements for Reports ........................................................................ 16

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 Kil 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-Yeniky 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)

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) 3

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) 4

Attributes having alphabetic characters: o Customer name(50 characters) o Country (25 characters) o City(25 characters) o Street (25 characters) o Order status (accepted or rejected) o Personnel name (25 characters) o Personnel surname (25 characters) o Personnel type (25 characters) o Department (20 characters) o Delivery status (delivered or not delivered) o Delivery Channel (25 characters) o Warehouse city (25 characters) o Status (available or not available)

Attributes having alphanumeric characters: o Customer type (25 characters) o Street (25 characters) o Customer e-mail ( 25 characters) o Personnel address (50 characters) o Personnel e-mail (25 characters) o Warehouse location (25 characters) o Product name (50 characters) o Product type (25 characters) o Brand (25 characters)

Attributes having dates: o Order date o Delivery date o Invoice date

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.

2.1. Entity-Relationship Diagram

3. LOGICAL DATA MODEL


3.1. Normalized Relational Schema

3.2. Primary Keys


Primary key of each relation are as follows: Customer_ID 8

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, Delivery_ID) PERSONNEL (SSN, Name, Surname, Type, Department, Salary, Address, Phone, Email) PRODUCT (Product_ID, P_Name, P_Type, P_Brand, Unit_Price, Customer_ID, O_Date, O_Status, Personnel_ID,

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) 9

4. PHYSICAL DATA MODEL

Product_ID P_Name P_Type Brand Unit_Price Description Status P_Weight P_Volume

Product int <pk> char(50) char(25) char(25) numeric(5) varchar(50) char(25) numeric(4,2) numeric(5,2)

FK_PRODUCT_IS_STORED

Product_ID Order_ID Warehouse_ID P_Quantity Stock_Amt

Store Warehouse int <pk>,<fk1> Warehouse_No int int <pk>, <fk2> FK_WAREHOUSE_IS_STORED Personnel_ID int int <pk>, <fk3> Location char(25) numeric(6,2) Capacity char(10) numeric(6,2) City char(25)

<pk> <fk>

FK_ORDER_IS_STORED

FK_PERSONNEL_CONTROLS_WAREHOUSE

Customer Customer_ID int C_Name char(50) C_Type char(25) Country char(25) City char(25) Street char(25) C_Phone char(15) C_Email char(25) C_Fax char(15)

Order_ID <pk> Customer_ID FK_CUSTOMER_GIVES_ORDER Personnel_ID Delivery_ID O_Date O_Status

Order int int int int datetime char(10)

<pk> <fk> <fk> <fk>

FK_ORDER_HAS_INVOICE

SSN Name FK_PERSONNEL_TAKES_ORDER Surname Type Department Salary Address Phone Email FK_PERSONNEL_CREATES_INVOICE

Personnel int char(25) char(25) char(25) char(20) char(5) char(50) char(10) char(25)

<pk>

Invoice_No Order_ID Personnel_ID Date Sum Total_Tax

Invoice int <pk> int <fk> int <fk> datetime numeric(8,2) numeric(5,2)

FK_PERSONNEL_PERFORMS_DELIVERY

FK_DELIVERY_RECEIVES_ORDER

Delivery Delivery_ID int <pk> Personnel_ID int <fk> D_Date datetime D_Cost numeric(6,2) D_Status char(25) D_Channel char(25) Total_Weight numeric(8,2) Total_Volume numeric(10,2)

4.1. DDL SQL Statements


4.1.1. CUSTOMER Table CREATE TABLE CUSTOMER ( Customer_ID C_Name C_Type int char (50) char(25) NOT NULL IDENTITY (1,1), NOT NULL, NULL,

10

C_Country C_City C_Street C_Phone C_Email C_Fax

char(25) char(25) char(25) char(15) char (25) char(15)

NULL, NULL, NULL, NULL, NULL, NULL,

CONSTRAINT CustomerPK PRIMARY KEY (Customer_ID) );

4.1.2. PRODUCT Table CREATE TABLE PRODUCT ( Product_ID P_Name P_Type P_Brand Unit_Price Description Status P_Weight P_Volume int char(50) char(25) char(25) numeric(5,2) varchar(50) char(25) numeric(4,2) numeric(5,2) NOT NULL IDENTITY (1,1), NOT NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL

CONSTRAINT ProductPK PRIMARY KEY (Product_ID), CONSTRAINT ProductStatusValues (Status IN (available, not available)) );

11

4.1.3. PERSONNEL Table CREATE TABLE PERSONNEL ( SSN Name Surname Type Department Salary Address Phone Email int char (25) char(25) char(25) char(20) char(5) char(50) char(10) char(25) NOT NULL IDENTITY (1,1), NOT NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,

CONSTRAINT PersonnelPK PRIMARY KEY (SSN) CONSTRAINT SalaryValues CHECK (Salary 1000 AND Salary 10000 ) );

4.1.4. ORDER Table CREATE TABLE ORDER ( Order_ID O_Date O_Status int datetime char(10) NOT NULL IDENTITY (1,1), NULL, NULL,

CONSTRAINT OrderPK PRIMARY KEY (Order_ID), CONSTRAINT CustomerFK FOREIGN KEY (Customer_ID) REFERENCES CUSTOMER (Customer_ID) ON DELETE NO ACTION ON UPDATE CASCADE, CONSTRAINT PersonnelFK FOREIGN KEY (Personnel_ID) REFERENCES PERSONNEL (SSN)

12

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 Location Capacity City int char(25 ) char(10) char(25) NOT NULL IDENTITY (1,1), NULL, NULL, 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 D_Date D_Cost D_Status D_Channel Total_Weight int datetime numeric(6,2) char(25) char(25) numeric(8,2) NOT NULL IDENTITY (1,1), NULL, NULL, NULL, NULL, NULL, 13

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 Date Sum Total_Tax int datetime numeric(8,2) numeric(5,2) NOT NULL IDENTITY (1,1), NULL, NULL, 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 Order_ID Warehouse_No int int int NOT NULL IDENTITY (1,1), NOT NULL, IDENTITY(1,1), NOT NULL, IDENTITY(1,1)

14

Stock_Amt P_Quantity

numeric(6,2) numeric(6,2)

NULL, NULL, PRIMARY KEY (Product_ID, Order_ID,

CONSTRAINT StorePK 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 REFERENCES WAREHOUSE(Warehouse_No), ); KEY (Warehouse_No)

15

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.Gn, Order.Status,

Customer.CustomerID, Delivery.D_Date, Delivery.D_Status FROM Delivery INNER = JOIN (Customer INNER ON JOIN [Order] ON =

Customer.[CustomerID] Order.[DeliveryID];

Order.[CustomerID])

Delivery.[DeliveryID]

16

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.Gn, 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];

17

Вам также может понравиться