Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

SA Paribohon

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Course Title:Database Management System with Lab

Course Code:CSE 225+CSE226


Name:Ananya Barua Tisha
ID:221003112

Part:1
1.Entity types:SA PARIBAHON,Shipped item,Retail centre,Transportation events.
2.Relationship types:
3.ERD:

4.Relational Model:
SA PARIBAHON
Branch name(FK) Branch ID(PK) Address(FK)
Chittagong 1 Muradpur
Dhaka 2 Kamlapur

Shipped item
Item Weight Dimensions Insurance Destination Final
number(PK) (FK) (FK) Amount(FK) (FK) delivery
date(FK)
1 5 2 25k Dhaka 10/8/2023

2 6 1 50k Chittagong 12/8/2023

Retail Centre
Unique ID(PK) Type(FK) Address(FK)
3 number Dhaka
4 number Chittagong

Transportation Event
Schedule number(PK) Type(FK) Delivery route(FK)
5 number 5
6 number 7

5.Data Dictionary:
SA PARIBAHON:
Field name Data type Size Range Description
Branch name varchar 20 1-25 Store branch
name
Branch ID number 8 0-4 Store branch
informaton
Address varchar 12 2-8 Store branch
location
Shipped item:
Field name Data type Size Range Description
Item number number 8 2-8 Store item
details
Weight number 8 1-4 Store item
weight
Dimensions number 16 2-8 Store degree
Insurance number 256 0-25 Store
amount insurance
amount
Destination varchar 16 1-4 Store location
Final delivery number 8 2-8 Store date
date

Retail Centre:
Field name Data type Size Range Description
Unique ID number 8 0-4 Store id
Type varchar 16 1-16 Store many
information
Address varchar 4 2-8 Store location

Transportation event:
Field name Data type Size Range Description
Schedule number 8 2-8 Store schedule
number number
Type varchar 16 2=25 Store many
information
Delivery route varchar 8 1-8 Store delivery
address
Part:B
6.
a)CREATE TABLE Branch(Branch_name VARCHAR2(50),Branch_id NUMBER,Address
VARCHAR2(100));

b) CREATE TABLE ShippedItem (itemNumber VARCHAR2(100),weight


NUMBER(50),dimensions VARCHAR2(100), insuranceAmount NUMBER(50), destination
VARCHAR2(200), finalDeliveryDate DATE NUMBER(20));

c)CREATE TABLE RetailCentre(unique_id NUMBER(50),type VARCHAR(100),Address


VARCHAR(100));

d)CREATE TABLE TransportationEvent(schedule_number(50),type


VARCHAR(100),delivery_route VARCHAR(100));

7.
a)1.ALTER TABLE Branch ADD CONSTRAINT PK_Branches PRIMARY
KEY(Branch_name);
2.ALTER TABLE Branch ADD CONSTRAINT FK_Branches FOREIGN
KEY(Branch_name)REFERANCE Branches(Branch_name);
3.ALTER TABLE Branch ALTER COLUMN Branch_name(set not null);
b)1. ALTER TABLE Branch ADD CONSTRAINT PK_Branches PRIMARY KEY(Branch_id);
2. ALTER TABLE Branch ADD CONSTRAINT FK_Branches FOREIGN
KEY(Branch_id)REFERANCE Branches(Branch_id);
3. ALTER TABLE Branch ALTER COLUMN Branch_id(set not null);
c) 1.ALTER TABLE Addresses ADD CONSTRAINT PK_Addresses PRIMARY
KEY(Addresses);
2.ALTER TABLE Addresses ADD CONSTRAINT FK_Branches FOREIGN
KEY(Addresses)REFERANCE Branches(Addresses);
3.ALTER TABLE Addresses ALTER COLUMN Addresses(set not null);

8.
ALTER TABLE Shippeditem ADD CONSTRAINT CHK_maxweight CHECK (weight<=40);
9.
ALTER TABLE Shippeditem ADD CONSTRAINT CHK_futuredeliverydate
CHECK(newdeliverydate>=GETDATE());
10.
a)1.INSERT INTO
Branch(Branch_name,Branch_id,address)VALUES(1,’Chittagong’,’Muradpur’),(2,’Dhaka’,’Ka
mlapur’),(3,’Rajshahi’,’Mirzapur’);
2.INSERT INTO
Shippeditem(Item_number,weight,dimension,insurance_amount,destination,final_delivery_date)
VALUES(1,’5’,’2’,’25k’,’Dhaka’,’10/8/2023’),(2,’6’,’1’,’50k’,’Chittagong’,’12/8/2013’),(3,’4’,’
6’,’70k’,’Rajshahi’,’15/8/2023’);
3.INSERT INTO
Retailcentre(Unique_id,type,address)VALUES(3,’number’,’Dhaka’),(4,’number’,’Chittagong’),(
5,’number’,’Rajshahi’);
4.INSERT INFO
TransportationEvent(Schedule_number,type,delivery_route)VALLUES(5,’number’,’5’),(6,’num
ber’,’7’),(7,’number’,’9’);
b)SELECT*FROM ShippedItem;
c)SELECT CONCAT(Item_number, ’,’ ,weight) AS ‘item number and weight’ FROM
ShippedItem;
d)SELECT Item_number,weight FROM ShippedItem WHERE weight NOT BETWEEN 20
AND 30 AND destination LIKE ‘%Chittagong%’;
e)SELECT Item_number FROM ShippedItem WHERE
DATE_FORMAT(final_delivery_date,’%Y-%m-%d’)=’21-5-2022’;
f)1. SELECT UPPER(destination) AS Uppercasedestination FROM ShippedItem;
2. SELECT Item_number, LEN(destination) AS destinationlength FROM ShippedItem;
3. SELECT weight, ROUND(weight / 2, 2) AS halfweight FROM ShippedItem;
g)1. SELECT destination, COUNT(*) AS ShipmentCount FROM ShippedItems GROUP BY
destination;
2. SELECT destination, SUM(weight) AS totalweight FROM ShippedItem GROUP BY
destination;
3. SELECT destination, SUM(weight) AS totalweight FROM ShippedItem GROUP BY
destination;
h)1. SELECT *FROM ShippedItem NATURAL JOIN destination_info;
2. SELECT *FROM ShippedItem LEFT OUTER JOIN destination_info ON
ShippedItem.destination = destination_info.destination;
3. SELECT *FROM ShippedItem RIGHT OUTER JOIN destination_info ON
ShippedItem.destination = destination_info.destination;
4. SELECT *FROM ShippedItem FULL OUTER JOIN destinationInfo ON
ShippedItem.destination = destination_info.destination;
i) SELECT ItemNumber, weight FROM ShippedItem WHERE weight > (SELECT AVG(weight)
FROM ShippedItem);

Discussion:
Entity Relationship Diagrams are diagrams that show the relationships between different entity
sets that are kept in databases. ER diagrams helps to describe the conceptual structure of
databases. In ER diagram , three things are mostly engaged one is Entities ,other is attributes and
last is relationship . Three different shape for them that i used in the part A and part B.With the
help of ERP diagram ,a database designer can understand the data that are stored in database. An
ERD Diagram can be used to communicate with users about the database's conceptual
foundation.
An entity is a such kind of real-world object that we all know, either alive or non-living. All the
things in company are shown in our designed database . It is a fact that is generally related to the
company issue or a event .
Relationship is like the association of two or more entities. Relationships involve entities.
Relationships between verbs or verb phrases are frequently useable .Strong entity sets have a
unique primary key, which is represented by a rectangle with an emphasized attribute. They exist
as dominant entities making relationships with others through diamond symbols. Weak entity
sets are indicated by double rectangles and dashed underlines because they lack a complete key.
In part A, I've introduced an entity-relationship (ER) model for a transportation context. There
are four major entities identified: SA PARIBAHON (Branches), Shipped Item, Retail Centre, and
Transportation Events. While the Relational Model defines entity properties, it lacks particular
relationship types and visual representation in an Entity-Relationship Diagram (ERD). The Data
Dictionary contains information about properties such as data types, sizes, ranges, and brief
descriptions. This section provides the framework for understanding data structures by
emphasizing entity features and attributes.
In part B, The information presented focuses into the design, manipulation, and querying of a
database considesring a transportation context. It covers several areas of database design and
interaction, all of which contribute to the effective management of transportation-related data.
SA PARIBAHON (Branches), Shipped Item, Retail Centre, and Transportation Events are the
four basic entity types in the context. Each entity type has unique properties that collect critical
information.
The Relational Model specifies the structure of each entity type's tables, including attributes, data
formats, and sizes. Primary keys (PK) and foreign keys (FK) are used to link tables together.
Data integrity and consistency are ensured through constraints such as the creation of primary
keys, foreign keys, and attribute checks.
Insert statements show how to update tables with sample data, emulating real-world settings.
Queries provide information about data retrieval and manipulation. The SELECT statements
show several query scenarios, including as fetching data, concatenating values, filtering based on
specified requirements, dealing with date formats, and performing aggregate computations. JOIN
techniques, such as NATURAL JOIN and other OUTER JOIN kinds, enable data from many
tables to be combined, giving light on relationships and intersections between entities.
The supplied information provides a basic overview of utilizing SQL commands to handle data
in a transportation environment. To assist effective transportation management, it emphasizes the
necessity of preserving data accuracy, performing quick data retrieval, and building meaningful
connections between entities.

You might also like