A
Project Report
on
Weather Forecast Log Management System
Developed by
Jaimish Trivedi - Department of IT, DDUniversity
Himanshu Vaghela -Department of IT, DDUniversity
Guided By
Internal Guide:
Prof. Roshni M. Raval
Department of Information Technology
Faculty of Technology
DD University
Department of Information Technology
Faculty of Technology, Dharmsinh Desai University
College Road, Nadiad-387001
October-2019
TABLE OF CONTENTS
I. Certificate .................................................................................................................. I
II. Acknowledgement .................................................................................................. II
1. SYSTEM OVERVIEW ........................................................................................... 1
1.1 Current system ..................................................................................................... 2
1.2 Objectives of the Proposed System...................................................................... 3
1.3 Advantages of the Proposed system (over current) ............................................. 4
2. E-R DIAGRAM ........................................................................................................ 5
2.1 Entities…………………………………………………………………………..5
2.2 Relationships……………………………………………………………………6
2.3 Mapping Constraints……………………………………………………………6
3. DATA DICTIONARY ............................................................................................. 7
4. SCHEMA DIAGRAM ............................................................................................. 8
5. DATABASE IMPLEMENTION ............................................................................ 9
5.1 Create Schema ........................................................................................................ 9
5.2 Insert Data values .................................................................................................... 9
5.3 Queries (Based on functions, group by, having, joins, sub query etc.) ............... 10
5.4 PL/SQL Blocks (Procedures and Functions) ........................................................ 10
5.5 Views .................................................................................................................... 11
5.6 Functions ............................................................................................................... 12
5.7 Procedures ............................................................................................................. 14
5.8 Triggers ................................................................................................................. 15
5.9 Cursors. ................................................................................................................. 16
6. FUTURE ENHANCEMENTS OF THE SYSTEM ............................................ 18
7. BIBLIOGRAPHY .................................................................................................. 20
DHARMSINH DESAI UNIVERSITY
NADIAD-387001, GUJARAT
CERTIFICATE
This is to certify that the project entitled “Weather Forecast Log Management
System” is a bonafied report of the work carried out by
1) Mr. Jaimish Trivedi, Student ID No: 17ITUOS082
2) Mr. Himanshu Vaghela, Student ID No: 16ITUSS148
of Department of Information Technology, semester V, under the guidance and
supervision for the subject Database Management System. They were involved in
Project training during academic year 2019-2020.
Prof. Roshni M. Raval
(Project Guide)
Department of Information Technology,
Faculty of Technology,
Dharmsinh Desai University, Nadiad
Date:
Prof. Vipul Dabhi
Head , Department of Information Technology,
Faculty of Technology,
Dharmsinh Desai University, Nadiad
Date:
i
ACKNOWLEDGEMENT
This Project being the first undertaken by us and it was unforgettable and educative
[Link] take this oppurtunity to thank all those who have generously helped
us to give a proper shape to our project.
Our Sincerest Appreciation Must Be Extended To DDIT, Nadiad. We Also Want To
Thanks Faculties Of The College, They Have Been Very Kind & Helpful To Us.
We Are Thankful To Prof. R. M. Raval for giving valuable and constructive
suggestions during the planning and development of this Project.
ii
Weather Forecast Log Management System System Overview
1. SYSTEM OVERVIEW
A Weather Forecast Log Management System is a system to display forecasted data
of weather to the user.
Functionalities:-
1) Show a basic daily forecast (daily high and low temperatures, weather
conditions, and sunrise/sunset times) for each day in the next week or two.
2) Allow users to select their city and any other cities where they want to see the
weather.
3) What is the maximum and minimum temperature on a particular date at
particular city.
4) What is the weather status of a city on a particular day.
5) A server gets weather information from which satellites.
6) On which location maximum servers are there and they belong to which
weather station.
7) Windspeed in a city on particular hour.
8) Name of satellites which sends data to particular server.
9) What is sunrise and sunset time of cities that are having latitude greater than
some value.
10) On a particular server how many employees are working.
11) Display hourly details for the next 24 hours.
12) Let users to see data in the measurement units of their choice.
DDU (Faculty of Technology, Department of IT) Page 1
Weather Forecast Log Management System E-R Diagram
2. E-R DIAGRAM
Fig 2.1 E-R Diagram Of Weather Forecast Log Management System
DDU (Faculty of Technology, Department of IT) Page 2
Weather Forecast Log Management System E-R Diagram
2.1 Entities
Users
City
Country
HourlyForecastLog
DailyForecastLog
Server
WeatherStation
Employee
2.2 Relationships
selects
partof
containshourly
containsdaily
getshourly
getsdaily
getsfrom
holds
workson
worksfor
have
2.3 Mapping Constraints
1 to Many :- City and HourlyForecastLog
City and DailyForecastLog
WeatherStation and Server
WeatherStation and Employee
Many to 1:- City and Country
Employee(Worker) and Employee(Manager)
Employee and Server
Many to Many:- Users and City
Server and DailyForecastLog
Server and HourlyForecastLog
Server and Satellite
DDU (Faculty of Technology, Department of IT) Page 3
Weather Forecast Log Management System Data Dictionary
3. DATA DICTIONARY
TableName Attributes Fiel Data Type Constraint Description Example
d
Size
/
Scal
e,
Prec
ision
USERS UsersId 5 VARCHAR2 P.K., Not User U101
null identificati
on
FirstName 10 VARCHAR2 Not null User’s Alex
First name
LastName 10 VARCHAR2 Not null User’s Dempsy
Last
Name
COUNTRY CountryId 5 VARCHAR2 P.K., Not Country CTR100
null Identificat
ion
Number
CountryName 10 VARCHAR2 Not null Name of India
the
country
SATELLITE SatelliteId 5 VARCHAR2 P.K., Not Satellite SAT100
null Identificat
ion
Number
SatelliteName 10 VARCHAR2 Not null Name of ISR-300
the
Satellite
WEATHER WeatherStationId 5 VARCHAR2 P.K., Not Weather W100
STATION null Station ID
WeatherStationN 10 VARCHAR2 Not null Weather Cellular
ame Station
Name
USERS UContact1 10 Number P.K., Not User 123456789
UCONTACT null Contact 0
UsersId 5 VARCHAR2 P.K., Not User U101
null,F.K. identificati
on
DDU (Faculty of Technology, Department of IT) Page 4
Weather Forecast Log Management System Data Dictionary
UContact2 10 Number NULL User 123456789
Contact 0
UContact3 10 Number NULL User 123456789
Contact 0
CITY CityPincode 6 Number P.K., Not Pincode 382443
null number of
a city
CityName 10 VARCHAR2 Not null City Baroda
Name
CityLatitude 5,2 Number Not null Latitude 39.02
of a city
CityLongitude 5,2 Number Not null Longitude -119.47
of a city
CountryId 5 VARCHAR2 F.K., Not Country CTR100
null Identificat
ion
Number
UsersId 5 VARCHAR2 P.K., F.K., User U100
SELECTS Not null Identificat
ion
Number
CityPincode 6 NUMBER P.K., F.K., Pincode of 382443
Not null a city
HOURLY StartDateTime - TIMESTAM P.K., Not Starting 02-JAN-
FORECAST P null Date and 2019
LOG Time of A 12:32:45
Hourly
Report
Humidity 5,2 NUMBER(5, Not null Humidity 64
2) in %
Visibility 10 VARCHAR2 Not null Visibility 6
(10) in km
Pressure 5,2 NUMBER(5, Not null Air 1006
2) Pressure
in mBar
WindSpeed 5,2 NUMBER(5, Not null WindSpee 3
2) d in km/h
WindDirection 2 VARCHAR2 Not null Direction
(2) of wind
Temperature 5,2 NUMBER(5, Not null Temperatu 40
2) re
in degree
celcius
DDU (Faculty of Technology, Department of IT) Page 5
Weather Forecast Log Management System Data Dictionary
FeelsLikeTemper 5,2 NUMBER(5, Not null Normal 34
ature 2) Atmosphe
re
Temperatu
re in
degree
celcius
WeatherStatus 10 VARCHAR2 Not null Status of Sunny
(10) environme
nt
CityPincode 6 NUMBER P.K., F.K., Pincode of 382443
Not null a city
DAILY CalendarDate - DATE P.K., Not Report 03-JAN-
FORECAST Null Date 2000
LOG
SunriseTime - TIMESTAM Not Null
Sunrise 06:20:10
P Time
SunsetTime - TIMESTAM Not Null Sunset 17:02:34
P Time
AverageHumidit 5,2 NUMBER Not Null Average 67
y Humidity
in %
MaxTemperature 5,2 NUMBER Not Null Maximum 40
Temperatu
re of a day
MinTemperature 5,2 NUMBER Not Null Minimum 20
Temperatu
re of a day
WeatherStatus 10 VARCHAR2 Not Null Status of Rainy
environme
nt
CityPincode 6 NUMBER P.K., F.K., Pincode of 382443
Not null a city
EMPLOYEE EmployeeId 5 VARCHAR2 P.K., Not Employee E100
null Identificat
ion
number
EmpFirstName 10 VARCHAR2 Not null First name Tracy
of an
employee
EmpLastName 10 VARCHAR2 Not null Last name Davis
of an
employee
EmpDOB - DATE Not null Date of 01-JAN-
birth of an 1993
employee
ServerId 5 VARCHAR2 Not null Server S100
Identificat
DDU (Faculty of Technology, Department of IT) Page 6
Weather Forecast Log Management System Data Dictionary
ion
Number
WeatherStationId 5 VARCHAR2 F.K., Not Weather W100
null Station ID
no.
ManagerId 5 VARCHAR2 F.K., Not Manager M100
null ID no.
EMPLOYEE EmpContact1 10 NUMBER P.K., Not Employee 123456789
EMPCONTA null contact 0
CT no.1
EmpContact2 10 NUMBER NULL Employee 123456789
contact 0
no.1
EmpContact3 10 NUMBER NULL Employee 123456789
contact 0
no.1
EmployeeId 5 VARCHAR2 P.K., F.K., Employee E100
Not null ID no.
GETSFROM SatelliteId 5 VARCHAR2 P.K., F.K., Satellite SAT100
Not null Identificat
ion
Number
ServerId 5 VARCHAR2 P.K., F.K., Server S100
Not null Identificat
ion
Number
CityPincode 6 Number P.K., F.K., Pincode 382443
GETSHOUR Not null number of
LY a city
StartDateTime TIMESTAM P.K., F.K., Starting 02-JAN-
P Not null Date and 2019
Time of A 12:32:45
Hourly
Report
ServerId 5 VARCHAR2 P.K., F.K., Server S100
Not null Identificat
ion
Number
GETSDAIL CityPincode 6 Number P.K., F.K., Pincode 382443
Y Not null number of
a city
CalendarDate DATE P.K., Not Report 03-JAN-
Null Date 2000
SERVER ServerId 5 VARCHAR2 P.K., F.K., Server S100
Not null Identificat
ion
DDU (Faculty of Technology, Department of IT) Page 7
Weather Forecast Log Management System Data Dictionary
Number
ServerLocation 20 VARCHAR2 NOT Server Ahmedabad,
NULL Location Gujarat
WeatherStationId 5 VARCHAR2 P.K.,F.K, Id WS101
NOT associated
NULL WeatherSta
on of the
server
DDU (Faculty of Technology, Department of IT) Page 8
Weather Forecast Log Management System Scherma Diagram
4. SCHEMA DIAGRAM
Fig 4.1 Schema Diagram Of Weather Forecast Log Management System
DDU (Faculty of Technology, Department of IT) Page 9
Weather Forecast Log Management System Database Implementation
[Link] IMPLEMENTION
5.1 CREATE SCHEMA
CREATE TABLE Users
(
UsersId VARCHAR2(5) NOT NULL,
FirstName VARCHAR2(10) NOT NULL,
LastName VARCHAR2(10) NOT NULL,
UsersEmail VARCHAR2(30) NOT NULL,
PRIMARY KEY (UsersId)
)
DESC Users;
CREATE TABLE Country
(
CountryId VARCHAR2(5) NOT NULL,
CountryName VARCHAR2(10) NOT NULL,
PRIMARY KEY (CountryId)
)
DESC Country;
CREATE TABLE Satellite
(
SatelliteId VARCHAR2(5) NOT NULL,
SatelliteName VARCHAR2(10) NOT NULL,
PRIMARY KEY (SatelliteId)
)
DESC Satellite;
DDU (Faculty of Technology, Department of IT) Page 10
Weather Forecast Log Management System Database Implementation
CREATE TABLE WeatherStation
(
WeatherStationId VARCHAR2(5) NOT NULL,
WeatherStationName VARCHAR2(10) NOT NULL,
PRIMARY KEY (WeatherStationId)
)
DESC WeatherStation;
CREATE TABLE UsersUContact
(
UContact1 NUMBER(10) NOT NULL,
UContact2 NUMBER(10) NULL,
UContact3 NUMBER(10) NULL,
UsersId VARCHAR2(5) NOT NULL,
PRIMARY KEY (UContact1, UsersId),
FOREIGN KEY (UsersId) REFERENCES Users(UsersId)
)
DESC UsersUContact;
CREATE TABLE City
(
CityPincode NUMBER(6) NOT NULL,
CityName VARCHAR2(10) NOT NULL,
CityLatitude NUMBER(5,2) NOT NULL,
CityLongitude NUMBER(5,2) NOT NULL,
CountryId VARCHAR2(5) NOT NULL,
PRIMARY KEY (CityPincode),
FOREIGN KEY (CountryId) REFERENCES Country(CountryId)
)
DESC City;
DDU (Faculty of Technology, Department of IT) Page 11
Weather Forecast Log Management System Database Implementation
CREATE TABLE Server
(
ServerLocation VARCHAR2(10) NOT NULL,
ServerId VARCHAR2(5) NOT NULL,
WeatherStationId VARCHAR2(5) NOT NULL,
PRIMARY KEY (ServerId),
FOREIGN KEY (WeatherStationId) REFERENCES
WeatherStation(WeatherStationId)
)
DESC Server;
CREATE TABLE Selects
(
UsersId VARCHAR2(5) NOT NULL,
CityPincode NUMBER(6) NOT NULL,
PRIMARY KEY (UsersId, CityPincode),
FOREIGN KEY (UsersId) REFERENCES Users(UsersId),
FOREIGN KEY (CityPincode) REFERENCES City(CityPincode)
)
DESC Selects;
CREATE TABLE HourlyForecastLog
(
StartDateTime TIMESTAMP NOT NULL,
Humidity NUMBER(5,2) NOT NULL,
Visibility VARCHAR2(10) NOT NULL,
Pressure NUMBER(5,2) NOT NULL,
WindSpeed NUMBER(5,2) NOT NULL,
WindDirection VARCHAR2(2) NOT NULL,
Temperature NUMBER(5,2) NOT NULL,
DDU (Faculty of Technology, Department of IT) Page 12
Weather Forecast Log Management System Database Implementation
FeelsLikeTemperature NUMBER(5,2) NOT NULL,
WeatherStatus VARCHAR2(20) NOT NULL,
CityPincode NUMBER(6,0) NOT NULL,
PRIMARY KEY (CityPincode, StartDateTime),
FOREIGN KEY (CityPincode) REFERENCES City(CityPincode),
)
DESC HourlyForecastLog;
CREATE TABLE DailyForecastLog
(
CalendarDate DATE NOT NULL,
SunriseTime TIMESTAMP NOT NULL,
SunsetTime TIMESTAMP NOT NULL,
AverageHumidity NUMBER(5,2) NOT NULL,
MaxTemperature NUMBER(5,2) NOT NULL,
MinTemperature NUMBER(5,2) NOT NULL,
WeatherStatus VARCHAR2(20) NOT NULL,
CityPincode NUMBER(6) NOT NULL,
PRIMARY KEY (CalendarDate,CityPincode),
FOREIGN KEY (CityPincode) REFERENCES City(CityPincode),
)
DESC DailyForecastLog;
CREATE TABLE getshourly
(
ServerId VARCHAR2(5) NOT NULL,
StartDateTime TIMESTAMP NOT NULL,
CityPincode NUMBER(6) NOT NULL,
PRIMARY KEY (ServerId, StartDateTime, CityPincode),
FOREIGN KEY (ServerId) REFERENCES Server(ServerId),
DDU (Faculty of Technology, Department of IT) Page 13
Weather Forecast Log Management System Database Implementation
FOREIGN KEY (StartDateTime, CityPincode) REFERENCES
HourlyForecastLog(StartDateTime, CityPincode)
)
DESC getshourly;
CREATE TABLE getsdaily
(
ServerId VARCHAR2(5) NOT NULL,
CalendarDate DATE NOT NULL,
CityPincode NUMBER(6) NOT NULL,
PRIMARY KEY (ServerId, CalendarDate, CityPincode),
FOREIGN KEY (ServerId) REFERENCES Server(ServerId),
FOREIGN KEY (CalendarDate, CityPincode) REFERENCES
DailyForecastLog(CalendarDate, CityPincode)
)
DESC getsdaily;
CREATE TABLE getsfrom
(
SatelliteId VARCHAR2(5) NOT NULL,
ServerId VARCHAR2(5) NOT NULL,
PRIMARY KEY (SatelliteId, ServerId),
FOREIGN KEY (SatelliteId) REFERENCES Satellite(SatelliteId),
FOREIGN KEY (ServerId) REFERENCES Server(ServerId)
)
DESC getsfrom;
CREATE TABLE Employee
(
EmployeeId VARCHAR2(5) NOT NULL,
EmpFirstName VARCHAR2(20) NOT NULL,
EmpLastName VARCHAR2(20) NOT NULL,
DDU (Faculty of Technology, Department of IT) Page 14
Weather Forecast Log Management System Database Implementation
EmpDOB DATE NOT NULL,
Designation VARCHAR2(20) NOT NULL,
ServerId VARCHAR2(5) NOT NULL,
WeatherStationId VARCHAR2(5) NOT NULL,
ManagerId VARCHAR2(5),
PRIMARY KEY (EmployeeId),
FOREIGN KEY (ServerId) REFERENCES Server(ServerId),
FOREIGN KEY (WeatherStationId) REFERENCES
WeatherStation(WeatherStationId),
FOREIGN KEY (worksfor_EmployeeId) REFERENCES Employee(EmployeeId)
)
DESC Employee;
CREATE TABLE EmployeeEmpContact
(
EmpContact1 NUMBER(10) NOT NULL,
EmpContact2 NUMBER(10) NULL,
EmpContact3 NUMBER(10) NULL,
EmployeeId VARCHAR2(5) NOT NULL,
PRIMARY KEY (EmpContact1, EmployeeId),
FOREIGN KEY (EmployeeId) REFERENCES Employee(EmployeeId)
)
DESC EmployeeEmpContact;
5.2 INSERT DATA VALUES
BEGIN
Insert into Users(FirstName, LastName, UsersId,UsersEmail)
Values ('Himanshu', 'Vaghela', 'U1','hv@[Link]');
Insert into Users(FirstName, LastName, UsersId,UsersEmail)
Values ('Jaimish', 'Trivedi', 'U2','JT@[Link]');
DDU (Faculty of Technology, Department of IT) Page 15
Weather Forecast Log Management System Database Implementation
Insert into Users(FirstName, LastName, UsersId,UsersEmail)
Values ('Sameep', 'Baraiya', 'U3','sb@[Link]');
Insert into Users(FirstName, LastName, UsersId,UsersEmail)
values ('Adil', 'Otha', 'U4','ao@[Link]');
Insert into Users(FirstName, LastName, UsersId,UsersEmail)
Values ('Aayush', 'Panchal', 'U5','ap@[Link]');
Insert into Users(FirstName, LastName, UsersId,UsersEmail)
Values ('Bhupendra', 'Dabhi', 'U6','bd@[Link]');
END
SELECT * FROM Users;
BEGIN.
Insert into Country(CountryId,CountryName)
Values ('CY1','India');
Insert into Country(CountryId,CountryName)
Values ('CY2','China');
Insert into Country(CountryId,CountryName)
Values ('CY3','Thailand');
Insert into Country(CountryId,CountryName)
Values ('CY4','Singapore');
Insert into Country(CountryId,CountryName)
Values ('CY5','Germany');
Insert into Country(CountryId,CountryName)
Values ('CY6','USA');
Insert into Country(CountryId,CountryName)
Values ('CY7','Canada');
Insert into Country(CountryId,CountryName)
Values ('CY8','UK');
END
SELECT * FROM Country;
DDU (Faculty of Technology, Department of IT) Page 16
Weather Forecast Log Management System Database Implementation
BEGIN
Insert into Satellite(SatelliteId,SatelliteName)
Values('S1','Aryabhatta');
Insert into Satellite(SatelliteId,SatelliteName)
Values('S2','Bhaskara1');
Insert into Satellite(SatelliteId,SatelliteName)
Values('S3','Bhaskara2');
Insert into Satellite(SatelliteId,SatelliteName)
Values('S4','IRS1A');
Insert into Satellite(SatelliteId,SatelliteName)
Values('S5','INSAT1C')
END
SELECT * FROM Satellite;
BEGIN
Insert into WeatherStation
Values('WS1','Ahmedabad');
Insert into WeatherStation
Values('WS2','Rajkot');
Insert into WeatherStation
Values('WS3','Bhavnagar');
Insert into WeatherStation
Values('WS4','Porbandar');
Insert into WeatherStation
Values('WS5','Surat');
DDU (Faculty of Technology, Department of IT) Page 17
Weather Forecast Log Management System Database Implementation
Insert into WeatherStation
Values('WS6','Nashik');
Insert into WeatherStation
Values('WS7','Mumbai');
END
SELECT * FROM WeatherStation;
BEGIN
Insert into Usersucontact(Usersid,UContact)
Values('U1',7623927428);
Insert into Usersucontact(Usersid,UContact)
Values('U2',7227008511);
Insert into Usersucontact(Usersid,UContact)
Values('U3',9284675963);
Insert into Usersucontact(Usersid,UContact)
Values('U4',7849135933);
Insert into Usersucontact(Usersid,UContact)
Values('U5',8645436943);
Insert into Usersucontact(Usersid,UContact)
Values('U6',9876541232);
END
SELECT * FROM Usersucontact;
BEGIN
Insert into City(CityName,CityLongitude,CityLatitude,CityPincode,CountryId)
DDU (Faculty of Technology, Department of IT) Page 18
Weather Forecast Log Management System Database Implementation
Values('Ahmedabad',85.43,57.76,380027,'CY1');
Insert into City(CityName,CityLongitude,CityLatitude,CityPincode,CountryId)
Values('Nadiad',156.23,57.36,380078,'CY1');
Insert into City(CityName,CityLongitude,CityLatitude,CityPincode,CountryId)
Values('Rajkot',128.23,58.36,380045,'CY1');
Insert into City(CityName,CityLongitude,CityLatitude,CityPincode,CountryId)
Values('Surat',138.23,51.36,380745,'CY1');
Insert into City(CityName,CityLongitude,CityLatitude,CityPincode,CountryId)
Values('Bhavnagar',198.23,23.46,380063,'CY1');
Insert into City(CityName,CityLongitude,CityLatitude,CityPincode,CountryId)
Values('Mumbai',185.23,90.26,380041,'CY1');
Insert into City(CityName,CityLongitude,CityLatitude,CityPincode,CountryId)
Values('Hyderabad',170.23,35.86,380086,'CY1');
END
SELECT * FROM City;
BEGIN
Insert into Server(ServerId,ServerLocation,SatelliteId,WeatherStationId)
Values('SE3','BhavnagariArea','S3','WS3');
Insert into Server(ServerId,ServerLocation,SatelliteId,WeatherStationId)
Values('SE2','RajkotRotary','S2','WS2');
Insert into Server(ServerId,ServerLocation,SatelliteId,WeatherStationId)
Values('SE1','RTOCIRCLE','S1','WS1');
END
SELECT * FROM Server;
BEGIN
Insert into Selects
DDU (Faculty of Technology, Department of IT) Page 19
Weather Forecast Log Management System Database Implementation
Values('U1',380027);
Insert into Selects
Values('U1',380078);
Insert into Selects
Values('U1',380041);
Insert into Selects
Values('U2',380027);
Insert into Selects
Values('U3',380063);
Insert into Selects
Values('U4',380063);
Insert into Selects
Values('U5',380027);
Insert into Selects
Values('U6',380027);
END
SELECT * FROM Selects;
BEGIN
INSERT INTO
HourlyForecastLog(StartDateTime,Humidity,Visibility,Pressure,WindSpeed,WindDir
ection,Temperature,FeelsLikeTemperature,WeatherStatus,CityPincode,ServerId)
VALUES(timestamp '2019-08-01
06:14:00.74',10,'High',10,10,'NE',10,8,'Sunny',380027,'SE1');
INSERT INTO
HourlyForecastLog(StartDateTime,Humidity,Visibility,Pressure,WindSpeed,WindDir
ection,Temperature,FeelsLikeTemperature,WeatherStatus,CityPincode,ServerId)
VALUES(timestamp '2019-08-01
07:14:00',7,'High',7,7,'NE',7,7,'Sunny',380027,'SE1');
INSERT INTO
HourlyForecastLog(StartDateTime,Humidity,Visibility,Pressure,WindSpeed,WindDir
ection,Temperature,FeelsLikeTemperature,WeatherStatus,CityPincode,ServerId)
DDU (Faculty of Technology, Department of IT) Page 20
Weather Forecast Log Management System Database Implementation
VALUES(timestamp '2019-08-01
05:14:00.74',10,'High',5,5,'NE',5,5,'Sunny',380027,'SE1');
INSERT INTO
HourlyForecastLog(StartDateTime,Humidity,Visibility,Pressure,WindSpeed,WindDir
ection,Temperature,FeelsLikeTemperature,WeatherStatus,CityPincode,ServerId)
VALUES(timestamp '2019-08-01
04:14:00.74',4,'High',4,4,'NE',4,4,'Sunny',380027,'SE1');
INSERT INTO
HourlyForecastLog(StartDateTime,Humidity,Visibility,Pressure,WindSpeed,WindDir
ection,Temperature,FeelsLikeTemperature,WeatherStatus,CityPincode,ServerId)
VALUES(timestamp '2019-08-01
03:14:00.74',10,'High',3,3,'NE',3,3,'Sunny',380027,'SE1');
INSERT INTO
HourlyForecastLog(StartDateTime,Humidity,Visibility,Pressure,WindSpeed,WindDir
ection,Temperature,FeelsLikeTemperature,WeatherStatus,CityPincode,ServerId)
VALUES(timestamp '2019-08-01
02:14:00.74',10,'High',2,2,'NE',2,2,'Sunny',380027,'SE1');
INSERT INTO
HourlyForecastLog(StartDateTime,Humidity,Visibility,Pressure,WindSpeed,WindDir
ection,Temperature,FeelsLikeTemperature,WeatherStatus,CityPincode,ServerId)
VALUES(timestamp '2019-08-01
01:14:00.74',1,'High',1,1,'NE',1,1,'Sunny',380027,'SE1');
INSERT INTO
HourlyForecastLog(StartDateTime,Humidity,Visibility,Pressure,WindSpeed,WindDir
ection,Temperature,FeelsLikeTemperature,WeatherStatus,CityPincode,ServerId)
VALUES(timestamp '2019-08-01
00:14:00.74',10,'High',0,0,'NE',0,0,'Sunny',380027,'SE1');
END
SELECT * FROM HourlyForecastLog;
DDU (Faculty of Technology, Department of IT) Page 21
Weather Forecast Log Management System Database Implementation
BEGIN
insert into
DailyForecastLog(CalendarDate,ServerId,Weatherstatus,CityPincode,SunriseTime,Su
nsetTime,AverageHumidity,MinTemperature,MaxTemperature)
values(to_date ('27/AUGUST/2019'),'SE1','Sunny',380027, timestamp '2019-08-27
06:00:08.74', timestamp '2019-08-27 19:14:00.74',27,20,30);
insert into DailyForecastLog(CalendarDate,ServerId,Weatherstatus,CityPincode)
values(to_date ('28/AUGUST/2019'),'SE1','Rainy',380027, timestamp '2019-08-28
06:00:08.74', timestamp '2019-08-28 19:15:00.74',28,20,30);
insert into DailyForecastLog(CalendarDate,ServerId,Weatherstatus,CityPincode)
values(to_date ('29/AUGUST/2019'),'SE1','Cloudy',380027, timestamp '2019-08-29
06:00:08.74', timestamp '2019-08-29 19:16:00.74',29,20,30);
insert into DailyForecastLog(CalendarDate,ServerId,Weatherstatus,CityPincode)
values(to_date ('30/AUGUST/2019'),'SE1','Sunny',380027, timestamp '2019-08-30
06:00:08.74', timestamp '2019-08-30 19:17:00.74',30,20,30);
insert into DailyForecastLog(CalendarDate,ServerId,Weatherstatus,CityPincode)
values(to_date ('31/AUGUST/2019'),'SE1','Sunny',380027, timestamp '2019-08-31
06:00:08.74', timestamp '2019-08-31 19:18:00.74',31,20,30);
END
SELECT * FROM DailyForecastLog;
BEGIN
Insert into
Employee(EmployeeId,EmpFirstName,EmpLastName,Designation,EmpDOB,ServerI
d,WeatherStationId,ManagerId)
values(
'E1','King','Puri','CEO','25/AUGUST/1997','SE1','WS1',NULL);
Insert into
Employee(EmployeeId,EmpFirstName,EmpLastName,Designation,EmpDOB,ServerI
d,WeatherStationId,ManagerId)
values(
'E2','Suresh','Puri','HRManager','05/AUGUST/1997','SE1','WS1','E1');
DDU (Faculty of Technology, Department of IT) Page 22
Weather Forecast Log Management System Database Implementation
Insert into
Employee(EmployeeId,EmpFirstName,EmpLastName,Designation,EmpDOB,ServerI
d,WeatherStationId,ManagerId)
values(
'E3','Mahesh','Puri','Electrician','25/MAY/1997','SE1','WS1','E2');
Insert into
Employee(EmployeeId,EmpFirstName,EmpLastName,Designation,EmpDOB,ServerI
d,WeatherStationId,ManagerId)
values(
'E4','Jayesh','Puri','Programmer','15/JULY/1997','SE1','WS1','E2');
END
SELECT * FROM Employee;
BEGIN
Insert into EmployeeEmpContact(EmployeeId,EmpContact1)
Values('E1',456123890);
Insert into EmployeeEmpContact(EmployeeId,EmpContact1)
Values('E2',326123890);
Insert into EmployeeEmpContact(EmployeeId,EmpContact1)
Values('E3',126123890);
Insert into EmployeeEmpContact(EmployeeId,EmpContact1)
Values('E4',456743890);
END
SELECT * FROM EmployeeEmpContact;
BEGIN
Insert into getshourly(ServerId,StartDateTime,CityPincode)
DDU (Faculty of Technology, Department of IT) Page 23
Weather Forecast Log Management System Database Implementation
Values('SE1','01-AUG-19 12.14.00.740000 AM',380027);
Insert into getshourly(ServerId,StartDateTime,CityPincode)
Values('SE1','01-AUG-19 01.14.00.740000 AM',380027);
Insert into getshourly(ServerId,StartDateTime,CityPincode)
Values('SE1','01-AUG-19 02.14.00.740000 AM',380027);
Insert into getshourly(ServerId,StartDateTime,CityPincode)
Values('SE1','01-AUG-19 03.14.00.740000 AM',380027);
Insert into getshourly(ServerId,StartDateTime,CityPincode)
Values('SE1','01-AUG-19 04.14.00.740000 AM',380027);
Insert into getshourly(ServerId,StartDateTime,CityPincode)
Values('SE1','01-AUG-19 05.14.00.740000 AM',380027);
Insert into getshourly(ServerId,StartDateTime,CityPincode)
Values('SE1','01-AUG-19 06.14.00.740000 AM',380027);
Insert into getshourly(ServerId,StartDateTime,CityPincode)
Values('SE1','01-AUG-19 07.14.00.000000 AM',380027);
END
SELECT * FROM getshourly;
BEGIN
Insert into getsdaily(ServerId,CalendarDate,CityPincode)
Values('SE1','27-AUG-19 ',380027);
Insert into getsdaily(ServerId,CalendarDate,CityPincode)
Values('SE1','28-AUG-19 ',380027);
Insert into getsdaily(ServerId,CalendarDate,CityPincode)
Values('SE1','29-AUG-19 ',380027);
Insert into getsdaily(ServerId,CalendarDate,CityPincode)
Values('SE1','30-AUG-19 ',380027);
Insert into getsdaily(ServerId,CalendarDate,CityPincode)
Values('SE1','31-AUG-19 ',380027);
END
SELECT * FROM getsdaily;
DDU (Faculty of Technology, Department of IT) Page 24
Weather Forecast Log Management System Database Implementation
BEGIN
Insert into getsfrom(ServerId,SatelliteId)
Values('SE1','S1');
Insert into getsfrom(ServerId,SatelliteId)
Values('SE2','S1');
Insert into getsfrom(ServerId,SatelliteId)
Values('SE3','S2');
END
SELECT * FROM getsfrom;
DDU (Faculty of Technology, Department of IT) Page 25
Weather Forecast Log Management System Database Implementation
5.3 QUERIES (BASED ON FUNCTIONS, GROUP BY, HAVING,
JOINS, SUB QUERY ETC.)
[Link] Minimum And Maximum Temperature of a City having pincode '380027'
on the date '29-aug-19':
Select [Link],[Link],[Link],[Link]
From City c full outer join DailyForecastLog d on [Link] = [Link]
Where [Link]= 380027 and [Link]='29-aug-19';
[Link] Weather Status of a City having pincode '380027' on the date '27-aug-19':
Select [Link],[Link],[Link]
From City c full outer join DailyForecastLog d on [Link] = [Link]
Where [Link]= 380027 and [Link]='27-aug-19';
[Link] having ID 'SE1' gets weather information from which satellites:
Select [Link],[Link],[Link]
From Server se right outer join getsfrom g on [Link]=[Link]
right outer join satellite sa on [Link]=[Link]
where [Link]='SE1';
[Link] of servers in each Weather Station:
select [Link],count([Link])
from server s full outer join weatherstation w
on [Link]=[Link]
group by ([Link]) ;
[Link] of a city having pincode '380027' on the 3rd hour of the day:
DDU (Faculty of Technology, Department of IT) Page 26
Weather Forecast Log Management System Database Implementation
select [Link] as "windspeed(km/h)",[Link],extract(hour from
[Link]) as hours
from hourlyforecastlog h full outer join city c
on [Link]=[Link]
where [Link]=380027
and extract(hour from [Link])=3;
[Link] having ID 'S1' sends the weather information to which severs:
Select [Link],[Link],[Link]
From Server se right outer join getsfrom g on [Link]=[Link]
right outer join satellite sa on [Link]=[Link]
where [Link]='S1';
[Link] time and sunset time of the cities having latitude greater than 57:
select [Link],[Link],[Link],[Link]
from city c full outer join dailyforecastlog d
on [Link]=[Link]
where [Link]
in
(select citylatitude from city
where citylatitude > 57.00
);
[Link] Of Employees working on A server:
select serverid,count(employeeid) as "Employees working"
from employee
group by serverid;
DDU (Faculty of Technology, Department of IT) Page 27
Weather Forecast Log Management System Database Implementation
[Link] Temperature in its various measurements:
select temperature as "temperature in degree celsius",temperature+273 as
"temperature in kelvin",(9*(temperature/5)+32) as "temperature in fahrenheit"
from hourlyforecastlog;
[Link] Name who is working under Some manager:
select empfirstname,employeeid,managerid
from employee
where managerid is not null;
DDU (Faculty of Technology, Department of IT) Page 28
Weather Forecast Log Management System Database Implementation
5.4 PL/SQL Blocks
[Link] the appropriate message if user tries to search for the details of a city whose
record is not in DataBase(Exception).
DECLARE
cname [Link]%type := :c;
cpin [Link]%type;
clong [Link]%type;
clat [Link]%type;
BEGIN
SELECT cityname,citypincode,citylongitude,citylatitude INTO
cname,cpin,clong,clat
FROM city
WHERE [Link]=cname;
DBMS_OUTPUT.PUT_LINE('City: '||cname );
DBMS_OUTPUT.PUT_LINE('Pincode: '||cpin );
DBMS_OUTPUT.PUT_LINE('Longitude: '||clong );
DBMS_OUTPUT.PUT_LINE('Latitude: '||clat );
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('No Record For this city named '||
cname);
END
DDU (Faculty of Technology, Department of IT) Page 29
Weather Forecast Log Management System Database Implementation
OUTPUT 1:
OUTPUT 2:
[Link] the Weather Station of a Server.(Implicit Cursor)
BEGIN
UPDATE Server
SET WeatherStationId = :WSid
WHERE Serverid = :ServID;
IF SQL%FOUND THEN
DDU (Faculty of Technology, Department of IT) Page 30
Weather Forecast Log Management System Database Implementation
DBMS_OUTPUT.PUT_LINE('Server is now part of This Weather
Station');
END IF;
IF SQL%NOTFOUND THEN
DBMS_OUTPUT.PUT_LINE('Error: either ServerID is wrong or
WeatherStationID is wrong,Please Check');
END IF;
END
OUTPUT 1:
OUTPUT 2:
DDU (Faculty of Technology, Department of IT) Page 31
Weather Forecast Log Management System Database Implementation
[Link] a record table for cities whose temperature is greater than 50 degrees, to put
them on red alert(Cursor)
CREATE TABLE Alerted_cities
cname VARCHAR2(10),
cpin NUMBER(6),
maxt NUMBER(5,2),
cdate DATE
);
DECLARE
CURSOR Red_alert
IS
SELECT [Link],[Link],[Link],[Link]
FROM city c FULL OUTER JOIN dailyforecastlog d
ON [Link]=[Link]
WHERE [Link]>50;
BEGIN
FOR I IN Red_alert
LOOP
DDU (Faculty of Technology, Department of IT) Page 32
Weather Forecast Log Management System Database Implementation
INSERT INTO Alerted_cities VALUES ([Link], [Link],
[Link],[Link]);
END LOOP;
COMMIT;
END
->SELECT * FROM Alerted_cities;
[Link] a record of users,who have searched for a particular city(here city having
pincode 380027) to send them updates about that city(Cursor)
CREATE TABLE update_user
u_id varchar2(5),
u_con number(10),
u_mail varchar2(30)
);
DDU (Faculty of Technology, Department of IT) Page 33
Weather Forecast Log Management System Database Implementation
DECLARE
CURSOR send_update
IS
SELECT [Link],uc.Ucontact1,[Link],[Link]
FROM usersucontact uc full outer join users u ON [Link]=[Link] full
outer join selects s on [Link]=[Link]
WHERE [Link]=380027;
BEGIN
FOR I IN send_update
LOOP
INSERT INTO update_user VALUES ([Link], I.ucontact1,
[Link]);
END LOOP;
COMMIT;
END
->SELECT * FROM update_user;
DDU (Faculty of Technology, Department of IT) Page 34
Weather Forecast Log Management System Database Implementation
[Link] any daily weather record of some city is deleted or updated,store its old value in
some table.(Trigger)
CREATE TABLE old_daily_value
CalendarDate DATE NOT NULL,
SunriseTime TIMESTAMP NOT NULL,
SunsetTime TIMESTAMP NOT NULL,
AverageHumidity NUMBER(5,2) NOT NULL,
MaxTemperature NUMBER(5,2) NOT NULL,
MinTemperature NUMBER(5,2) NOT NULL,
WeatherStatus VARCHAR2(10) NOT NULL,
CityPincode NUMBER(6) NOT NULL
);
CREATE OR REPLACE TRIGGER Keep_Old AFTER UPDATE OR DELETE ON
dailyforecastlog FOR EACH ROW
DECLARE
BEGIN
DBMS_OUTPUT.PUT_LINE('TRIGGER FIRED');
INSERT INTO old_daily_value
DDU (Faculty of Technology, Department of IT) Page 35
Weather Forecast Log Management System Database Implementation
VALUES(:[Link], :[Link], :[Link],
:[Link], :[Link],:[Link],
:[Link],:[Link]);
END;
->UPDATE dailyforecastlog
SET maxtemperature=20
WHERE averagehumidity=30;
->SELECT * FROM old_daily_value;
[Link] a user search for a temperature info of a particular city then display temperature in
all the other formats also
CREATE OR REPLACE FUNCTION Temp_Format_F(Temp IN NUMBER)
DDU (Faculty of Technology, Department of IT) Page 36
Weather Forecast Log Management System Database Implementation
RETURN NUMBER
IS
TF Number;
BEGIN
TF:=(9*(Temp/5)+32);
return TF;
END;
CREATE OR REPLACE FUNCTION Temp_Format_K(Temp IN NUMBER)
RETURN NUMBER
IS
TK Number;
BEGIN
TK:=(Temp+273);
return TK;
END;
DECLARE
cpincode [Link]%type := :pincode;
DDU (Faculty of Technology, Department of IT) Page 37
Weather Forecast Log Management System Database Implementation
CURSOR display_t
IS
SELECT citypincode,temperature,startdatetime
FROM hourlyforecastlog
WHERE citypincode=cpincode;
tempf [Link]%type;
tempk [Link]%type;
BEGIN
FOR I IN display_t
LOOP
tempf:=Temp_Format_F([Link]);
tempk:=Temp_Format_K([Link]);
DBMS_OUTPUT.PUT_LINE('City Pincode: '|| cpincode);
DBMS_OUTPUT.PUT_LINE('Date and Time: '||[Link]);
DBMS_OUTPUT.PUT_LINE('Temperature(C): '|| [Link]);
DBMS_OUTPUT.PUT_LINE('Temperature(F): '|| tempf);
DBMS_OUTPUT.PUT_LINE('Temperature(K): '|| tempk);
DBMS_OUTPUT.PUT_LINE(' ');
END LOOP;
END;
DDU (Faculty of Technology, Department of IT) Page 38
Weather Forecast Log Management System Database Implementation
7. Create A procedure that will take an input as server ID and weather station ID and
will give us details of the employees working on it.
DDU (Faculty of Technology, Department of IT) Page 39
Weather Forecast Log Management System Database Implementation
CREATE OR REPLACE PROCEDURE get_details(serv IN [Link]%type,
wstation IN [Link]%type)
IS
CURSOR emp_details
IS
SELECT
[Link],[Link],[Link],[Link],[Link],e.s
erverid
FROM Server s FULL OUTER JOIN Employee e
ON [Link]=[Link] AND [Link]=[Link];
BEGIN
FOR I IN emp_details
LOOP
IF [Link]=serv THEN
IF [Link]=wstation THEN
DBMS_OUTPUT.PUT_LINE('Employee id:
'||[Link]);
DBMS_OUTPUT.PUT_LINE('Employee
Name:'||[Link]||' '||[Link]);
DBMS_OUTPUT.PUT_LINE('Designation:
'||[Link]);
END IF;
END IF;
END LOOP;
END;
DDU (Faculty of Technology, Department of IT) Page 40
Weather Forecast Log Management System Database Implementation
DECLARE
sid [Link]%type;
wsid [Link]%type;
BEGIN
sid:=:Server_Id;
wsid:=:Weather_station_Id;
get_details(sid,wsid);
END;
DDU (Faculty of Technology, Department of IT) Page 41
Weather Forecast Log Management System Database Implementation
[Link] a table for weather station ID WS1 containing the serverID of the servers at
that station,if any new server is added or removed it will trigger an event that will tell
us about that server.
CREATE TABLE servers_ws1
serid VARCHAR2(5),
serloc VARCHAR2(10)
);
DECLARE
CURSOR add_serv
IS
SELECT serverid,serverlocation FROM server WHERE
weatherstationid='WS1';
BEGIN
FOR I IN add_serv
LOOP
INSERT INTO servers_ws1
VALUES([Link],[Link]);
END LOOP;
DDU (Faculty of Technology, Department of IT) Page 42
Weather Forecast Log Management System Database Implementation
END;
SELECT * FROM servers_ws1;
CREATE OR REPLACE TRIGGER get_serv AFTER INSERT OR DELETE ON
server
FOR EACH ROW
DECLARE
BEGIN
IF :[Link]='WS1' THEN
IF INSERTING THEN
DBMS_OUTPUT.PUT_LINE('TRIGGER FIRED');
INSERT INTO servers_ws1
VALUES(:[Link],:[Link]);
DBMS_OUTPUT.PUT_LINE('Server having Server ID
'||:[Link]||' is now part of Weather Station having ID WS1');
END IF;
END IF;
IF :[Link]='WS1' THEN
IF DELETING THEN
DDU (Faculty of Technology, Department of IT) Page 43
Weather Forecast Log Management System Database Implementation
DBMS_OUTPUT.PUT_LINE('TRIGGER FIRED');
DELETE FROM servers_ws1
WHERE serid=:[Link];
DBMS_OUTPUT.PUT_LINE('Server having Server ID
'||:[Link]||' is now not a part of Weather Station having ID WS1');
END IF;
END IF;
END;
INSERT INTO server
VALUES('ABC','SE4','WS1');
SELECT * FROM servers_ws1;
DELETE FROM server
WHERE serverid='SE4';
DDU (Faculty of Technology, Department of IT) Page 44
Weather Forecast Log Management System Database Implementation
SELECT * FROM servers_ws1;
DDU (Faculty of Technology, Department of IT) Page 45
Weather Forecast Log Management System Future Enhancements of the System
6. FUTURE ENHANCEMENTS OF THE SYSTEM
DDU (Faculty of Technology, Department of IT) Page 46
7. BIBLIOGRAPHY
DDU (Faculty of Technology, Department of IT) Page 47