Parcel Delivery Management System
Parcel Delivery Management System
Spring 2020-21
Introduction to Database
Section – B
Course Teacher:
Juena Ahmed Noshin
Project Name:
Parcel Delivery Management System
Group Members
SL No. Name ID
01 WASEK-AL-AZAD, MD 19-39381-1
02 SAHA, TAPU 19-40152-1
03 OHI, SABIHA KHAIR 20-41905-1
04 ANZOOM, TANVIR 20-41920-1
05 FARDOUS, RIJOAN 20-41943-1
Page |1
Contents
Introduction ............................................................................................... 2
Scenario Description ................................................................................. 3
ER Diagram ............................................................................................... 4
Normalization ............................................................................................ 5
Normalization Steps: ........................................................................ 5
Temporary Tables: ......................................................................... 11
Final Tables: ................................................................................... 12
Schema Diagram ..................................................................................... 13
Table Creation ......................................................................................... 14
Sequence: ........................................................................................ 17
Data Insertion .......................................................................................... 18
Query Writing .......................................................................................... 23
Subquery ......................................................................................... 23
Joining ............................................................................................ 24
View ............................................................................................... 24
Relational Algebra ................................................................................... 26
Conclusion ............................................................................................... 27
Introduction
Scenario Description
ER Diagram
Normalization
Normalization Steps:
Place Branch
UNF
place (OrderID, OrderDate, CustID, CustName, CustEmail, CustPhone,
ApartmentNo, PostalCode, StreetName, City)
1NF
CustPhone is a multi-valued attribute.
1. OrderID, OrderDate, CustID, CustName, CustEmail, CustPhone,
ApartmentNo, PostalCode, StreetName, City
2NF
1. OrderID, OrderDate
2. CustID, CustName, CustEmail, CustPhone, ApartmentNo,
PostalCode, StreetName, City
3NF
1. OrderID, OrderDate
2. CustID, CustName, CustEmail, CustPhone
3. ApartmentNo, PostalCode, StreetName, City
Table Creation
1. OrderID, OrderDate, CustID
2. CustID, CustName, CustEmail, CustPhone, AddressID
3. AddressID, ApartmentNo, PostalCode, StreetName, City
Contain Branch
UNF
contain (OrderID, OrderDate, ProductID, ProductName, ProductPrice,
Quantity, DeliveryDate)
1NF
There is no multivalued attribute. Relation already in 1NF.
1. OrderID, OrderDate, ProductID, ProductName, ProductPrice,
Quantity, DeliveryDate
2NF
1. OrderID, OrderDate
2. ProductID, ProductName, ProductPrice, Quantity, DeliveryDate
3NF
There is no transitive dependency. Relation already in 3NF.
1. OrderID, OrderDate
2. ProductID, ProductName, ProductPrice, Quantity, DeliveryDate
Table Creation
1. OrderID, OrderDate
2. ProductID, ProductName, ProductPrice, Quantity, DeliveryDate,
OrderID
Pay Branch
UNF
pay (PaymentID, TotalPrice, PaymentDate, CustID, CustName,
CustEmail, CustPhone, ApartmentNo, PostalCode, StreetName, City)
1NF
CustPhone is a multi-valued attribute.
1. PaymentID, TotalPrice, PaymentDate, CustID, CustName,
CustEmail, CustPhone, ApartmentNo, PostalCode, StreetName,
City
2NF
1. PaymentID, TotalPrice, PaymentDate
2. CustID, CustName, CustEmail, CustPhone, ApartmentNo,
PostalCode, StreetName, City
3NF
1. PaymentID, PaymentDate, TotalPrice
2. CustID, CustName, CustEmail, CustPhone
3. ApartmentNo, PostalCode, StreetName, City
Table Creation
1. PaymentID, PaymentDate, TotalPrice, CustID
2. CustID, CustName, CustEmail, CustPhone, AddressID
3. AddressID, ApartmentNo, PostalCode, StreetName, City
Receive Branch
UNF
receive (ProductID, ProductName, ProductPrice, Quantity, DeliveryDate,
CustID, CustName, CustEmail, CustPhone, ApartmentNo, PostalCode,
StreetName, City)
1NF
CustPhone is a multi-valued attribute.
1. ProductID, ProductName, ProductPrice, Quantity, DeliveryDate,
CustID, CustName, CustEmail, CustPhone, ApartmentNo,
PostalCode, StreetName, City
2NF
1. ProductID, ProductName, ProductPrice, Quantity, DeliveryDate
2. CustID, CustName, CustEmail, CustPhone, ApartmentNo,
PostalCode, StreetName, City
3NF
1. ProductID, ProductName, ProductPrice, Quantity, DeliveryDate
2. CustID, CustName, CustEmail, CustPhone
3. ApartmentNo, PostalCode, StreetName, City
Table Creation
1. ProductID, DeliveryDate, ProductName, ProductPrice, Quantity,
CustID
2. CustID, CustName, CustEmail, CustPhone, AddressID
3. AddressID, ApartmentNo, PostalCode, StreetName, City
Has Branch
UNF
has (PaymentID, TotalPrice, PaymentDate, OrderID, OrderDate)
1NF
There is no multi-valued attribute. Relation already in 1NF.
1. PaymentID, TotalPrice, PaymentDate, OrderID, OrderDate
2NF
1. PaymentID, TotalPrice, PaymentDate
2. OrderID, OrderDate
3NF
There is no transitive dependency. Relation already in 3NF.
1. PaymentID, TotalPrice, PaymentDate
2. OrderID, OrderDate
Table Creation
1. PaymentID, TotalPrice, PaymentDate
2. OrderID, OrderDate, PaymentID
Collect Branch
UNF
collect (PaymentID, TotalPrice, PaymentDate, DmID, DmName,
DmSalary, DmPhone)
1NF
DmPhone is a multi-valued attribute.
1. PaymentID, TotalPrice, PaymentDate, DmID, DmName,
DmSalary, DmPhone
2NF
1. PaymentID, TotalPrice, PaymentDate
2. DmID, DmName, DmSalary, DmPhone
3NF
There is no transitive dependency. Relation already in 3NF.
1. PaymentID, TotalPrice, PaymentDate
2. DmID, DmName, DmSalary, DmPhone
Table Creation
1. PaymentID, TotalPrice, PaymentDate, DmID
2. DmID, DmName, DmSalary, DmPhone
Deliver Branch
UNF
deliver (DmID, DmName, DmSalary, DmPhone, ProductID,
ProductName, ProductPrice, Quantity, DeliveryDate)
1NF
DmPhone is a multi-valued attribute.
1. DmID, DmName, DmSalary, DmPhone, ProductID, ProductName,
ProductPrice, Quantity, DeliveryDate
2NF
1. DmID, DmName, DmSalary, DmPhone
2. ProductID, ProductName, ProductPrice, Quantity, DeliveryDate
3NF
Table Creation
1. DmID, DmName, DmSalary, DmPhone
2. ProductID, ProductName, ProductPrice, Quantity, DeliveryDate,
DmID
Temporary Tables:
Final Tables:
Schema Diagram
Table Creation
Address Table:
CREATE TABLE Address
(AddressID NUMBER (5) CONSTRAINT PK_Address PRIMARY KEY,
ApartmentNo NUMBER (3),
StreetName VARCHAR2(20),
PostalCode NUMBER (4),
City VARCHAR2 (15));
Customer Table:
CREATE TABLE Customer
(CustID NUMBER (5) CONSTRAINT PK_Customer PRIMARY KEY,
CustName VARCHAR2(20),
CustEmail VARCHAR2(20),
CustPhone1 NUMBER (11),
CustPhone2 NUMBER (11),
AddressID NUMBER (5) CONSTRAINT FK_AddressID REFERENCES Address);
DelivaryMan Table:
CREATE TABLE DelivaryMan
(DmID NUMBER (5) CONSTRAINT PK_DelivaryMan PRIMARY KEY,
DmName VARCHAR2(20),
DmSalary NUMBER (7,2),
DmPhone1 NUMBER (11),
DmPhone2 NUMBER (11));
Payment Table:
CREATE TABLE Payment
(PaymentID NUMBER (5) CONSTRAINT PK_PaymentID PRIMARY KEY,
PaymentDate DATE,
TotalPrice NUMBER (7,2),
CustID NUMBER (5) CONSTRAINT FK_CustID REFERENCES Customer,
DmID NUMBER (5) CONSTRAINT FK_DmID REFERENCES DelivaryMan);
Orders Table:
CREATE TABLE Orders
(OrderID NUMBER (5) CONSTRAINT PK_OrderID PRIMARY KEY,
OrderDate DATE,
CustID NUMBER (5) CONSTRAINT FK_CustID1 REFERENCES Customer,
PaymentID NUMBER (5) CONSTRAINT FK_PaymentID REFERENCES
Payment);
Product Table:
CREATE TABLE Product (ProductID NUMBER (5) CONSTRAINT PK_ProductID PRIMARY
KEY,
ProductName VARCHAR2(20),
ProductPrice NUMBER (7,2),
Quantity NUMBER (2),
DelivaryDate DATE,
CustID NUMBER (5) CONSTRAINT FK_CustID2 REFERENCES Customer,
DmID NUMBER (5) CONSTRAINT FK_DmID1 REFERENCES DelivaryMan,
OrderID NUMBER (5) CONSTRAINT FK_OrderID REFERENCES Orders);
Sequence:
Data Insertion
Address Table:
1. INSERT INTO ADDRESS VALUES (222, 12, 'ABC', 1215, 'DHAKA');
2. INSERT INTO ADDRESS VALUES (333, 23, 'BCD', 1326, 'DHAKA');
3. INSERT INTO ADDRESS VALUES (444, 34, 'CDE', 1437, 'DHAKA');
4. INSERT INTO ADDRESS VALUES (555, 45, 'DEF', 1548, 'DHAKA');
5. INSERT INTO ADDRESS VALUES (666, 56, 'EFG', 1659, 'DHAKA');
SELECT * FROM ADDRESS;
Customer Table:
1. INSERT INTO CUSTOMER VALUES (Customer_custNo.NEXTVAL,
'Ohi', '[email protected]', 01720419051, 01920419051, 222);
2. INSERT INTO CUSTOMER (CustID, CustName, CustEmail, CustPhone1,
AddressID) VALUES (Customer_custNo.NEXTVAL, 'Rijoan',
'[email protected]', 1720419431, 333);
3. INSERT INTO CUSTOMER VALUES (Customer_custNo.NEXTVAL,
'Siam', '[email protected]', 20419201, 01920419201, 444);
4. INSERT INTO CUSTOMER (CustID, CustName, CustEmail, CustPhone2,
AddressID) VALUES (Customer_custNo.NEXTVAL, 'Wasek',
'[email protected]', 0171939811, 555);
5. INSERT INTO CUSTOMER VALUES (Customer_custNo.NEXTVAL,
'Tapu', '[email protected]', 01719401521, 01919401521, 666);
SELECT * FROM CUSTOMER;
DelivaryMan Table:
1. INSERT INTO DELIVARYMAN VALUES (4040, 'Azad', 7000, null,
01719456812);
2. INSERT INTO DELIVARYMAN VALUES (5050, 'Fardous', 7500,
01645984125, null);
3. INSERT INTO DELIVARYMAN VALUES (6060, 'Sabiha', 9000,
01545896574, 01436578951);
4. INSERT INTO DELIVARYMAN VALUES (7070, 'Tanvir', 8500, null,
0139217586);
5. INSERT INTO DELIVARYMAN VALUES (8080, 'Saha', 8000,
01648217457, null);
SELECT * FROM DELIVARYMAN;
Payment Table:
Orders Table:
Product Table:
Query Writing
Subquery:
2. Display all the deliveryman’s information who has a lower salary than
Tanvir’s salary.
SELECT * FROM Delivaryman WHERE DmSalary < (SELECT DmSalary
FROM Delivaryman WHERE DmName = 'Tanvir');
Joining:
1. Display all the customers name whose products were delivered on 12 Oct
2020. Also show the product they ordered.
SELECT Customer.CustName, Product.ProductName FROM Customer,
Product WHERE Customer.CustID = Product.CustID AND
Product.DelivaryDate = '12-OCT-20';
2. Display all the deliveryman’s name and salary who delivered the products
which has product id greater than 110.
View:
Relational Algebra
1. Find the name of the customer whose customer id is 1125.
∏CustName (σ CustID =1125(Customer))
3. Find the apartment no, street name and postal code where
AddressID is equal to 555.
∏ApartmentNo, StreetName, PostalCode (σ AddressID = 555 (Address))
Conclusion
In this project, we have mainly created a sql-based parcel delivery
management system focusing on proper quick delivery to the appropriate
customer in an error-free manner to reduce all sorts of hassle that happen
in a traditional management system. The project queries run in ‘Oracle
10g’. Here, we have made seven relationship among all the entities with
cardinality. We have also normalized the project to organize data elements
properly.
Future Planning:
We have tried our level-best to make the parcel delivery management
system more convenient. Yet, it has some shortcomings that can be
improved through proper arrangements. A few of them are: